Here is my code below. Its simple. I just need to get the var defined on the Main Stage and have every external swf get access to that var.
Here is the code that doesn't work:
IN MAIN SWF:
var ThePath:String;
ThePath = "happy/go/lucky/";
/// Below the code is in A LOADED SWF from the Main previous timeline above. (now showing full code to do this here)
var myMC:MovieClip;
myMC= parent as MovieClip;
trace("Your VAR PATH IS " + myMC.ThePath); /// DOES NOT WORK.
Thanks happy stackers!
UPDATE 4-31-12
IN SHORT: I need to make a global var in the main stage and allow all others externally loaded swf's access to that var.
Best Answer
You should use camelCase as variable definitions.
EDIT:
Another solution is to pass a reference to the parent in the child swf when you load it in the loader (by setting a value, setting the reference) and then the child can reference the parent.
i.e.:
Parent:
function startLoad() { var mLoader:Loader = new Loader(); var mRequest:URLRequest = new URLRequest(“Child.swf”); mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler); mLoader.load(mRequest); }
function onCompleteHandler(loadEvent:Event) { var childMC:MovieClip = loadEvent.currentTarget.content; addChild(childMC:MovieClip); childMC.refToMainSWF = this; }
For reference: http://genaboo.wordpress.com/2008/03/27/as2_vs_as3_root_parent_communicating_between_swfs/