[swfmill] Accessing frames in AS3

Trevor Burton trevor.burton at virtuefusion.com
Mon Nov 12 01:21:41 PST 2007


This isn't a problem with swfmill, more about how AS3 is different to AS2.
 
If you want to access frames in a movieclip that's being loaded into another swf you can't cast to MovieClip like you used to do in AS2. Because of the the way the loading and display list processes have been reworked you have to handle it a little differently. It's something like this....
 
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();
 
    addChild(clipInstance);
 
    clipInstance.gotoAndPlay("whatever");
}
 
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.
 
>using flex 2's native mxmlc compiler... or any other compiler for that matter
 
What other AS3 compilers are there?
-------------------------
Trevor Burton
Flash Developer
VirtueFusion
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: Sun 11/11/2007 20:12
To: swfmill at osflash.org
Subject: [swfmill] Accessing frames in AS3


Hey all,

I've been trying to use swfmill to generate a movie in which I can access the specific frames (eg: gotoAndStop(2) for frame 2) in AS3. But, I haven't been successful yet. Is this possible? For example, I want to create a movie with 10 frames, and on each frame there's an image, text, etc. 

I've been reading through the archives of the list and tried taking an existing swf that I know I can access frames for, running swf2xml on it and then converting the output xml back to a swf. When I do this, I can import the newly generated swf in to Flash CS3 and have no problems, but trying to access it through actionscript (eg. using flex 2's native mxmlc compiler... or any other compiler for that matter), I don't see anything. I can't access any frames and I can't even play the movie. When I'm reading it in, I cast the swf to a MovieClip. Is this correct? Any other suggestions? 

The other thing I'm doing, is I'm reading it in over a network (non-local file). This is pretty standard though, using a Loader with a callback function. Could this be an issue? For some reason swfmill has some network security settings? 

Thanks!

-- Joel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 6590 bytes
Desc: not available
Url : http://osflash.org/pipermail/swfmill_osflash.org/attachments/20071112/74b73225/attachment.bin 


More information about the swfmill mailing list