I am trying to figure out why changes to variables and elements are not reflected when one SWF is loaded into another.
main.swf
var myLoader:Loader = new Loader();
myLoader.load(new URLRequest("products.swf"));
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, finishLoading);
function finishLoading(loadEvent:Event):void {
myLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, finishLoading);
myScrollPane.source = loadEvent.currentTarget.content;
trace(loadEvent.currentTarget.content.bg.height);
trace( Object(myLoader.content).myheight);
myScrollPane.update();
}
products.swf
var myheight:Number = 50;
bg.height = 500;
var productsXML:XML = new XML();
var productsLoader:URLLoader = new URLLoader(new URLRequest("http://shop.stevesmusicstuff.com/rsscategoryproducts.sc?categoryId=2"));
var gdNs:Namespace = new Namespace("http://app.fastshoppingcart.com/rss/featuredProduct/1.0");
productsLoader.addEventListener(Event.COMPLETE, productsLoaded);
function productsLoaded(event:Event):void {
productsXML = XML(productsLoader.data);
var itemDisplay:productDisplay = new productDisplay();
addChild(itemDisplay);
itemDisplay.x = 257.45;
itemDisplay.y = 390; //95;
itemDisplay.productImage.source = productsXML.channel.item[0].gdNs::image.gdNs::image_link;
itemDisplay.productTxt.htmlText = productsXML.channel.item[0].title;
bg.height = 1000;
myheight = 1000;
}
When the main file is tested the out put of the traces is 50 & 300 which is what the variable and the bg object are set to at the top instead of what they changed to in the productsLoaded(event:Event) function.
It’s as if the myloader listener is ignoring changes to variables & elements inside of the loaded SWFs listener function.
Seems wrong and very confusing.