/ Published in: ActionScript 3
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.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
var topParent :DisplayObject; var paramObj :Object = getLoaderInfo(this).parameters; for(var varName:String in paramObj) { trace("varName: " + varName + " Value: " + paramObj[varName]); } function getLoaderInfo(dispObj:DisplayObject):LoaderInfo { var root:DisplayObject = getRootDisplayObject(dispObj); if (root!=null) { return root.loaderInfo; } return null; } function getRootDisplayObject(dispObj:DisplayObject):DisplayObject { if (topParent == undefined) { if (dispObj.parent!=null) { return getRootDisplayObject(dispObj.parent); } else { topParent = dispObj; return topParent; } } else { return topParent; } }
URL: http://blogs.adobe.com/pdehaan/2006/07/using_flashvars_with_actionscr.html#comment-1977115