Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 11-02-2009, 04:49 PM   #1
Bosworth
~[b{}x]~
 
Bosworth's Avatar
 
Join Date: Oct 2004
Location: Olympia, wa
Posts: 517
Default timeline control of externally loaded swfs

So - still new to AS 3.0 -

I have a set of SWFs loaded, and have successfully added them to the stage, and can assign basic methods ( gotoAndPlay(), stop() etc..) based on MouseEvents. I can't quite figure out, however, how to assign methods based on frame number or label, triggered by labels on the currently playing SWF timeline.

So, for example: externally loaded swf starts playing, and a listener is set up to listen for a "stop" label, which would activate stop();

I can obviously just drop a stop(); in the timeline of the loaded swf, but I am really trying to banish all code from timelines, period.

I could set up a frame-based listener to decide if a label exists at the current frame, and then to evaluate if that frame label == "stop"... but that seems pretty messy, and because it has to run at every frame, CPU heavy...

So - the question is really about listeners, I guess. What event would I listen for? Something like a MouseEvent - but ... a LabelEvent instead Obviously - this doesn't exist, but something like it would be perfect.

Any ideas?

Or am I just overcomplicating things, and, a couple simple actions scattered here and there isn't that big of a deal...


cheers -

~[b{}x]~
__________________
I dont want the world.
I just want your half.

Last edited by Bosworth; 11-02-2009 at 04:52 PM.
Bosworth is offline   Reply With Quote
Old 11-02-2009, 07:42 PM   #2
ASWC
Super Moderator
 
ASWC's Avatar
 
Join Date: Dec 2007
Location: Greenville, SC
Posts: 6,528
Default

I would just include a dispatchEvent in the swfs right at the frame I want and simply make my main file listen for these events and take action.
__________________
aswebcreations
Super Duper!
ASWC is offline   Reply With Quote
Old 11-02-2009, 08:03 PM   #3
Bosworth
~[b{}x]~
 
Bosworth's Avatar
 
Join Date: Oct 2004
Location: Olympia, wa
Posts: 517
Default

Not sure if I follow you

are you saying that the eventDispatch routine would be included in the external swf? I'm actually hoping to include zero code in any timeline. The idea would be to create a listener in the main.as class to listen for frame label changes.

I actually got this working:

ActionScript Code:
targetInstance.addEventListener(Event.ENTER_FRAME,checkLabel, false, 0, true);                     }         private function checkLabel(evt:Event){             trace(targetInstance.name + " current frame = "+ targetInstance.currentLabel);              if (targetInstance.currentLabel=="stop"){                 targetInstance.stop();                 targetInstance.removeEventListener(Event.ENTER_FRAME,checkLabel);              }         }

which does work, but I'm a little hesitant to incorporate it as I would guess its a bit cycle heavy.

Is it possible to create a custom listener to make this work?

thx for the reply
__________________
I dont want the world.
I just want your half.
Bosworth is offline   Reply With Quote
Old 11-02-2009, 08:36 PM   #4
ASWC
Super Moderator
 
ASWC's Avatar
 
Join Date: Dec 2007
Location: Greenville, SC
Posts: 6,528
Default

Quote:
Originally Posted by Bosworth View Post
I'm actually hoping to include zero code in any timeline.
That's too bad since dispatching an event directly from the swf timeline would save you a lot of resources and troubles. Other than that you only have enterframe to check the frame labels but do it globally at least and not with an enterframe event for each swf.
__________________
aswebcreations
Super Duper!
ASWC is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:57 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.