?
Solved

Need help running this function. Beginner!

Posted on 2009-02-20
5
Medium Priority
?
153 Views
Last Modified: 2012-05-06
Hi all

I need a little help. I have a loop which I want to play a certain number of times.

On the timeline I have this call. I want it to check the number of times it has been played and if its within the range gotoAndPlay(1);

Perhaps my syntax is not correct.

Any advice.

A.
function playMyLoop()
{
timesrun=timesrun+1	
if(timesrun < 3)
gotoAndPlay(1);
}
 
playMyLoop();

Open in new window

0
Comment
Question by:Abiel de Groot
  • 3
  • 2
5 Comments
 
LVL 5

Author Comment

by:Abiel de Groot
ID: 23694382
The above action script is within the moviclip timeline not the scene on which it is played. Not sure where I should put it.

A.
0
 
LVL 9

Expert Comment

by:jkunrein
ID: 23696464
I noticed that your conditional is not within braces.  Add braces around your gotoAndPlay command.

I'm assuming that you have timesrun initialized somewhere else.
0
 
LVL 5

Author Comment

by:Abiel de Groot
ID: 23698982


You mean like this

---------------------------
function playMyLoop()
{
timesrun=timesrun+1      
if(timesrun < 3)
   {
    gotoAndPlay(1);
   }
}
 
playMyLoop();
--------------------------------

Should I initialize like this

var timesrun = 0

?

Thanks for your help.

A.
0
 
LVL 9

Accepted Solution

by:
jkunrein earned 2000 total points
ID: 23710804
Try this code instead.  As someone who is mostly accustomed to working in VB, I find myself omitting the semicolon a lot of times, so I know how frustrating that can be.  

You might be able to initialize like that, but I went ahead and defined it as a number.

See if this does it for you.
function playMyLoop()
{
timesrun=timesrun+1;     
if(timesrun < 3)
   {
    gotoAndPlay(1);
   }
}
 
playMyLoop();
 
 
var timesrun:Number = 0;

Open in new window

0
 
LVL 5

Author Comment

by:Abiel de Groot
ID: 23735521
Sorry for the delay in getting back to you. many thanks

A.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
Suggested Courses
Course of the Month13 days, 16 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question