Sorry for my English… (-:
I’m having some problems on getting full communication between loaded SWFs. I’m totally stuck and my timing is running.
Suppose the following scenario:
Father-SWF has his own class and loads A-SWF and B-SWF. A and B SWF has his own class and package. To exchange values and run functions between SWF, I’m using a Global class with public static vars. Some of this vars are function, example:
GLOBAL CLASS WITH STATIC VARS (com. with other class and package beetween SWF)
package scripts
{
public class GlobalAct
{
public static var mainStage:Object;
public static var myFuncGlobalA:Function;
public static var myFuncGlobalB:Function;
}
}
MAIN CLASS FATHER SWF
package
{
import flash.display.MovieClip;
import scripts.GlobalAct;
public class FatherClass extends MovieClip
{
public function FatherClass():void
{
GlobalAct.mainStage = this;
GlobalAct. myFuncGlobal = myFunc;
}
public function myFunc():void
{
//some wild stuff
}
}
}
A_SWF CLASS
package scripts
{
import flash.display.MovieClip;
import scripts.GlobalAct;
public class Layout extends MovieClip
{
private var someMc:MovieClip;
public function Layout()
{
someMc = new MovieClip();
someMc. addEventListener(MouseEvent.CLICK, mouseFunc);
}
public function mouseFunc (evt:MouseEvent):void
{
GlobalAct. myFuncGlobalA ();
}
}
}
B_SWF CLASS
Similar to A-SWF class but with other kind of functions…calling “GlobalAct.myFuncGlobalB();” for example.
This works great, when I run Father-SWF, it load every SWF and functions run from SWF to SWF.
The problem happens when I load Father-SWF in another SWF. There is a MAIN-SWF with his own set of class and a Global static vars Class.
WORKING
Father-SWF -> many SWF that could load other SWF
NOT WORKING
Main SWF -> Father-SWF -> many SWF that could load other SWF
When this happens none of the Global functions seems to work. The other Global vars seems OK, only function vars seems not to work.
I only get the error:
**“TypeError: Error #1006: value is not a function. at scripts::Layout/ mouseFunc ()” **
when I try to click a button inside A-SWF.
Does I lose my Global reference when loading the Father-SWF in another SWF?
Does the MouseEvent who call the global function enclosed when loaded in Main SWF?
How can I make this bullet proof and generic for every situation?
What’s the best oop practice to communicate between class and SWF on AS3?
I also tried a Singleton approach without success. The Singleton solution works if not loaded on the Main SWF!!
Need helppppp :x