Posted By

sandropadin on 01/20/10


Tagged

flash parameters flashvars as3 actionscript3 loaderInfo flashvar


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

sandropadin


Top-Most Parent Loader Info


 / Published in: ActionScript 3
 

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

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.

  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. }

Report this snippet  

You need to login to post a comment.