ActionScript 3.0 :: Global Timer Control - Remove Instance Refs From Array?
Sep 15, 2008
I'm writing a video game and I have used timers all over the place to make everything go. Now I want to be able to pause the game, completely. Meaning, I need to stop and start all timer instances at once, or globally. So I created a Timer subclass called CustomTimer, put some statics in there, came up with the attached code. Now my problem is that I'm pretty sure I've created a memory leak, in that the instances array will just grow and wont allow or gc. So, my question is, is there an "onDestroy()" method or somesuch, that I can override, and use that moment to remove instance refs from the instances array? Or, is there a smarter way to do this? an application object with a pause method perhaps?
what I'm trying to do is Instance a rectangle and move it across the screen, and as it's moving, make more rectangles. For some reason though, it's only making one rectangle, and the timer is taking way more than what I thought would be 100 milliseconds. Any help would be appreciated. >
I am trying to set a timer when no activity removeMovie and attach screen saver. I am trying to use a global var so that I can reset the count. Here is my AS what can I do to reset my timer.
Does anyone know of a way to adjust the volume of all the sounds in a swf? I'm looking to build a volume controller that changes the audio level of the swf.
The project I'm working on has grown to include multiple swf files of different types. However, the client wants the sound of all swfs controlled from the main swf. After some Google searches I came across examples of local Shared Objects and have attempted to implement what I found. However, the satellite swf in my prototype only registers the data from the LSO as "null."
I think what I need to do is encapsulate the code that defines, writes and clears the LSO in a separate .as file, call it from the .as of my main file (which already has a Document Class defined), and define the satellite files as having the LSO's .as as a Document Class. Am I correct in this line of thought?Using this article as a reference, my SO class would look something like this:
ActionScript Code: class SO { private var shared:SharedObject;[code]........
I'm also thinking the satellite files will mostly be using the "returnString" function, since I don't want them to write to the LSO, just to reference it.
I have tried to locate any guidance how you would go about creating a small control panel that would allow a user to adjust the size of the text, its colour and say the background colour too using actionscript 3.I understand that text formatting can be done on dynamic textfields but can this be achieved on static textfields?I am currently putting together a number of modules each a swf that contains e-learning and to comply with DDA.
3 circles which can be dragged over a target (one for each circle)When the circle is placed on its target it loads its respective xml playlist into 4 buttons (play, pause, forward, back)I want to be able to create some kind of function to control the volume, either using a slider or a rotary dial, whichever is easiest!
Is it possible to attach a timer to control a slider? Or alt remove the slider_mc and replace with a timer so that an image desaturated gradually after 60 seconds? Here is the file I am looking at [URL].
I want to add a child to the stage for 5 seconds and then remove it. When I use the following code I get a "1120: Access of undefined property WordoScreen." error.
In particular the problem only occurs when I use the "removeChild(WordonScreen);" using the TIMER_COMPLETE. If I remove that statement I don't have a problem.[code]...
I have a main swf that loads swf with photo gallery. Photos change with timer. But when i remove child with gallery in main swf timer still works and loads photos. I can see that in my trace window and in bandwidth profile while testing swf. Is there any special reason why removing child does not kill/stop timer and do i have to stop it from my main swf or is there any workarounds?
edit: I just read this article: [URL]
So i have to remove listener in my main application in order to stop timer?
i want to do is to remove all the children (ninge) added with Timer when the user rolls out the mouse. The ideea is when the user moves his mouse over the movieclip it begins to snow and when it moves away i want all the snow to disappear.
ActionScript Code: rama2_mc.addEventListener(MouseEvent.MOUSE_OVER, rama2); function rama2(event:MouseEvent):void {
I got some problems with removing a child from stage. The timer is still active I try to get rid of it with a killMe function. Called by REMOVED_FROM_STAGE event. But it doesn't work.
just cause i'm trying to optimize my project to the fullest (concerned about garbage collection and all that...), i want to know something about timers...is the killTimer function enough? or do i also have to remove the listeners?
I am adding a Timer object when my flv playback enters a Pause state and removing that Timer Object when playback starts again. I noticed that if I pause the movie and then drag the slider on the timeline the movie enters the Pause State again which adds another Timer Object....
How do I check to see if the Timer has already been added and if so remove it and add a new one.
See code below:
my_player.addEventListener(VideoEvent.PAUSED_STATE_ENTERED, pausePlay); my_player.addEventListener(VideoEvent.PLAYING_STATE_ENTERED, startPlay); function pausePlay(e:VideoEvent):void {
I having a little trouble with the countdown tutorial here. I want to remove the milliseconds and have the timer based on seconds instead. How do I do that? I'm using Flash 8 if that means anything.
I want to make simple motion tween of analog timer seconds arrow. Can i sync it with specified defined timer on AS3?I know that the regular speed of animation can variate according to system specs.
I am trying out the inactivity timer technique and I am still trying to get it to work. This what I have so far [URl]As you can see I have it so when the mouse isnt moving the control bar goes down and vice versa. But when I move the mouse the control bar replays the up motion.
Code: Select all//call tween import caurina.transitions.Tweener; const BUFFER_TIME:Number = 8; /* stores the time to buffer for the video in seconds. */
I am working on a card game.When the game initializes, 2 cards get dealt to the dealer and 2 to the player. Each card MC is created dynamically. When you hit the deal button, the cards are dealt, but all appear at the same time. So i figured i would try using the Timer class in order to delay each card so they are dealt one-at-a-time. Seemed easy enough, but evidently i am missing something obvious and probably embarrassing. The short, simple code, which i expected to be a no-brainer, doesn't seem to want to work. My ignorance with the Timer class isn't helping where i am going wrong or if i am way out in left field? I created a Timer that repeats 4 times(repeatCount). I was thinking that i could target e.repeatCount with a case statement and fire off each card. I can't seem to get it working though.
Code: Select allimport flash.events.TimerEvent; import flash.utils.Timer; var dealTimer:Timer = new Timer(200, 4);
I searched the whole internet and I could not find a solution for this.I'm trying to load XML, parse values into global array, and use that global array later in my code... this is not working.
_global.autoid=Array(); function ParsingXML(){ var pokXML:XML = new XML();
I'm new in flash scripting and this is driving me crazy I searched the whole internet and I could not find a solution for this. I'm trying to load XML, parse values into global array, and use that global array later in my code... this is not working.
I am curious if this is an okay implementation of the Array.filter() method.
[Code]...
I was not able to figure out an implementation of the callback function for the filter() method, where the callback was outside of the getGallery() function. I wonder if there is a way to get the isGallery function outside of the getGallery scope?
I have a timer to try and have my main timeline frame change every X amount of time. I just would like to cycle the frames as if they were an image slideshow or something. It works almost works by this I mean It will cycle frames 1-4 but then it wont go back to 1 with this code. It will go to frame 2 after frame 4 then the timing and randomness get even worse.[code]
I have a news rotator that is populated from an RSS feed. The rotator has a timer that cycles through the news items, displaying a link and image and title for each item. I have the put in three buttons for the user to control the item that is displaying. A pause, forward and backward button.
My issue is that I'm not sure how to implement the button without messing up my timer that is already running. I was able to do the Pause button, which was simply to stop the timer. The forward and backward buttons are a bit more tricky. This is what I have so far. Note that I have much of the code duplicated because I needed to initialize the objects for the first timer index. After the first item, the code runs from the timerHandler() function.
PHP Code: var xmlLoader:URLLoader = new URLLoader(); var xmlData:XML = new XML(); import fl.transitions.Tween; import fl.transitions.easing.*; import fl.transitions.TweenEvent; [Code] .....