Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 08-20-2012, 07:37 PM   #1
Lou22
Member
 
Join Date: May 2009
Posts: 59
Default How to detect when nested movieclip reaches last frame

I would be grateful for help - it seems like something standard but I can't work out how to do it, and I would like to do it neatly:

I want to be able to detect when a nested movieclip reaches its last frame so that:
1. it (the movieclip) and its parent (example1) can be removed, and
2. a new movieclip (example2) can replace it.

I have:

1. a document class, to which is added dynamically:
2. mc_background, to which is added dynamically:
3. mc_example1, to which is added dynamically (on frame 3)
4. mc_try(this is several frames with a navigation button). (note: I have added mc_try to mc_example on frame 3 where it is needed, because it was the only way I could get stage.focus on the input textfield on mc_try to work with flashing cursor.)

I need -- mc_background to detect -- when mc_try reaches its last frame so that mc_example1(parent of mc_try) can be removed and replaced with mc_example2.

I thought this could be done with an event dispatcher on last frame of mc_try but I don't understand how to get mc_background to detect when this event occurs. Perhaps with enterframe but I thought this was bad practice.

Any help gratefully received.
Lou22 is offline   Reply With Quote
Old 08-20-2012, 08:16 PM   #2
abeall
Senior Member
 
Join Date: Feb 2006
Location: Washington, DC
Posts: 2,682
Send a message via AIM to abeall
Default

The way I'd probably do this is to dispatch an event on the last frame of the child MovieClip as a bubbling event, and listen for it in the parent class code.

ActionScript Code:
// on the last frame of the mc_try dispatchEvent(new Event("ExampleComplete", true)); // in your background class addEventListener("ExampleComplete", exampleCompleteHandler); function exampleCompleteHandler(e:Event):void {     // swap examples }
__________________
Aaron Beall | Flash portfolio | Fireworks extensions | Twitter
abeall is offline   Reply With Quote
Old 08-21-2012, 04:35 AM   #3
henke37
Senior Member
 
henke37's Avatar
 
Join Date: Mar 2009
Location: Sweden
Posts: 9,779
Send a message via Skype™ to henke37
Default

I would just add the listener to the right object instead of using a bubbling event. It helps when you use the same event type multiple times.
__________________
Signature: I wrote a pair of articles about the timeline.
henke37 is offline   Reply With Quote
Old 08-21-2012, 05:25 AM   #4
Lou22
Member
 
Join Date: May 2009
Posts: 59
Default How to detect when nested movieclip reaches last frame

Thanks so much for the help - it works now!
Lou22 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 06:29 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2013, 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.