[swfmill] Accessing frames in AS3
trevor.burton at virtuefusion.com
Mon Nov 12 11:25:12 PST 2007
Sorry, this wasn't clear...
I suggested you put your frames in a MovieClip in order that you can access them once the swf has loaded.... this is just a personal preference as i think it makes things easier - there are other ways to do it.
when your swf has loaded you can instantiate the FramesClip using the 'getDefinition' or getDefinitionByName calls to instantiate the FramesClip class because the swf that's loading it doesn't have any reference to the FramesClip class. so you can't just do
it just instantiates the class from it's qualified classname - you can treat it as a MovieClip and do your gotoAndPlay/Stop calls on it. I'm not sure how you'd give it the classname in swfmill - cause i've not used swfmill for compiling AS3 swfs.
If that's a problem the alternative is to have your content on the main timeline of the swf that's being loaded and then attach the Loader object to the displaylist (either before the load starts or after it's completed). Loader extends DisplayObject so you can addChild() it. this should mean that your content is visible as soon as the load's complete (or as soon as it's attached after the load is complete). But i'm not sure how you'd handle controlling the timeline from there as i don't use this technique myself... you should be able to work it out fairly easily though.
the Event that's passed to your loadComplete handler contains information about the Loader that fired it - so you can do
var loader:Loader = event.target as Loader;
to get the loader object
14-16 Betterton Street
London, WC2H 9AH
t: 0207 420 6420
m: 07954 239 024
From: swfmill-bounces at osflash.org on behalf of Joel Poloney
Sent: Mon 12/11/2007 18:52
To: swfmill at osflash.org
Subject: Re: [swfmill] Accessing frames in AS3
create a MovieClip in your swf and create the frames that you'll want to access in that swf.
Load the swf in and create a new instance of the MovieClip with your accessible frames in.
for instance if your clip is called 'FramesClip' - and is being exported for actionscript - it is automatically (in the Flash IDE and Flex, anyway) compiled into a Class that extends MovieClip, so you can instantiate it with 'new' as you would any other class.
haven't tested this at all but this is the process.
var context:LoaderContext = new LoaderContext( false, ApplicationDomain.currentDomain )
var loader:Loader = new Loader();
loader.addEventListener ( Event.COMPLETE, handleLoadComplete );
loader.load(new URLRequest( "framesclip.swf" ), context );
private function handleLoadComplete(event:Event):void
var ClipClass:Class = getDefinition("FramesClip") as Class;
var clipInstance:MovieClip = new ClipClass();
In this case i've loaded the other swf into the same ApplicationDomain as the swf that's loading it. That's not necessary, but you'd have to get the definition from the Loader's ApplicationDomain if you don't.
Interesting news about the changes to AS3. Alright, so I understand the process, but are you saying that I should name the movieclip as "FramesClip" when I compile it in swfmill? Is there a way I can utilize the event:Event var in the handleLoadComplete function when creating the ClipClass? I noticed that you use this var at all. I guess I don't really understand the getDefinition line of your callback function. Can you explain this a little better?
What other AS3 compilers are there?
The haXe compiler will compile AS3 if I'm not mistaken.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 6718 bytes
Desc: not available
Url : http://osflash.org/pipermail/swfmill_osflash.org/attachments/20071112/4d64bf8d/attachment-0001.bin
More information about the swfmill