Solved

Repeat an action every frame

Posted on 2006-11-14
5
209 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
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.

705 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

12 Experts available now in Live!

Get 1:1 Help Now