AS3 :: Flex - GetTimer() Method And The Timer Class?

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


Similar Posts:


ActionScript 3.0 :: Pausing A Timer Without GetTimer (instead Of Stopping / Restarting)

Oct 20, 2010

I'm currently working on a detailed music media management application in Flash. There is a mp3 player which plays music and has a playback seeker (keeps track of current time for track and a tiny pin that that increases its x position as the track plays). I have a simple play & pause button that does appropriate functionality of playing & pausing the track, but the issue is that I have to pause the Timer associated with updating the playback seeker. The seekerTimer object has a delay of 1000 (1 second), while I'm listening to a track, the timer may have already excuted 600 ms, only waiting for 400 ms till the next timer event is dispatched to update the playback seeker. If I hit the pause button at 600 ms of execution time and I do a seekerTimer.stop(); and then a seekerTimer.start();, the timer does not resume its execution and instead restarts executing from 0 ms. This means that the playback seeker is not updated accordingly.

How can I pause the timer when I hit my pause button (essentially store the execution time), and then resume execution when I hit the play button? The play button doesn't have any parameters to start executing from a certain time. I looked at tutorials online but they all rely on the getTimer(); function, this returns a value of how long the Flash player has been running (from initialization). The issue is that the mp3 player in this Flash app doesn't initialize upon the application initalization (I know its a bit confusing).

View 3 Replies

ActionScript 3.0 :: Use A GetTimer Method That Takes To Another Frame - Continues Counting

May 27, 2010

I am trying to use a getTimer method that takes me to another frame (frame is "memory") after a certain amount of time after the movieclip has been loaded. The frame that I want it to go was given the name already. The timer itself does count when tested, but it just continues counting.

[Code]....

View 2 Replies

ActionScript 2.0 :: (getTimer-getTimer) Word "undefined" Is Displayed In The Textbox?

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

Flex :: Enterframe Event - Using Timer Class For Main Loop

Jan 8, 2011

I have been developing a game using Flex, and used the Timer class to keep the main loop going. However, when I tried using the enterFrame event to do the main loop, there were a few problems. First of all, physics simulation seemed way too fast. Is the enterFrame event called more than once per frame? I set the application's global frame rate to 24, so shouldn't the application set off the event every 1/24 of a second? And the second problem is that when the game runs like this, some MXML components that are added are not shown.

View 2 Replies

Flex :: Calling A Static Method Of A Class With Only An Instance?

Jul 27, 2009

If all I have is an instance of an object, can I call a static method of its class? For fun, let's say I don't know what the name of the class is, only the name of the static method.

View 3 Replies

ActionScript 3 :: Flex - Wait For Class Method To Complete?

Aug 30, 2010

I'm currently creating a website with AS3 in FlashDevelop, so it's code only no timeline stuff.

I have a class that loads images with a method that I call from my main source. I was wondering how I go about making sure that the images are loaded before executing more code outside of the class. I know how to do it using Event.COMPLETE in the image class, but I am unsure how to get the main class to wait.

View 1 Replies

Flex :: Cannot Add Method / Function To Class Of Existing Project?

Mar 28, 2011

I'm totally new to Adobe Flex Builder 3. I've been assigned a fully functional project but when I want to add the simplest function to any class, I always got the same error :
Call to a possibly undefined method through a reference with static type

For example, in some random class there is a function defined like this :
public function GetID() : String { return m_strID; }
If I try to define a new one like below :
public function GetIDFoo() :String { return m_strID; }

And then I try to call both of them like this:
trace ("This line is ok : " + oPhysicalScreen.GetID());
trace ("This line gives me an error : " + oPhysicalScreen.GetIDFoo());
[Code] .....

View 2 Replies

Flex :: Determine When A Method Or Property Was Added To A Player Or SDK Class?

Sep 11, 2009

I recently found a method (ByteArray.clear()) that FlexBuilder complains is possibly undefined; however, the method is in fact documented in the Flex LiveDocs. It must have been added in a later version of the SDK than I have installed. I'm not asking about this particular method, but I'm giving it as an example of the documentation issue that I'm trying to resolve. My questions are:

How can I determine what version of the SDK or Flash player that a method or property was added in? How can I tell which versions of the SDK are supported on which Flash player versions?

I want to be able to determine from the documentation, instead of compiler or runtime errors, what SDK and Flash player versions are needed to support newly added methods.

With Java I look for the @since javadoc tag when I need to know this, but I can't find an equivalent feature in the Flex docs.

View 3 Replies

Flex :: Programmatically Get Documentation Comments From A Class , Method / Property?

Dec 11, 2010

I know that I can get info about constants, methods, etc of a class by using flash.utils.describeType. But I want to know if I can retrieve the asdoc comments of a class member.

I suspect, documentation is removed when classes are compiled into SWF so it might be impossible to get comments during run-time.

View 2 Replies

Xml :: Flex - Getting Warning: 3594: Parent Is Not A Recognized Method Of The Dynamic Class XML?

Jan 26, 2010

It's coming from this line of code:var dropTargetXML:XML = XMLTemplate.template.component.section.question.(@question_questionID == nNode.parent().@question_questionID)[0];nNode is an XML node sent as an argument to the function this is called in. The code runs,and does everything expected but the compiler sends out that warning. Do I have some formatting issue?P.S. I've tried telling it that it's XML like this:var dropTargetXML:XML = XMLTemplate.template.component.section.question.(@question_questionID == XML(nNode).parent().@question_questionID)[0];

View 1 Replies

ActionScript 3.0 :: Timer Method And If Statements?

Jun 15, 2010

I am interested in have a dynamic text field display three quotes at different intervals. I thought I could use the Timer to trigger these quotes by loading them into the dynamic TextField.
 
However, I cannot seem to get it going. I try to attach a number from the timer but that throws an error /1176: Comparison between a value with static type flash.utils:Timer and a possibly unrelated type int.

[Code]...

View 3 Replies

Flex :: Any Method In Module Class Where I Can Hide And Show Based On User Login?

May 19, 2010

<?xml version="1.0"?>
<!-- This module loads an image. -->
<mx:Module width="100%" height="100%" [code]..........

I have such 10 modules. Is there any Method in Module Class where i can hide and show based on user login.

View 1 Replies

Flex :: Call To A Possibly Undefined Method Through A Reference With Static Type Class

Aug 1, 2011

I wrote a singleton class to keep track of some variables across my application.

I am getting a syntax error that I can't figure out, I am sure that I am missing something simple but it's been one of those days. Anyone see something wrong with my code?

The error is 1061: Call to a possibly undefined method setResult through a reference with static type Class.

My function in my singleton class

public function setResult(resultNumber:int, value:int): void
{
switch(resultNumber)
{

[Code].....

View 2 Replies

Actionscript 3 :: Timer Method Won't Add Textfield To Sprite?

Sep 2, 2011

When i press keyboard down button the textfield is added to sprite but not through timer event call. Why is that ?

package
{
import flash.display.Sprite;
import flash.events.KeyboardEvent;

[Code].....

View 1 Replies

ActionScript 3.0 :: Listen For A Timer Event In Document Class From Another Class?

May 7, 2010

How do I listen for a timer event in my document class from another class? im thinking...... HTML Code:

[Code]...

HTML Code: 1119: Access of possibly undefined property gameTimer through a reference with static type Class.

View 3 Replies

Flex :: Sequence Flex/Actionscript Method/function Method Calls

Aug 11, 2011

OK, from what I know actionscript in Flex runs asynchronously. I need the ability to run a method in a loop synchronously. Consider this code:

public class CustomerContainer extends VBox
{
public function CustomerContainer ()
{

[Code]....

This is not my exact situation as it is a bit more complicated to explain here. There is an abstract class and several custom view objects derived from it. Some of the views are dependent on others being completed first but I cannot seem to order them in the correct order. TIMERS are not an option. Probably not explaining this correctly.

View 2 Replies

Actionscript 3 :: Calling A Method, Which Is Defined In Another Class, From Main Class Gives Error 1120?

Aug 16, 2010

I have two classes. The Main class calls a function, which is defined in a Second class.I'm getting the following error:Error 1120: Access of undefined property myFunctionBasically, I am creating buttons in the Main class that will add a corresponding Child to an Object in the Second class (if you click one button, child x1 will be added, if you click another button, child x2 will be added, and so forth).Here's the relevant code for the Main.as file:

package
{
import flash.display.MovieClip;

[code].....

View 3 Replies

ActionScript 3.0 :: Calling Method In Parent Class From Imported Class?

Jul 15, 2011

I have the following parent class that I'm working with:

Code:
package {
import com.poptent.SubClassOne;
import com.poptent.SubClassTwo;

[Code].....

I am trying to set it up so that a parent method called by subClassOneInstance can affect subClassTwoInstance.

View 4 Replies

ActionScript 3.0 :: Flash - Calling Method On Document Class From Another Class?

Jul 5, 2010

I have a rather silly question but as3's document class always gets me confused.I have a public method on my document class. I want to call this method from another class that is instantiated from within an object in the library of the flash file (the same one on whose document class I want to call a method).

View 6 Replies

ActionScript 3.0 :: Invoking A Method Of Document Class From Other Class

Mar 23, 2009

I have two classes:

1. DocumentClass

2. GameClass

I would like to be able to call a public method of DocumentClass from GameClass. I don't know how to do that, I tried instantiating an object of DocumentClass within GameClass which simply throws me into an endless loop and after a short while application crashes.

View 2 Replies

Actionscript 3 :: Call A Method From A Different Class In Current Class

Nov 4, 2010

I have a class, my document class, called SilkRoadTweeter. as I also have a class called User.as In my User class I need to call a method called nonce() I have tried this, trace(SilkRoadTweeter(root).nonce()); But I get the error, TypeError: Error #1009: Cannot access a property or method of a null object reference.

View 4 Replies

Actionscript 3.0 :: Calling Method On Document Class From Another Class?

Jul 6, 2010

I have a public method on my document class. I want to call this method from another class that is instantiated from within an object in the library of the flash file (the same one on whose document class I want to call a method).

I have tried everything and nothing seems to work. How do I do this?

View 8 Replies

ActionScript 2.0 :: Delete Instance Of Class From Class' Method?

Dec 28, 2005

I have a class called Unit. When I use this class in a .fla file, I create it by saying:

var unit00:Unit = new Unit(...);

So then it creates a gfx representation of the screen for me. I would like to have a method like this:

PHP Code:

[code]....

So how do I get this to work? I know that delete this will not work when defined inside the class. How do I target the .fla's instance name when I don't know what it will be called?

View 10 Replies

ActionScript 3.0 :: Call A Method From One Class From Within Another Class?

Jun 9, 2011

They are located in the same package and are both importing each other. I am trying to call a function from Class2 within Class1, but I don't know the syntax. I tried: Class2.godoThisThingNow(); But it gave me an error 1061, call to an undefined method. What's the proper syntax for this, and is it even possible in AS3?

View 3 Replies

ActionScript 3.0 :: Class A Call A Method From Class B?

Oct 12, 2009

From my LoadXML class I am trying to call a method, named onBackgrLoad, which sits inside the Main class. I made the method onBackgrLoad public. Inside the LoadXML class in the method ParseData I added an event listener. This is supposed to call onBackgrLoad but it doesnt work

[Code]...

View 3 Replies

ActionScript 3.0 :: Timer In Document Class?

Sep 18, 2009

I have the code here in a Document Class - I'm trying to fade in a logo than after a set time fade it out.he logo fades in but when it starts to fade out I get a repeating error - the logo still fades out but there's obviously something wrong that I can't work out

Quote:
TypeError: Error #1016: Descendants operator (..) not supported on type Logo.
at Doc/fadeOut()

[code]......

View 4 Replies

ActionScript 3.0 :: Remove A Child Within Timer Class?

Dec 9, 2011

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]...

View 5 Replies

ActionScript 3.0 :: Class Is Not Dispatching Event Without Timer Of 1 Second

Apr 28, 2011

I am developing a project where ClassA creates the instances of ClassB , ClassC and ClassD and adds the eventsDispatcher with them. ClassB and ClassC are able to dispatch the events back to ClassA which is fine. But ClassD is not dispatching the event. It only dispatch the event only when I call the dispatchEvent(new Event(Event.Complete)) function after giving 1 Second delay.

View 11 Replies

ActionScript 3.0 :: Using The Timer Class To Time Events

Feb 11, 2010

I am using the Timer class to time events. Although, I am not sure I have it set up correctly as after a few seconds the events start to get synchronized. first two, then three, etc. Here is an example of the code:

[Code]...

Does anyone know what could be possibly interfering with the Timer for this to happen? It mainly starts happening after you click on an mc and it is removed from the stage (this is for a game).

View 3 Replies







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