Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 12-20-2009, 08:22 AM   #1
simonn
Registered User
 
Join Date: Dec 2009
Posts: 6
Default Help with refer

Hi,

I'm Simon, and I'm quite new to ActionScript 3.0 but I think it's fun to learn.

I've got a problem and would be very glad for your helping

On the stage, I've got 4 boxes (shapes) which all are MovieClips and each has 11 frames with different drawed symbols. When a box, inside it's movieclip, comes to a frame, I've written stop(); there so it stays at the current drawed symbol.

On the frame 1 in each box, there is nothing, and I if the MovieClip is stop on frame 1, there are nothing drawed, so it is empty.

All boxes has instance name, first: box_1, second: box_2 and so on...

In another MovieClip on stage, I've written this function. I want the loop to find the first "empty box" (which is stop at frame 1) and then move that MovieClip to frame 3 and stop.

So, if box_1 is at frame 3, it will check if box_2 is at frame 1 and so on

ActionScript Code:
function findBox (event) {     for (var i:int = 0; i < 4; i++) {                 if (MovieClip(root).box_+i.currentFrame == 1) {                             MovieClip(root).box_+i.gotoAndStop(3);         break;         }

I would be very glad if someone could explain how to write this.

Thanks
/Simon
simonn is offline   Reply With Quote
Old 12-20-2009, 09:42 AM   #2
RogerClark
Senior Member
 
Join Date: Sep 2009
Location: Melbourne, Australia
Posts: 1,040
Default

Hi Simon,

I'm not totally sure what you're trying to do, but I can see some errors in your code

so I've tried to fix them

ActionScript Code:
function findBox (event) {     for (var i:int = 0; i < 4; i++) {                 if (MovieClip(root)["box_"+i].currentFrame == 1) {                             MovieClip(root)["box_"+i].gotoAndStop(3);         break; }// if }// for }
RogerClark is offline   Reply With Quote
Old 12-20-2009, 09:59 AM   #3
simonn
Registered User
 
Join Date: Dec 2009
Posts: 6
Default

Hi Roger,

Thank you very much. By correcting my code, you solved my problem.

Have a nice weekend

Regards
/Simon
simonn 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 04:34 AM.

///
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.