tahadaf
September 8th, 2009, 09:46 AM
Hi,
There's something about loading external swf files into your project that I'm not sure if it's possible or not, so hopefully you can give me some advice?
This is what I know:
I know how to load an external swf file into my main flash file and I have also been able to build an interface class so that I can call public functions in the loaded swf from the main flash file... all works perfect.
This is what I don't know:
I wonder how I can use the very same loaded swf file twice in my file?! that is, I load it once and then somehow create two or more instances of the loaded swf file...! is it possible at all?
For your notice, this is how I have loaded the current swf file into my project:
This is the interface class
package
{
public interface IInput
{
function label(a:String):void;
}
}
This is how the codument class of the loaded SWF looks (this is just the important codes for your notice of course)
package
{
public class Main extends Sprite implements IInput
{
public function Main():void
{
}
public function label(a:String):void
{
// do something
// main document class will call this function
}
}
}
And below is how the document class of the main file looks like after completly loading the external swf file in itself...
private function onSwfDone(e:Event):void
{
mySwf = e.currentTarget.content as IInput;
// add the loaded swf class to your project
this.addChild(mySwf as Sprite);
// call a function on the loaded swf
mySwf.label("I am called from the main stage!");
}
As you see above, I am able to easilly work and call different public function in the above "mySwf" variable... but I do not know how to create another instance of the loaded swf file!
If anything you can think of, that would be great if you can share it.
Thanks,
Hadi
There's something about loading external swf files into your project that I'm not sure if it's possible or not, so hopefully you can give me some advice?
This is what I know:
I know how to load an external swf file into my main flash file and I have also been able to build an interface class so that I can call public functions in the loaded swf from the main flash file... all works perfect.
This is what I don't know:
I wonder how I can use the very same loaded swf file twice in my file?! that is, I load it once and then somehow create two or more instances of the loaded swf file...! is it possible at all?
For your notice, this is how I have loaded the current swf file into my project:
This is the interface class
package
{
public interface IInput
{
function label(a:String):void;
}
}
This is how the codument class of the loaded SWF looks (this is just the important codes for your notice of course)
package
{
public class Main extends Sprite implements IInput
{
public function Main():void
{
}
public function label(a:String):void
{
// do something
// main document class will call this function
}
}
}
And below is how the document class of the main file looks like after completly loading the external swf file in itself...
private function onSwfDone(e:Event):void
{
mySwf = e.currentTarget.content as IInput;
// add the loaded swf class to your project
this.addChild(mySwf as Sprite);
// call a function on the loaded swf
mySwf.label("I am called from the main stage!");
}
As you see above, I am able to easilly work and call different public function in the above "mySwf" variable... but I do not know how to create another instance of the loaded swf file!
If anything you can think of, that would be great if you can share it.
Thanks,
Hadi