Top-Most Parent Loader Info


/ Published in: ActionScript 3
Save to your folder(s)

Gets the loaderInfo of the top-most parent. For example, if you load an external swf, placing this code within that external swf can access the loaderInfo and FlashVars for the parent SWF (the SWF that has loaded this external SWF) from within the child SWF.


Copy this code and paste it in your HTML
  1. var topParent :DisplayObject;
  2. var paramObj :Object = getLoaderInfo(this).parameters;
  3. for(var varName:String in paramObj) {
  4. trace("varName: " + varName + " Value: " + paramObj[varName]);
  5. }
  6.  
  7. function getLoaderInfo(dispObj:DisplayObject):LoaderInfo {
  8. var root:DisplayObject = getRootDisplayObject(dispObj);
  9. if (root!=null) {
  10. return root.loaderInfo;
  11. }
  12. return null;
  13. }
  14.  
  15. function getRootDisplayObject(dispObj:DisplayObject):DisplayObject {
  16. if (topParent == undefined) {
  17. if (dispObj.parent!=null) {
  18. return getRootDisplayObject(dispObj.parent);
  19. }
  20. else {
  21. topParent = dispObj;
  22. return topParent;
  23. }
  24. }
  25. else {
  26. return topParent;
  27. }
  28. }

URL: http://blogs.adobe.com/pdehaan/2006/07/using_flashvars_with_actionscr.html#comment-1977115

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.