Actionscript 3 :: GetTimer Results Between MOUSE_MOVE Events
Jun 27, 2010
I'm programatically dragging the play head back and forth along a timeline based on a mouse event listener. The faster the mouse drags the faster the playhead rips through the frames (it's linearly proportional). I'm also firing a starter=getTimer(); event at the inital mouse_move Event trigger (and only on the initial event) and then firing a ender=getTimer() at the end of the code that calculates the new playhead position, but only if the calculation has resulted in the playhead being told to move at least one frame (the mouse can move a few pixels before playhead will move one frame). In essence it's giving me a frame per second rate.
If I look a the delta of the two timers I rarely get anything but 0. Occasionally I'll get a 1 but not very often. There are a good few dozen heavy lines of code that need to be worked out between the initial mouse_move and the decision to move the play head, and this has to be done for a number of mouse position changes before the playhead will move at all and the second getTimer call is triggered. Does the mouseEvent trigger every ms or does it trigger at the frame rate (enterframe rate) of the doc. If so the smallest delta I should see is 31ms.
This runs as an app in the standalone swf player (10.1) and never in a browser.
Are my results indicative of this? Can the compiler really run this fast? How does one do very small timing tests that appear to be beyond the millisecond clock granularity?
View 1 Replies
Similar Posts:
Jun 10, 2009
I'm getting a flickering issue with my tool tip hovers. I've tried writing the code in 2 different ways and I'm still getting the same thingEach way seems to work fine if there's only one object, but when there are more than one and you start moving the mouse between the 2 this really annoying flickering keeps occurring? My file needs to have several objects which all overlap. I've tried altering the hit areas so that they don't actually touch - but no effect.
I've also tried swapping ROLL_OVER for MOUSE_OVER and MOUSE_MOVE but all with no results.
View 3 Replies
Oct 3, 2009
I have a module, which is a simple swf file to load.
Inside there, in a modules document class I have a code like:
ActionScript Code:
buttonMode = true;
useHandCursor = true;
[Code]....
When I load the module, I can see the drawn background with proper sizes. However, the cursor is not hand (useHandCursor) and mouse events are not dispatched. They are only dispatched on some children of the document class, not on itself, on its own background. ANd the hand cursor is only over the children, not over the document class' background itself again.
The document class of the module extends Sprite.
View 9 Replies
Mar 8, 2012
I'm listening for MOUSE_MOVE events.They are sent and received just fine unless the middle mouse button is held down. I don't get any more MOUSE_MOVE events until the middle button is released.Is this an issue with Flash, or something to do with my specific ouse/computer configuration (bluetooth Mighty Mouse on Lion)?Are there any known workarounds?Here is a sample project to demonstrate the problem.Left click and drag traces mouse move events, but middle click only shows middle mouse down and middle mouse up.
import flash.events.MouseEvent;
this.stage.addEventListener(MouseEvent.MIDDLE_MOUSE_DOWN, onMiddleMouseDown);
this.stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
[code]....
View 2 Replies
Oct 25, 2009
I'm making a racing game and am trying to have the final time displayed after I cross the finish line...In frame 4 (where the game begins) i have a setInterval timer that counts down from 20.when it reaches 0, my text is: startTime; where var startTime:Number = (getTimer()/1000).In frame 12 (where the game ends) i have
finalTime.text = endtime
// finalTime is a textbox
var endtime:Number = (_root.finishTime-_root.startTime);[code]...
when i finish the race, however, the word "undefined" is displayed in the textbox.
View 2 Replies
Jun 25, 2009
I am in the process of writing a scrolling image viewer that dynamically updates from an xml file. I have written the scroll function (with a lot of help from Kirupa and other sources), and the pictures are updating beautifully, but when it comes to adding the function for the buttons I am encountering an unusual error.
Using the following code:
Code:
initButtons=function(){
for (var i in btnArray) {
var btn:MovieClip = btnArray[i];
[code]....
from this site results in the doClick function being called for each of the buttons in the btn array at runtime, and then not working afterwards.
View 4 Replies
May 19, 2009
I have been using hitTestPoint so far with mouse_move listener, which means if the mouse was stationary over target area when that listener was added the desired action wont happen until mouse moves.
Basically I have this window in the middle of the stage where loader loads pictures and when picture loads if the mouse moves over that window some other stuff appears.The listener is added after each picture is added and if the mouse was stationary above the loader when that happened it doesnt trigger hitTestPoint (until mouse moves).
I have seen somewhere this same effect, but it worked even if the mouse was stationary above the image when image appeared.
[Code]...
View 2 Replies
Nov 5, 2010
I've got a png sequence of a 3d object rotating on my timeline. My as3 find the mouse.x and uses math to choose which frame in the sequence to move to. I need to be add easing to the movement.
AS3 in use:
stage.addEventListener(MouseEvent.MOUSE_MOVE,findF rame);
function findFrame(event:Event):void{
var frame:int = Math.floor((stage.mouseX/stage.stageWidth) * 31);
gotoAndStop(frame);
}
View 1 Replies
Feb 7, 2010
I need to dispatch an event object when user stops moving mouse cursor. In poor words, i need the exatly opposite of a Mouse_Move event. Is there any solution or I need to create a event with EventDispatcher class?
View 5 Replies
May 26, 2010
i'm attempting to implement a mouse event where Mouse_Move can only occur if Mouse_Down. i could introduce a boolean that would toggle during Mouse_Down and Mouse_Up that could work, but is there a better way, perhaps a more official way, of doing this?
View 1 Replies
Mar 24, 2011
I have a disc I am rotating with the mouse with event.MOUSE_MOVE, like a jog wheel on some audio equipment. Everything almost works as expected, but the problem I am experiencing is that the disc always jumps to the point where the user clicks on the disc. I need the point on the disc that the user clicks on to remain under the mouse while the user spins the disc but I can't seem to come up with the correct math to make it happen. Here's the code i am using:
var xd = (_knob.x - _stageRef.stage.mouseX);
var yd = (_knob.y - _stageRef.stage.mouseY);
var radAngle = Math.atan2(yd, xd);
_knob.rotation = int(radAngle * 360/(Math.PI * 2) - 90);
_knob is a vector circle wrapped in a movieclip, with the circle centered on the movieclip's reg point. _stageRef represents the main stage.
View 1 Replies
Sep 15, 2011
why it scrolls down fine but when it scrolls up the first line of text falls to the middle of the pageContainer?the height of the pageContainer is 440 pixels.I cant get it to stop at the top of the pageContainer.It just keeps going up (into blank space)and the text keeps moving. Heres the code:
pageContainer.addEventListener(MouseEvent.MOUSE_MO VE, scrollPage);
function scrollPage(event:MouseEvent):void
{
TweenLite.to(pageContainer, 0.5, { y:-(mouseY/440)*pageContainer.height+stage.stageHeight/2});
}
View 2 Replies
Nov 6, 2009
I create an application that will work when users move the mouse and concurrently press the Ctrl key. But, it does not work if I did not first click on screen (application run on browser).
[Code]...
View 6 Replies
May 21, 2010
My code seems to be hearing a MOUSE_MOVE event when you click outside of the Flash stage (anywhere else on the page).
I have one listener for MOUSE_LEAVE (stage), which hides some overlay controls after a 500ms interval, and another (MOUSE_MOVE) to show them again when you move back over the stage. Yet the controls show again when I click anywhere outside of the stage.
I suppose I could add a Boolean for whether the mouse is over or outside of the stage (since I'm tracking that anyway), and *not* show the controls if its outside, but is there something else I'm overlooking?
View 3 Replies
Jun 23, 2011
what is meant by EnterFrame and it's use and how to declare it? And also the difference between EnterFrame and MOUSE_MOVE?
View 2 Replies
Nov 28, 2005
How do I reset a getTimer();? My script for my "game" doesn't work, here's the code:
Code:
on(press){
poang += 1;
_root.minpoang=poang;
this.gotoAndPlay(2);
[code]....
As you can see, I have tried to reset time to 0 again, but that doesn't work..[URL]
View 4 Replies
Jun 4, 2002
I have an empty movie clip that tells another movie clip on the stage to move based on a variable that's based on the getTimer results something like:
onClipEvent (enterFrame) {
targetx = 0;
_root.slide.gotoAndPlay("move");
[Code].....
Now, what I want to do is to reset the value of getTimer so my movie will loop,
View 5 Replies
Oct 21, 2010
Trying to use the MouseEvent.Mouse_Move event. Simply, there's one 300 x 20 line which the event is assigned and another line (100x20) is top of the first line. But if mouse moves over the second line, the event is not working... The same event could be assigned on the second line but it seems a bit waste and I'm sure there must be a way to trigger the event through the other object.
View 2 Replies
Aug 29, 2011
I would like to know how fast, flash player processes the Mouse movement? Does it process mouse movement at the same speed as the fps(frames/second) of the flash player .
For example for a function added as a listener to Mouse movement say, stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveListener); Does flash invoke this function 'mouseMoveListener' every time the mouse is moved? Is it done at the same speed at which the Operating system handles mouse move ? Or is it lesser? If so, then by what amount?
View 4 Replies
Jan 5, 2011
I'm trying to catch when a second is passed using getTimer. I don't want to use setInterval, because I'll need to pause, and unpause it. So.. here's my code:
[Code]...
What is wrong with this code? It seems that the time variable reachs 1000 milliseconds too fast.I'm not getting a second interval. How would I fix that?
View 1 Replies
Jan 31, 2011
I have recently been working on a Flash file that dynamically loads a movie based on the contents of a simple XML file. I was concerned about caching issues so tried to set up the code to avoid the XML file being cached causing the wrong content to be loaded. I did this by adding a dummy query string to the file link which is a numerical value generated by getTimer().In practice the system mostly worked but occasionally old content would load even though the XML had been changed. The code runs a setInterval that checks the XML every 20 seconds and checks if the loaded file specfied has changed. The code loads the XML with the following code:
The getTimer() functions starts counting in milliseconds as soon as the movie runs so there is a chance that the same query string is assigned to more than one file, meaning that an old cached version is loaded instead of the new, live file. I am now thinking about ways to improve this code and generate unique values for the query string. I thought using the epoch time - the time in milliseconds from which Flash calculates time and dates which is set to Jan 01 1970 - would generate a new value every millisecond and maybe adding an additional random number to that value to further reduce the chance of the same query string being generated more than once.
this.onEnterFrame = function () {
var nowDate:Date = new Date();
nowTime = nowDate.getTime();
[code].....
View 1 Replies
Apr 19, 2004
this doesn't work...what's wrong with it. i want to stall the timeline in an MC for 5 seconds.
Code:
now=getTimer();
if (now > 5000) {[code].........
View 14 Replies
Aug 9, 2004
I have a simple slideshow that is non-interactive. It just loops five movie clips loaded externally. Each slide is shown for a certain amount of time that is determined with getTimer.The code for the slideshow is in the last frame of the root timeline. So, basically the slideshow starts when the root timeline finishes playing. The problem is that the timer works great the first time the code plays, but when I tell the player head to back up and enter the frame again, the clips play very rapidly, as though getTimer was not being initialized.
Here is the code:
stop();
square._alpha = 0;
[code].....
View 2 Replies
May 18, 2007
Is it possible to capture the time in a timer? I have some English learning games for my students that use a timer. It works fine as it is. Its starts when they click start and ends when they drag the last thing into place. What I would like to do is have a bonus scene when students do exceptionally well and get some crazy low score. I don't know how to go about capturing the end time though.
View 1 Replies
Jul 30, 2009
I have the following in a class and get an error message. CaseStudyQuiz is my constructor method. I want to detect when the mouse moves via the stage.addEventListener.
[Code]...
View 17 Replies
Sep 16, 2009
i have an .fla, which loads goes to different frames in the timeline according to the download speed of the user. i understand how it should work... start timer > upload file > stop timer > calculate download speed - easy?
so what is this simple code im missing to find the download speed? from my fruitless searching, the only relevant code i could find, is this:
Code:
var time1 = getTimer();
targetClip.loadMovie("example.swf");
targetClip.onLoad = function()
[Code]....
... but i have test this, which gives an undefined property error grrr.... so what is the actionscript 3, to find the value of the download speed?
View 4 Replies
Jun 18, 2009
I'm in the process of making a game (a shmup) and I've started to question the accuracy of the timers in ActionScript. Sure, they're accurate enough when you want to time things on the order of a few seconds or deciseconds, but it seems to perform pretty poorly when you get to finer ranges. This makes it pretty tough to do things like have a spaceship firing a hundred lasers per second.
In the following sample, I tested how long (on average) the intervals were between 1000 timer ticks intended for 30ms. Time and time again, the results are ~35-36ms. Decreasing the time, I found the floor on the timer delay to be ~16-17ms. This gives me a max fps of ~60, which is great visually but also means I can't possibly fire more than 60 lasers per second :-(. I ran this test a few times at 100 and 1000 loops, but for both the 30ms test and the 1ms test the results didn't change. I print to a textField at the end because using trace() and launching the swf in debug mode seems to negatively affect the test. So what I'm wondering is:
Is this test a decent measure of the Timer class's performance, or are my results questionable? Will these results change dramatically on other machines? I understand this is dependent on the getTimer() method's accuracy, but the discussions I find on this topic usually center around getTimer()'s accuracy on larger intervals.
[CODE]...
View 5 Replies
Jan 17, 2012
I'm working on the game. The gameplay is based on a really small time lapse (you have only 5 secondes to do an action). My timer works great in Flash Player, i DO have 5 secondes. In a web browser (firefox, safari ..) the 5 seconds timer is now 8 seconds.
[Code]...
View 1 Replies
Aug 4, 2003
I need to get my movie to check if the user has click anywhere on the interface (doesn't matter were), if there's not click after 60second, I need to send the movie back to frame1.I know is a combination of addListener(Mouse), onMouseMove and getTimer. but I'm not very good at action script yet to combine the three.
View 8 Replies
Oct 9, 2011
I'm encoutering something pretty weird. My framerate is set to 60 and I have a function that listens to enterFrame events and calls getTimer() to calculate the time between steps. That usually works nicely, however when I run the swf in flash player 10.3 or 11 standalones, the time delta is detected for many steps as being '0' because getTimer() returns exactly the same thing as on the previous step. The flash movie as such doesn't skip frames (except it looks bad since everything moves according to the time delta) and the framerate is 60 as it should (EDIT: Not actually true, 0 ms frames are skipped). It doesn't even happen every time. Sometimes I run it with the aforementionned players and it's just fine, apparently for no reason. I have tried the debug and release players and the problem happens with both.I'm targeting flash player 10.0 and it works well with that standalone player, as it does with 10.1. Not targeting 10.3 might be part of the problem I guess, but I have no idea really. At any rate, I was wondering if anyone else encountered that problem before, and hopefully would know the cause. I have found nothing about it on the web so far.Technical info: I'm using flashDevelop 3.3.2 and the Flex 4.1 open source sdk
EDIT: It would seem it's not a getTimer problem. The time delta between frames is reported correctly but faulty frames do last 0ms.
View 4 Replies