I have two .SWFs one is loading in a parent SWF. I’m trying to pass a bitmap total width by using LocalConnection.send() method.
I can received the variable result but after clicking twice in same menu option. When first clicked I got a 0 as result. After second time, I got the right bitmap width total (ex: 1800).
I set a global var and trying to understand why it returns 0 at first click instead of 1800 dynamically supposed to return.
Does anyone know HOW to resolve that?
PS: I draw container.panelMC in main.fla
In my loadPhoto (loadPhoto.swf) class:
for (var i:uint=0;i<tabPhotos.length;i++) {
...
bitmapWidthTotal += 900;
}
sender = new LocalConnection();
sender.addEventListener(StatusEvent.STATUS, handleStatusEvent);
sender.send("abc", "setBitmapSize", bitmapWidthTotal);
In my Main class (main.swf):
// Global var
private var testBitmap;
...
receiver = new LocalConnection();
receiver.connect("abc");
receiver.client = this;
public function setBitmapSize(bitmapWidth:uint):void
{
this.testBitmap = bitmapWidth;
trace("**setBitmapWidth: " + bitmapWidth);
}
private function handleMenu(event:CustomEventCenter):void
{
menuOption = event._name.menu;
menuOption.addEventListener(MouseEvent.CLICK, handleOptionClicked);
}
private function handleOptionClicked(event:MouseEvent):void
{
switch(event.target.name) {
case "menuOption1" :
loader.load(new URLRequest("option1.swf"));
container.panelMC.width = getBitmapSize(); // got 0 first click
trace("Option1 Width: "+container.panelMC.width);
scrollbarMC.resetThumbScroll(container, false);
break;
...
}
}
private function getBitmapSize():uint
{
return testBitmap;
}