ActionScript 3.0 :: Timer Intervals In Correlation To ENTER_FRAME?

Feb 9, 2009

There are a few fairly intensive procedures the class goes through, which require me to stagger out the action taking place. That is to say, if I were to use recursion, there are times when I'd easily hit a stack overflow, so to compensate I'm avoiding recursion through recording information in class level variables and running through the routine again (and again and again) on an ENTER_FRAME event.

This all works great, and I'm happy with the result. The only annoying bit is that performance is better when the frame rate's higher (and slower when it's lower). Run the class at 30fps, and the time it takes to complete is significantly slower than at 120fps. No surprise there, but still annoying since I'm not interested in making the user make changes in their framerate to accomodate the class.

So I considered switching to a timer-based method, but then I remembered something about the Timer class accomodating the framerate of the SWF. Looking it up confirmed what I remembered:

...if a SWF file is set to play at 10 frames per second [fps], which is 100 millisecond intervals, but your timer is set to fire an event at 80 milliseconds, Flash Player will fire the event close to the 100 millisecond interval.

Now I'm wondering if it's even worth the effort, since it would appear that the end result would be much the same as it is now using enter frame.

View 2 Replies


Similar Posts:


ActionScript 3.0 :: How To Change Timer Intervals

Jul 31, 2010

I'd like to change a timer interval, In my code I first initialize the timer with a selected interval with :
Code:
gameTimer=new Timer(interval,0);
gameTimer.addEventListener(TimerEvent.TIMER, IALoop);
gameTimer.start();
Then, I need afterwards to change the interval, so I try to stop the timer, remove the listener

Code:
gameTimer.stop();
gameTimer.removeEventListener(TimerEvent.TIMER, IALoop);
And when I init again the timer with the same code:

Code:
gameTimer=new Timer(interval,0);
gameTimer.addEventListener(TimerEvent.TIMER, IALoop);
gameTimer.start();

It's like if i had 2 timers, and when i stop the timer, it continues, I guess it's because of the new object that I create, but I can't found a method to change the interval of the existing timer..

View 2 Replies

ActionScript 1/2 :: Countdown Timer - The Seconds Seem To Skip And / Or Hesitate At Different Intervals

Feb 15, 2011

I notice on my 30 minute countdown timer that the seconds seem to skip and/or hesitate at different intervals. It seems to run for the full 30 minutes but it will be shown on a HUGE screen and the seconds movements is very obvious. how to fix the code for complete accuracy in the timing? Not sure if I should add milliseconds. ( I dont want that to show in the timer though, just minutes and seconds 00:00. Here's the code

[Code]....

View 5 Replies

ActionScript 3.0 :: Enter_Frame And Timer?

Mar 7, 2010

I was wondering, why does weak references does not work fro Enter_Frame and Timer? I mean, when I add any event listener on an object for those events I must remove them later, that is annoying! I use this:

timer.addEventListener(TimerEvent.TIMER, myevent, false, 0, true);or sprite.addEventListener(Event.ENTER_FRAME, myevent, false, 0, true);

When I lose reference to objects with these events (removeChild or null it) the event continues to happen and the 'myevent' func continues to be called :/Am I doing something wrong? What would be a good solution for this?

View 6 Replies

ActionScript 3.0 :: AddChild With Timer Or ENTER_FRAME

Jun 23, 2010

I have been trying to add a child (ball) randomly on stage with a timer every certain time or with ENTER_FRAME, but I can't get it to work. In both cases it just add the first one and then stops, even though the timer keeps on working!

[Code]...

View 11 Replies

ActionScript 3.0 :: AddChild With Timer Or ENTER_FRAME?

Jun 23, 2010

I have been trying to add a child (ball) randomly on stage with a timer every certain time or with ENTER_FRAME, but I can't get it to work. In both cases it just add the first one and then stops, even though the timer keeps on working!

Here is the code:
//Classes
import com.greensock.*;

[code]......

View 3 Replies

Actionscript 3 :: Using Enter_Frame As A Timer Flash

Jan 15, 2010

I am trying to save memory and space. So instead of using the Timer for my application, I was thinking about using my main loop (ENTER_FRAME) to keep track of time that passes. Is there anything wrong about this ??

View 1 Replies

ActionScript 3.0 :: Use Enter_frame Correctly With A Timer?

Jul 20, 2009

it has a countdown timer. When this timer gets to 0, I want the game to go and play the next level. This is the code.

ActionScript Code:
stage.addEventListener(Event.ENTER_FRAME, countDown);
function countDown(e:Event){

[code].....

View 9 Replies

ActionScript 3.0 :: Animation: Timer Versus ENTER_FRAME Event?

Jul 10, 2011

I use 2 options when i comes to animationg objects with Action Script

1. Timer based animation

PHP Code:

initTimer = new Timer(1000/fps);
initTimer.addEventListener(TimerEvent.TIMER, moveItem);

[code]....

2. ENTER_FRAME event based animation

PHP Code:

var time:int = getTimer();
addEventListener(Event.ENTER_FRAME, moveItem);
function moveItem(event:Event){

[code]....

Both of this options work ideal for my needs and they produce smooth animation. My question is witch one is better and why? And is there more ways to animate objects with action script?

View 9 Replies

ActionScript 2.0 :: Panning Content From Left To Right (with Stop As Intervals) Then Right To Left (also With Intervals)?

Nov 30, 2006

panning my content from left to right (with stop as intervals) then right to left (also with intervals)

1. I created an mc (name: "content")Notice in this mc, I layout 4 sets of text (like a page) from left to right

2. I created another mc (name: "pancontent_mc")

-I added a layer for "content" and created a motion tween for it to pan from left to right

-I created a mask layer on top of "content" that will show 1 set at a time

-I created an action layer that has total of 4 stops(); on each frame where the 4 sets of text will show directly under the mask.

3. maintimeline -There's only 1 layer. I placed an instance of buttons (left/right) and an instance of "pancontent_mc"

4. actions for right button, works fine and stops on each set of text.

on (release) {
this.pancontent.play();
}

5. actions for left button - none. I havent figured this out yet.

on (release) {
this.pancontent. - something like play previous frame until stop...
}

View 3 Replies

ActionScript 3.0 :: Font Size And Text Field Width Correlation?

Mar 28, 2012

Is there a way to determine what the width of a Text Field should be if the string length and the font size are known. I realize that every font have different letter size but don`t know how to get to that value

View 3 Replies

Actionscript 3 :: ENTER_FRAME Event Over ENTER_FRAME Event?

Oct 29, 2009

Lets say we have a movieclip "Enemy" in the Flash library and a class "Enemy.as" is associated with it which listens to ENTER_FRAME event as follows,

public function Enemy():void
{
//constructor of this "Enemy.as" class

[code]....

View 1 Replies

Xml Thumbnails With Intervals?

Jun 18, 2009

I'm having some issues with a thumbnails scroll that I found in another forum. I was able to modify it to fit my needs, but now I want to incorporate a interval that plays my next image without having to click on the buttons. I have tried several methods but nothing seems to work. here is the code:
 
descriptions=true;
alert._visible=false;
var ease = 5;

[Code].....

View 4 Replies

MX04 Basic Countup With Intervals?

May 1, 2009

basically what im trying to do is have a basic countup timer that goes in intervals of three. (3,6,9,12,15,ETC.) but it has to run with a 12 fps and not stop. also this cannot be 1000 frames long .

View 12 Replies

ActionScript 2.0 :: Calling Multiple Set Intervals?

Nov 26, 2009

I am working on a project and it is almost there basicly its a cracker that opens after a set interval of 1500,

I then want it wait for 20 seconds and open again and in a loop every 20

I have tried clearInterval but doesn't work for me

heres my code & fla attached

Code:
//IMPORT TWEEN ENGINE START
import mx.transitions.Tween;
import mx.transitions.easing.*;
//IMPORT TWEEN ENGINE END

[Code]....

View 0 Replies

ActionScript 2.0 :: Multiple Intervals For One Function?

Jan 18, 2011

I've got one function that I'm running, but I need it to run at different times for different movie clips.Here's my code. What is wrong with this?

ActionScript Code:
function tweenText(_TEXT:MovieClip, _START:Number, _END:Number, _SEC:Number, _INTERVAL:Number) {
var xTween:Tween = new Tween(_TEXT, "_x", Strong.easeOut, _START, _END, _SEC, true);
clearInterval(_INTERVAL);

[code]....

View 2 Replies

ActionScript 2.0 :: Way To Clear All Intervals In Movie With One Command

Nov 11, 2002

i 'd like to know if there is a way to clear all Intervals in a movie with one command.in my current project I use setInterval()very often in different clips and though i cleanly put the corresponding clearInterval() commands in the script I realized, that on slow computers some of them don't get stopped.Which puts more weight on the CPU and sometimes slows down the comp very much.

View 9 Replies

Get Flash Product Counter To Count In Different Intervals?

Jan 25, 2011

I am working on a project that need to countdown what is in stock.

Right Now I have the banner counting down but how do I get it to count in different intervals?

Right now I have an interval setIt = setInterval(this, "counter", 8000);

But I want it to go form 8 sec. to 1 sec. to 8 sec.

View 3 Replies

ActionScript 3.0 :: Make An Object Vibrate At Specified Intervals?

Jul 11, 2011

I just started learning Flash as part of a project, consisting of a spider-like figure which is supposed to vibrate every 20 seconds. I've basically got the vibrating to work but am having more trouble learning about getting it to vibrate at different intervals. I was hoping that someone here could point me in the right direction as to where to find this information, even an applicable tutorial or something.

View 6 Replies

Flash :: Start Or Seek To Sub-second Intervals With NetStream?

Jan 20, 2010

I am working on a Flash Video player and am implementing the ability to start a video at x time within the span of an FLV (served from FMS). I am able to start it x seconds into a stream without any issue using

netStream.play(source, startTime);

but as far as I can tell, it only supports seconds. I am looking to be able to give a start time (or even a seek time if that is supported) in milliseconds, or really anything more precise than whole seconds.

Anyone know of any way to achieve this even by monkey patching the fl classes?

View 1 Replies

Flex :: Different Or Variable Intervals On Chart Axis

Mar 23, 2011

I have a Flex chart and on the x-axis want to be able to have different intervals set so I can draw gridlines.For example the axis may be from 0 to 82 and I would want to have an interval at 6,8, 21, 29, 40, 49, 52, 59 and 70.

View 1 Replies

ActionScript 2.0 :: FMX04 - Loading New Movies At Set Intervals

Oct 21, 2006

I have three Flash movies (all the same pixel size) that I want to use on the home page of my website which is built in MX 2004.

How often the movie changes is not critical, but I think once an hour will be fine. What's the best way to get Flash to automatically change the movie every hour and where should I attach any code - to an Actions layer in movie no. 1?

As a summary, here's what I want to achieve;

12.00pm - movie no. 1 plays
1.00pm - movie no. 2 plays
2.00pm - movie no. 3 plays
3.00pm - movie no. 1 plays again

...and so on for 24 hours until you get back to 12.00pm when movie no. 1 plays again.

View 1 Replies

ActionScript 2.0 :: Dynamically Naming & Clearing Intervals?

Dec 19, 2006

I am trying to dynamicallly name intervals and clear them. Here's my code:

[AS]
_root.onMouseDown = function() {
setMyInterval();
};

[Code]....

View 1 Replies

ActionScript 2.0 :: Intervals Using Relative Object Positioning?

Feb 20, 2007

check this code out:

[Code]...

I was wondering, is there a way to change if (myClip_mc._x < 400) { to a relative position of myClip_mc. I mean, i want myClip_mc to move 100px from it's current position everytime the button is clicked. Instead of only moving it if it's x position is less than 400. So it needs to somehow check it's current position everytime the button is clicked and then make it shift from that position. I know this is a long winded way of doing it but i want it this way so i can use it for something different.

View 8 Replies

ActionScript 2.0 :: Garbage Cleanup - OnEnterFrame, Intervals, ?

May 23, 2007

A project I'm working on is working just fine at first, but as I perform more actions, it slows down noticeably. I've made sure to clear any onEnterFrame and setInterval events, so I don't think the problem lies there. Most likely, it's because practically every time an action occurs, much of the content on the screen is redrawn/recreated. However, every time I create a movie clip, text field, shapes, etc., I call a function to remove it beforehand:

Code:
function killThis(mc:MovieClip, thingsName:String):Void{
var obj:Object = mc[thingsName];
if (obj instanceof MovieClip){[code]..........

View 1 Replies

ActionScript 2.0 :: Multiple Intervals Being Created - Need One At A Time?

Aug 12, 2008

Its seems a problem I am having is to do with setIntervals in a while loop. I clear what seems to be the interval but as another interval is started before the last one finish I then have multiple intervals. I can close them all down with this...
for (i= checkImage;i>0;i--){
trace("clearInterval(checkImage) " +i);
clearInterval(i);}
But that ofcourse closes the rest down before they have done what I need.

I think my while loop needs to change? Here is the current while loop code....
function loadImages(){
while (imageWidthList[leftPictureNumber+imagesDisplayed] > 0 and xPosition +(imageWidthList[leftPictureNumber+imagesDisplayed]+(borderThickness*3)) < 700) {
var img_mcl:MovieClipLoader = new MovieClipLoader();
linkLayer = this.createEmptyMovieClip("link"+(leftPictureNumbe r+imagesDisplayed), _root.getNextHighestDepth());
[Code] .....

Is there a way that straight after the setInterval and the loadClip the function watchMyImageLoad is run to completion before continuing in the while loop. What I have seen is that the while loop continues until the condition has been met and then all the intervals are run?

View 10 Replies

ActionScript 2.0 :: Intervals In Movie Clips Won't Stop After MC Is Removed

Sep 9, 2010

I have a barometer activity flash program. It's weather themed and at each stage of the barometer fill, a movie clip appears that has as-generated weather icons (i.e. rain, clouds) floating across the screen. The problem is once I click to the next level of the barometer, the weather icons keep flashing in the upper left corner. I tried putting clearInterval in various places but it didn't seem to do anything.

View 7 Replies

ActionScript 2.0 :: Tracking Intervals / Scripts In A Flash File

Feb 17, 2011

Is it possible to somehow tell what scripts/intervals/onEnterFrames are still running in a flash file while viewing the .swf? I seem to be having some possible RAM issues with the .swf and just curious if there is a way to track this.

View 9 Replies

ActionScript 2.0 :: Resize The Window In A Flash Movie At Different Intervals?

Sep 12, 2005

how would i resize the window in a flash movie at different intervals? example here:[URL] in that movie, the window box resizes at different set intervals.

View 4 Replies

ActionScript 3.0 :: Randomly Change Movie Clip Colors At Set Intervals?

Mar 8, 2010

I have this movie clip that's a solid color with 60% transparency. I have 24 copies of this, all with instance names of light_mc1, light_mc2 and so on. What I'm trying to do is have them transition their colors not only randomly and constantly, but in unison. The transition has to be smooth, it can't just instantly show red in one frame, then green in the next. I have to be able to see it smoothly change to green, or whichever color is randomly selected.

View 7 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved