Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Repeat an action every frame

Posted on 2006-11-14
5
Medium Priority
?
220 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 1400 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

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

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. …
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…
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.
Suggested Courses

581 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