# Main swf to loaded swf communication

**URL:** <https://forum.kirupa.com/t/main-swf-to-loaded-swf-communication/324291>\
**Category:** flash\
**Created:** [August 12, 2011, 2:46pm UTC](https://forum.kirupa.com/t/main-swf-to-loaded-swf-communication/324291 "2011-08-12T14:46:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![FlashCurious](https://avatars.discourse-cdn.com/v4/letter/f/71c47a/32.png) [@FlashCurious](https://forum.kirupa.com/u/FlashCurious)\
**Post date:** [August 12, 2011, 2:46pm UTC](https://forum.kirupa.com/t/main-swf-to-loaded-swf-communication/324291/1 "2011-08-12T14:46:56Z")

</div>

I’m upgrading some elearning code to AS3 and having trouble with a “Jump Menu” that loads at 3 in the main swf. The idea is that users can jump to any frame in the module randomly.

Here is the main swf code:

//Main swf shell  
var menuLoader:Loader = new Loader();  
menuLoader.contentLoaderInfo.addEventListener(Event.INIT, doneLoading3);  
var menuMC:MovieClip = new MovieClip();  
stage.addChild(menuMC);  
function doneLoading3(e:Event):void {  
menuMC = MovieClip(menuLoader.content);  
stage.addChildAt(menuMC, 3);  
menuMC.visible = false;  
};  
function thirdClip():void{  
menuLoader.load(new URLRequest(“jump\_menu\_as3.swf”));  
};  
thirdClip();

The menu gets it’s content from an XML file and builds the links dynamically:

//Loaded swf jump\_menu\_as3  
var textFormat:TextFormat = new TextFormat(“Verdana”, 12);  
var xml:XML;  
var xmlLoader:URLLoader = new URLLoader();  
var [url:URLRequest](http://www.kirupa.com/forum/URLRequest) = new URLRequest(“media.xml”);  
xmlLoader.load(url);  
xmlLoader.addEventListener(Event.COMPLETE, onXmlLoad);  
function onXmlLoad(e:Event):void {  
xml = new XML(xmlLoader.data);  
var mediaElements2:XMLList = xml.level2.media2;  
var len:int = mediaElements2.length();  
for (var i:int = 0; i \< len; i++) {  
var tf:TextField = new TextField()  
tf.defaultTextFormat = textFormat  
tf.htmlText = mediaElements2\*  
tf.x = 10  
tf.y = 20\*i + 10  
tf.width = 300  
tf.selectable = false;  
jump\_menu.megaMan.addChild(tf)  
tf.addEventListener(TextEvent.LINK, linkEvent);  
function linkEvent(event:TextEvent):void {  
switch (true) {  
case (event.text == “myText”):  
MovieClip(this.parent.parent).widget1 = 0;  
MovieClip(this.parent.parent).nextClip();  
break;

case (event.text == “myText1”):  
MovieClip(this.parent.parent).widget1 = 1;  
MovieClip(this.parent.parent).nextClip();  
break;

case (event.text == “myText2”):  
MovieClip(this.parent.parent).widget1 = 2;  
MovieClip(this.parent.parent).nextClip();  
break;  
default :  
trace(“curious”);  
}  
}

The nextClip function reads the widget1 variable and gets the correct swf to load. I can trace that the XML links are loading and that they trigger a trace, but I can’t get them to talk to the main swf. Please help me figure out what I’m missing.

Thanks
