var zipTimer:Timer = new Timer(1000, zipArray.length-1);
zipTimer.addEventListener(TimerEvent.TIMER, onTick);
zipTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
[code]....
Now, I can't see, for the life of me, why this isn't firing. It's almost exactly the code from Adobe's docs...zipArray.length is at least 32.
I have a little flash app that I have running constantly on my server (I made it an exe). It runs great for a few days, but then eventually it just stops.
Code: trace("test1"); var myTimer:Timer = new Timer(5000, 1); myTimer.addEventListener(TimerEvent.TIMER, getData,false,0,true);
[Code].....
The code above should call the function getData once after 5 seconds have passed. This works 99.99% of the time, but for some reason (usually after a few days of it running) it doesn't call the getData function.
I have verified this through trace statements. When it eventually fails, it traces out test1, test2..... then nothing else. No test3.
I'm assuming I need to add an event listener for the timer object to check if it fails for whatever reason. How do I do this?
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 am working on a very simple game in Flash. I want to make all the animations framerate agnostic, so that I can change the framerate without affecting the flow and speed of the game.I read somewhere that if you want to do that, you simply create a Timer object and attach an event listener to this timer.
What if I have many objects that have to listen to the same timer? See the code to understand what I am trying to do. At this stage nothing breaks, but the event does not fire.Here is the Main class, the one that runs on swf execution:
public class Main extends MovieClip { private static var _stage:Stage; private static var _timer:Timer;
What is the difference between Timer.stop() and Timer.reset() functions because it seems that the 2 functions do the same thing? I image Timer.stop() to stop the timer and when Timer.start() is called the timer starts from where it stopped. For example, if I have a 3 sec. timer (3000 ms). If I stop the timer after 2.5 sec. and start the timer again, I would expect the timer to expire/trip within .5 sec.
I have a ActionScript 3.0 project and I have a timer that is running on 1000 millisecond intervals. I would like to delay this timer for 1500 milliseconds perform an action and start the timer again after the delay. I thought I could do this easily, but I'm having trouble, would it be better to stop the timer and perform the action and then listen for the action to be completed to start the timer again?
In my case, the timer I make doesn't reduce its time whenever a function is called. What code will I change or add in order to reduce the time in my timer? [code]At this point the timer.start(); is placed on a frame so that the timer starts as it enters the frame.
I'm working on a scene where the user can drag sugar, honey and syrup flavour to a cup of coffee and each time they collide, the coffee's happiness is increased by 1. I added a TweenLite so that sending any of the objects to their original positions is much more fluid. The problem is that the hitTestObject is now firing more than once (which makes sense and now happiness is increasing at more than one increment at a time) but how can I make it so happiness is increased just once?
Code: public function hitsDecaf(e:Event):void{ if (myCounter.myHoney.hitTestObject(myCounter.decafSweetened)){ ifStartTimer = true; stopDrag(); myCounter.steamHappy.gotoAndPlay(2); [Code] .....
I have the following:A document class, extending from a custom class, extending from MovieClip. In my document class, I assign a handler to the FullScreenEvent like so:
Also, I've set up a SimpleButton to call that same function, toggle_fullscreen, when clicked.Here's the catch:When I click the button, my app goes fullscreen. When I press Esc, the app goes back to normal but the FullScreenEvent doesn't get fired,so I can't catch it to re-align the elements on my stage.I've also tried to add the event listener to the stage object of my document class, but that doesn't work either.
The problem is that I've done a lot of work in my game, and there's too much code bound to shift and control keys. For example you need to hold shift key to select multiple soldiers or control key to shoot or sometimes pause the game or even call a map, a lot of stuff in GUI depends on those keys as well. Both KEY_UP and KEY_DOWN are added to the stage object. But, time after time, there happens a very annoying thing, KEY_UP event just doesn't fire for shift or control (in most cases it does, but not always). That is, I press shift, start selecting soldiers, then release shift but Flash Player keeps thinking it's still pressed, so I can still select multiple soldiers, which is not good.
I have some code where an event handler listening to Event.ID3 fires twice for an MP3 file. From searching the web, I found a few others asking a similar question, but I haven't seen any response.
Does anybody know what would cause the ID3 Event to fire twice for a single file? My only guess is that the MP3 file contains two versions of ID3 format.
I am using a big file so I know its taking several seconds between calling URLLoader.load and complete. There just doesn't seem to be a report in between 0-100..
I keep running into problems where I want to add an event listener onto a class instance RIGHT after it's instantiated, like this: Code: storiesXML = new XML(XMLdata); storyBook = new vStories(XML(storiesXML.stories)); storyBook.addEventListener("storyBookLoaded", storyBookLoaded); . . .
But by the time we arrive at the third line, the "storyBookLoaded" event has very often (inconsistent) already been dispatched from my class instance: Code: var evt:Event = new Event("storyBookLoaded", true, false); dispatchEvent( evt ); ...
(Even though quite a lot has happened in the class before that.) To be clear, I don't want to add storyBook as a display child, and even if I did, the addChild() method would have to be called after instantiation of storyBook, so we'd have the same problem. I know I could set a timer in the vStories class to artificially delay the dispatching of the event, but that seems really hack-ish, and would have a real compounding problem if I have to do it too often as everything builds up. How to make sure custom communication events happen after their listeners are set?
I'm sure some users on this forum will be aware that AddThis are dropping the Clearspring Launchpad, so I'm writing a new API to get ready for the changeover. Part of that is a base UI that will create buttons for social network sharing destinations. At the moment, AddThis contain all the icons in a single long strip that is 16x3520 pixels in size [URL]...
What I'm trying to do is load this into a utility class, but the Event.COMPLETE event never fires, and if the Loader class that loads it is added to the stage, the bitmap is never shown. I thought it was maybe a dimensions issue, but what is curious is that if I place the PNG on a Flash stage and export as a SWF, it loads no problem. If I dump it out as a JPEG, no problem. Its ONLY when the file is a PNG that there are problems trying to load it. I even tried dropping it out as a 24-bit PNG (the original is 8) but that had no effect.
I am simply trying to link a button on my site to another webpage (an online store). The site is currently live at Higdon Florist (won't let me put the dot com address due to forum rules) The last 2 menu options (View Bouquets and Place Order) should link to (store dot higdon florist)
On PC, this works just fine every time.
However, I have reports that Mac users have trouble. The action never fires on the first 4 or 5 tries. Then, suddenly, it begins to work (and continues to work thereafter).
In my Flash project I have a movieclip that has 2 keyframes. Both frames contain 1 movieclip each.
frame 1 - Landing frame 2 - Game
The flow of the application is simple:
User arrives on landing page (frame 1) User clicks "start game" button User is brought to the game page (frame 2) When the game is over, the user can press a "play again" button which brings them back to step 1
Both Landing and Game movieclips are linked to separate classes that define event listeners. The problem is that when I end up back at step 1 after playing the game, the Game event listeners fire twice for their respective event. And if I go through the process a third time, the event listeners fire three times for every event. This keeps happening, so if I loop through the application flow 7 times, the event listeners fire seven times. I don't understand why this is happening because on frame 1, the Game movieclip (and I would assume its related class instance) does not exist - but I'm clearly missing something here.
I've run into this problem in other projects too, and tried fixing it by first checking if the event listeners existed and only defining them if they didn't, but I ended up with unexpected results that didn't really solve the problem.
I'm new to ActionScript development and am using the FlashDevelop IDE. I've been playing around with some really simplistic things and have come across a problem I can't seem to solve.My application compiles and runs, and a function that watches click events fires perfectly and I can see the event in the console when I pass it to trace(), yet the same code watching for KeyboardEvent fails to fire at all.Here's my code:
I'm writing a SWF that I'd like to communicate with a Java process via Sockets. This is usually quite easy with standard Sockets, but for some reason the events described in the Socket documentation aren't firing when all signs say they should be.
On the Java side, I've set up a ServerSocket that's listening on port 8080. Using netcat I've confirmed it works as designed.[code]...
When I run the resulting SWF, all I get is "Called connect!" on the stage, and none of the events ever fire. Even more strangely, when I investigate the communication from the ServerSocket on the Java end, it receives and accepts a connection. When I close the SWF the code calling my Server completes as normal -- meaning it was hanging on a connection made with my SWF.
I'm left with a few questions...
With the exception of the event handlers, this is the end of control for my code (after the connection is established, we just wait for events and render them appropriately). Could the entire program be "terminating," and I'm just misunderstood about the Runtime model?Are there visibilty/naming requirements for the callbacks for them to be called? They're all public, but could it be that the Runtime isn't seeing them?Are there any gotchas with AS3 Socket programming? I kept thinking this was an issue of sandboxing, etc., but the SECURITY_ERROR didn't fire either.
I have a bit of a quandary. I need to call a function inside a MovieClip once a particular sound has finished playing. The sound is played via a sound channel in an external class which I have imported. Playback is working perfectly.Here is the relevent code from my external class, Sonus.
public var SFXPRChannel:SoundChannel = new SoundChannel; var SFXPRfishbeg:Sound = new sfxpr_fishbeg(); var SFXPRfishmid:Sound = new sfxpr_fishmid();[code].... osr.Sonus.PlayPrompt(...) and gui.Wait(...)
both work perfectly, as I use them in other contexts in this part of the project without error.Basically, after the sound finishes playing, I need Wait(false); to be called, but the event listener does not appear to be "hearing" the SOUND_COMPLETE event. Did I make a mistake somewhere? For the record, due to my project structure, I cannot call the appropriate Wait(...) function from within Sonus.
I was wondering for personal use how you would go about writing a function on a button that when the mouse click is down it would keep firing the function kinda like it does when using the onEnterFrame on key frame..
I've got a class which attempts to call a method upon Event.ADDED_TO_STAGE firing. Instances of this class are obviously added to my stage (I can see them) yet my onAddedToStage method never gets called.
HTML Code: package { import flash.display.MovieClip; import flash.events.Event;
I'm dynamically creating instances of a loader in a loop, adding a complete listener to it, and loading it. For some reason the complete function is not called. Is this syntax wrong?
I have set up the tab order of my movie clips and i can tab through them fine. When i get to a movieclip that has a mouse event to fire off a link it does not fire when i hit the enter key. I know in As2 you didn't have to do anything the enter key just worked. Does any one know how to resolve this?
Or at least that's the impression I'm getting. Locally in Flash, it all seems to work fine. When I open it in Safari or Firefox, it messes up some of my functions, and I THINK it's because the onChange function fires twice. Just can't figure it out.[code]Then changePage2() comes into play, but the problem is before this apparently.when I go to the URL directly, or when hitting the back button. It goes wrong when the change is triggered inside the movie.
I'm working on a little game, and everything is working great. Except for if you push a button, then drag, the button stays stuck. I found this is because the TOUCH_MOVE event fires then the TOUCH_END event doesn't. I've got some very simple code here, how can I fix this? Is there a function to tell if you are currently touching the button?
When I run this code, I get to click on either the container "Big Box" or its contents "Poly". The associated trace states should fire but look at the tracer on "Poly" it fires twice. Why? [code]
im just testing some stuff, and everytime the space key is pressed i want one bullet to come out, however righty now you can just hold down space and it keeps firing...heres the code i used [code]