Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 04-17-2006, 04:07 PM   #1
ROYOW
Registered User
 
Join Date: Oct 2005
Posts: 48
Default Maybe a simple question...but need your help..

Hi guys,

I have a simple question but can't figure it out by myself.
I want to assign 5 different movie clips to do the same action. I know I can list like:

mc1.gotoAndPlay(2);
mc2.gotoAndPlay(2);
mc3.gotoAndPlay(2);
mc4.gotoAndPlay(2);
mc5.gotoAndPlay(2);

I'm wondering if there is any simple way to use less AS lines to do the same work?

Anyone can help? Thanks!
ROYOW is offline   Reply With Quote
Old 04-17-2006, 04:45 PM   #2
tg
done
 
Join Date: Jun 2001
Location: portland, or
Posts: 8,106
Default

ActionScript Code:
for(var i=1;i<6;i++){    this['mc'+i].gotoAndPlay(2); }
__________________
tg
---
what the hell was i thinking?
tg is offline   Reply With Quote
Old 04-17-2006, 08:55 PM   #3
ROYOW
Registered User
 
Join Date: Oct 2005
Posts: 48
Default

Thank you, tg.
I have never thought about using loop. However, I'm wondering if you could think of some codes that are more flexible. For instance, I have a button A that is attached the action: mc1.gotoAndPlay(1) and mc2-5 gotoAndPlay(2). Also at the same time, I have another button B that is assigned: mc2.gotoAndPlay(1) and mc1, 3-5 gotoAndPlay(2)

How can you make those different MCs do the same action with less code?

Thank you for your help in advance.
ROYOW is offline   Reply With Quote
Old 04-17-2006, 09:04 PM   #4
tg
done
 
Join Date: Jun 2001
Location: portland, or
Posts: 8,106
Default

so, is it just button a and button b? or do you have buttons c,d,e..... that have their own individual settings also?
__________________
tg
---
what the hell was i thinking?
tg is offline   Reply With Quote
Old 04-17-2006, 11:00 PM   #5
ROYOW
Registered User
 
Join Date: Oct 2005
Posts: 48
Default

Yes, tg, I have buttons c,d,e, etc..
In fact, I have 11 buttons. What I'm trying to do is that a Movie Clip (button) will keep its active state when the user click on it but it will go to back to its original state when the user clicks on another Movie Clip(button). I used very stupid way to make it work but thought there should be a better way to write the code.

Thanks for your help again.
ROYOW is offline   Reply With Quote
Old 04-18-2006, 02:59 PM   #6
tg
done
 
Join Date: Jun 2001
Location: portland, or
Posts: 8,106
Default

well the easiest way would be to reset all buttons back to default setting (inactive) then set the one clicked to active.
so when a button is clicked. all are set to inactive then set the selected button to active.
__________________
tg
---
what the hell was i thinking?
tg 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 Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple preloader question ( when using components) silentweed ActionScript 2.0 3 03-22-2006 11:09 PM
[AS1] Swapdepth using txt files and dynamic content for game. superbnerb Gaming and Game Development 3 09-22-2004 07:27 PM
simple button question paolo1234567891 ActionScript 1.0 (and below) 12 12-19-2003 07:55 PM
Simple scoring question caffrey75 Gaming and Game Development 2 11-14-2003 10:45 AM
simple simple syntax question quinu ActionScript 1.0 (and below) 2 01-17-2003 01:55 AM


All times are GMT. The time now is 04:21 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.