Solved

Repeat an action every frame

Posted on 2006-11-14
5
210 Views
Last Modified: 2012-05-05
I’m running Flash 8 and have a question about how to repeat an action on every frame.

I have a movie that has about 600 frames and I need an actionscript to run on every frame.  Initially I thought I could just create a layer with a keyframe at the first frame and another at the last one.  Then include an action in the initial keyframe and hope that the action is executed every frame…that didn’t work.

So now I’m in need of help.

To be more specific, I have a slider and need to record the value of the slider (user moves it throughout the movie to indicate enjoyment) every second (or every frame…either works).  So the code should look something like this:

On enter frame -> get value from slider -> store value from slider in array -> increment counter -> goto next slide

I could put the equivalent of that in every single frame (keyframe each), but as you can imagine this is not a very elegant or practical solution.

Any help is appreciated.

Thanks in advance!
Jeff
0
Comment
Question by:buktotruth
  • 3
  • 2
5 Comments
 
LVL 13

Expert Comment

by:FLAASHER
ID: 17943583
Your qestion is "Repeat an action every frame" ?

simply make the action u want to repeat as function :

function flaasher(){
//ur action code
//put it here
}


then call this function on enter each frame of ur time line like this :

_root.onEnterFrame = function(){
flaasher();
}


thats all :)

FLAASHER
0
 

Author Comment

by:buktotruth
ID: 17943593
what i'm trying to do is avoiding entering the code 600 times (once per frame)...so where would i put that code to make it replicate for each frame?  And how would i set up the timeline?

Thanks!
0
 
LVL 13

Accepted Solution

by:
FLAASHER earned 350 total points
ID: 17943650
put ur code in this function :

function flaasher(){
//ur action code
//put it here
}


you need to put this funtion in the frist frame in ur time line


also in the frist frame call the function by this code :

_root.onEnterFrame = function(){
flaasher();
}



thats all


FLAASHER
0
 

Author Comment

by:buktotruth
ID: 17943688
Awesome...worked like a charm.

Thanks for the Help!!
0
 
LVL 13

Expert Comment

by:FLAASHER
ID: 17943720
U welcome :)

FLAASHER
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

863 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now