ActionScript 3.0 :: Adding Time Delay Without Timers?
Jun 18, 2010
I've been having some trouble with this line of code. This is being used in an .as class file for my Ball class. I can get it to move within the main .fla by using a timers but if possible I would rather avoid the timer. I'm trying to develop a system for my FLA like this:
Ball starts at x,y
Ball moves to waypoint x,y
Ball leaves stationary copies of itself along the way forming a line as it goes.
The file will do this several times so I am trying to base this on if/else rules rather than animate it out. I feel like I should contain all movement activity within the class file and leave the waypoint rules for the main .fla. My current issue is that the code below (without the hittest) works if the FLA has a timer triggering the moveTowards function. Without the timer in the fla, it still works but the ball just warps to the destination.So I have two questions:
Is there a way to control the while loop so that it pauses at the end of each loop enough to look like the ball is moving incrementally?Is there a way for me to have a drawball function within the ball class itself or should I make a new package/class within the class file? Ideally I would have the new ball creation be relative to the "step" variable.
Code:
public function moveTowards(pX:Number, pY:Number, step:Number)
{
var dir:Number = Math.atan2(pY - y,pX - x); //find angle direction[code]...........
View 13 Replies
Similar Posts:
Mar 30, 2009
Is there actionscrip to add a delay to something....
e.g 1.
I click on a button, i want MovieClip1 to move to the right, then i want a 3 second gap and then i want MovieClip2 to move downwards....
View 2 Replies
Jan 31, 2007
my code the problem with this code is that I can't change the delay once its loaded.
Is there a way to change the delay after firing runMany() ?
Code:
var intID:Number = setInterval(runMany, 1000, 1); // 1 second
function runMany():Void {
trace("runMany() called @ " + getTimer() + " ms");
clearInterval(intID);
}
View 5 Replies
Aug 30, 2011
I have this random movie player with 6 buttons that play the individual movies. The random movies have a title and a countdown timer that is working.I cannot make the timer work on the individual buttons.
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.text.TextField;[code]....
View 6 Replies
Feb 2, 2012
var LevelCode:Array = [10,20,30,40,50,60,70,80,...,990,1000];
var Piece0:Timer = new Timer(50, LevelCode[0]);
var Piece1:Timer = new Timer(50, LevelCode[1]);
...
var Piece98:Timer = new Timer(50, LevelCode[98]);
var Piece99:Timer = new Timer(50, LevelCode[99]);
I want to start Piece0 timer, Piece1 timer, etc., at the same time. I tried Piece0+Piece1.start();, but it did not work.
View 3 Replies
Jun 18, 2009
I have a timer with a default value of 10 minutes. If the user selects some radio buttons, time should be able to change accordingly.
Problem is I don't know if it's possible to alter a timer once created. Using a switch/case I declared[code]...
View 6 Replies
Feb 23, 2012
I wonder if you can get the number of milliseconds that have elapsed since an actionscript timer has started.I want to set a simple label in flex that has the value of how long it wil take before the timer fires (again).this is the code, at 'GET ELAPSED TIME', I need the time that the timer has been running (since it last fired the function):
var timer = new Timer (10000);
timer.addEventListener(TimerEvent.TIMER, foo);
timer.start();
[code]....
View 1 Replies
Apr 28, 2006
I have an app in which there are 2 identical units that have a timer that displays elapsed time. I'm using a single file for these units since they are identical. When a user turns one of the units on, its timer is supposed to start and when they turn it off, it should then stop. The problem I'm having is this:
If I go to one unit and turn it on, and, after 2-3 minutes, turn it off, then go to the 2nd unit, instead of displaying 0:00, it displays the 2:00+ that was on the first unit. If I go back to the first unit and turn it back on, instead of starting at the 2:00+ mark, it starts up at 3:00 or later. I'm not very familiar with the way getTimer works, but I had figured that could be set to start whenever I wanted.
If the user then selects a new module, instead of restarting at 0:00, it starts off at around 5:00 or so. It appears to be giving the time from when I started the Flash piece instead of since the beginning of the module like I thought it would. How should I code these timers so that they can start when the user selects a module and so that they can be distinct values?
View 1 Replies
Dec 13, 2010
In a game I'm making the timers that I use go one speed when I run it by pushing Ctrl-Enter in Flash but when I run the external .swf file created, the timers go considerably slower.I have managed to work around this by making the timers reset at lower intervals but I would rather not have to resort to this.
View 1 Replies
Aug 9, 2009
I need to have a delay between two transitions that I'm running. How do I do this with my code?
import fl.transitions.*;
import fl.transitions.easing.*;
var bb_mc:bb = new bb();addChild(bb_mc);
var header_mc:header = new header();
this.parent.addChild(header_mc);
[Code] .....
View 4 Replies
Jan 16, 2009
I have a simple button which would load an image in a Movieclip (MC1) using;
MC1.loadMovie('image');
And I also want it to go to a certain frame using;
gotoAndStop(frame#);
What I am looking for is that I wanna add a delay in the working of the button's next command i.e. gotoAndStop(frame#);.. Like a 3 second frame so the Image is 'fetched' in MC1 before the next frame is brought on screen..
View 5 Replies
Feb 28, 2004
How do I add delay in a timeline for the loadMovieNum to take place?
To be more specific, I have all my layers in Scene1 and the top most is the Actions layer. Somewhere around frame 75 of the timeline I inserted a keyframe in the Actions layer to loadMovieNum but it doesn't seem to load.
If I place that piece of code at the first frame if plays fine though. I don't want it to play immediately. As mentioned, I want the code to execute at frame 75 and load my MC onto the stage.
I bet its a very simple thing and there must be something I missed out. This is my first time working with Flash. Btw, i'm using MX 2004 if that helps.
View 3 Replies
Nov 19, 2009
how to add a delay to the attack button of the character. Right now you are able to leave the button pressed and the character stays on the attacking animation and you can simply do that to destroy everything, so at least having to press again to make the attack animation happen again would also be perfect.
View 3 Replies
Mar 3, 2010
I have some video which I have converted into .swfs I am trying to set delays to the three videos, so that the first swf plays on page load. The second loads after 30 seconds and the third after 45 seconds.
View 11 Replies
Sep 21, 2009
I have a movie which calls a external js on the last frame which closes the parent iframe in which the swf sits. However i want the user to stop at the last frame foe some seconds before if calls for the js to close the iframe.
View 3 Replies
Mar 30, 2009
Is there actionscrip to add a delay to something.
I click on a button, i want Movieclip1 to move to the right, then i want a 3 second gap and then i want Movieclip2 to move downwards.
View 1 Replies
Jul 1, 2009
So on frames 10, 20, and 30 on my timeline I have these llines of code on each of them respectively:[code] This essentially "bounces" on my images. Can someone give me direction on how to set up a delay to make this happen all on one frame?[code]
View 1 Replies
Jun 25, 2003
does anyone know of any actionscript i can use for a time delay. Say you have only 3 frames on a time line is there some way using actionscript that i can delay the playhead so for instance it stays on each frame for 20mins and once that time is up it moves on to the next frame and so on and so on.
View 9 Replies
Feb 8, 2009
I create 3 instances of the class below. I need to find a way to call them with a delay so they get added to the stage one after the other. Is there a class that lets me queue up functions? Or an economical way to do it with the functions built into flash.
View 2 Replies
Jul 30, 2010
when I add items nothing appears in the component but when I make a second adding cycle List shows the one I added previously...The code with which I add my elements is this.The studied method is updateStorages(), the rest is to understand how's the process cycle.All the trace you see in the code works with no problem.
ActionScript Code:
public function Scopa() //constructor
{
[...]
[code]...
View 0 Replies
Feb 9, 2012
this is a working singleton class for Tooltips. I want to add a timer in order to delay the tooltips since the way they're instantly popping up is bothering me.
This is the fla:
Code:
//Import and Initialise the ToolTip class
import ToolTip;
ToolTip.show();
[Code]....
View 2 Replies
Apr 23, 2010
I need to add in extra hours to the time, and the day will change automatically too. How should I change the code below?[code]
View 1 Replies
Sep 4, 2009
I have a rotating menu that when clicked rotates and loads in swf movies, OnClick.
The problem I seem to be having is that because the swf movies load in on click it seems to be causing the rotation of the menu not to run smooth.
Question: Is it possible to get the swf movies to load in once the action of the click has completed its action. some kind of 2 second delay before the movies load in??
what happens: you can click or mouse scroll through the menu, when you click, the action repositions the selected Item (ActiveItem) in the center and resizes larger. this works great, is it possible after this action is complete to then load in the swf movies?
to see how the movie runs at the moment this is the link: [URL]
you will see at the moment onClick the movies load straight away which makes the rotation not smooth when rotating around.
I can't seem to get the mouse scroll to work the same function as the click at the moment also.....thats for another day
View 11 Replies
Sep 7, 2009
Is there any way to change the delay time. i used a variable to set the delay time but it wont works for me. The delay time is Working as the previous value.Here is my code.
ActionScript Code:
var delay:Number = 1000
timfun()
[code]....
View 5 Replies
Dec 16, 2009
I have a short animation mcl that has an enter button (loader) on it. Once clicking the enter button, the main website content (another swf) loads. For some reason when users click the enter button, there is a 12+ second delay in loading the content swf
View 1 Replies
Jan 25, 2011
I need to know how we can create a menu with time delay. Mouse down, disappears after three seconds, move mouse the menu appears.
View 1 Replies
Apr 15, 2007
The code show's the movieclip "nav" when "bg_inv" is clicked, and fades it out when 5 seconds have passed. What I want to achieve is this:When I click a button inside "nav" called "next_btn" the delay needs to be reset, so that "nav" doesn't fade out until five seconds have passed since I clicked the button.
Code:
nav._visible = false;
import mx.transitions.Tween;
import mx.transitions.easing.*;
[code]....
View 1 Replies
Apr 15, 2010
I need to load 3 SWF's file after a certain period of time (loading first SWF, see 5 sec and loading next SWF, see this SWF 2 second and loading Final.swf and stop load)
View 3 Replies
Dec 15, 2011
I am attempting to add a movie clip to the stage when a button is triggered. When the user clicks the button the movie clip is added to the stage; it works fine, but the following problems occur:
1) The appearance of the movie clip is delayed.
2) The sound in the movie clip starts to play but the movie clip appears when the sound is finished.
Additional information: 1) The movie clip has the sound in the timeline.Here is the code:
Actionscript Code:
//Buttons: Adds movie clip to stage.readtomeShortA1.addEventListener(MouseEvent.CLICK, playShortAReadMe1);var playShortA1:ShortAReadMe1function..[code].....
2) However, I also want to know is keeping the sound in the timeline of the movieclip the most efficient way to use sound in the movieclip? Or is there better, more efficient way to do it?
View 3 Replies
Dec 18, 2008
When a page appears I want to delay the appearance of the button so users stop to see the animation i have put there but the help file just tells me how to create classes when I'm sure there must be a few lines of code to do it? can someone tell me what is wrong here as when I make the alpha of the button to 0 the whole page becomes 0 alpha and it wont do anything or give out any errors[code]...
View 1 Replies