Copy link to clipboard
Copied
I need help with the game I am working currently. On the main timeline Actions frame I have a loader class called myLoader. I attached that to a movieclip called currentSWF. I have a movieclip called SpinningCard in the library which I dynamically attached to the stage. Inside the SpinningCard movieclip there is another movieclip Card. In the Card movieclip I have 10 frames and on each frame I want to attach a different instance of the movieclip currentSWF. How can I do achieve that?
here's what I have till now...
On the main timeline Actions frame...
var loader:Loader=new Loader();
loader.load(new URLRequest("CardGraphics.swf"))
var currentSWF:MovieClip;
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoaded);
function swfLoaded(e:Event):void {
currentSWF = MovieClip(loader.contentLoaderInfo.content);
addChild(currentSWF);
}
Inside the Card movieclip on the first frame I have this code...
var a1:MovieClip = MovieClip(parent.parent.getChildByName('currentSWF'));
CardFrame1.addChild(a1);
//CardFrame1 is an empty movieclip which is there on the frame 1 of Card Moveiclip.
I am getting error : Parameter must be non-null. How can I solve. Can anyone please help me.
Copy link to clipboard
Copied
Well first thing you need to do to fix your error is this:
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoaded);
function swfLoaded(e:Event):void {
currentSWF = MovieClip(loader.contentLoaderInfo.content);
currentSWF.name = "currentSWF";
addChild(currentSWF);
}
However, to attach a different instance of currentSWF you are going to have to load the SWF 10 times as there is no way to clone a MovieClip. Alternatively, you can give it a linkage name in the library and instantiate it after loading the SWF by:
var swfClass:Class = ApplicationDomain.currentDomain.getDefinition(linkageName) as Class;
for (var idx:int = 0; idx < 10; idx++)
{
var currentSWF:MovieClip = new swfClass() as MovieClip;
addChild(currentSWF);
}
Copy link to clipboard
Copied
Hi Nabren
I'm also looking to load a library based movie-clip into a stage based movie-clip, so that I can inturn swap it with other movie clips to act as different pages (page2_mc etc) which will be used in different sections of the application to give chapters as such.
I've had a go at the above but can't get a result, though it did not throw an error. I also had a trace() on each side and both of those triggered.
The stage based mc I called pageMC and the content mc I called content the same as your example
trace('loader - cx'); | |
var loader:Loader=new Loader(); | |
var pageMC:MovieClip; | |
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoaded); | |
function swfLoaded(e:Event):void { | |
pageMC = MovieClip(loader.contentLoaderInfo.content); | |
pageMC.name = "pageMC"; | |
addChild(pageMC); | |
} | |
trace("Menu 4"); |
I'd appreciate some assistance. I would like to use internal MC's as I want to put the application to iOS and Android and believe by using movieclips I should be able to have some code with them whereas importing swf's I can't.
Thanks
Copy link to clipboard
Copied
If you use AIR SDK 3.6 (might work with earlier versions, can't remember what version introduced this) you can package multiple .SWF files into the .IPA file for iOS. This means you can load them like a regular dynamic SWF (with a relative path) and they will still function as before. Unless you package them with the iOS build you cannot have any code outside of your main .SWF.
The difference is Android has an Adobe AIR app while iOS they are packaged into native code and there is no interpreter to run your ActionScript code at runtime.
Copy link to clipboard
Copied
Just loaded in the SDK for what I expected is 3.6, it shows as 3.6.0.5990. Does that sound correct or may I have pciked up a non stable dev version.
Thank you for the SWF information. I will start looking at that avenue. A question though, can one MovieClip be loaded into another, or only external swfs.
Thank you
Find more inspiration, events, and resources on the new Adobe Community
Explore Now