Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Repeat an action every frame

Posted on 2006-11-14
5
Medium Priority
?
218 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
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. …
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.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.
Suggested Courses

604 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