Return to Snippet

Revision: 22736
at January 20, 2010 15:18 by sandropadin


Initial Code
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;
	}
}

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

Initial Description
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.

Initial Title
Top-Most Parent Loader Info

Initial Tags
flash

Initial Language
ActionScript 3