<< Chapter < Page | Chapter >> Page > |
You must start the timer
The timer does not start automatically. You must call the start() method to start it.
A project to measure the TIMER event rate
Listing 17 provides a simple AS3 project that illustrates the use of TIMER events. As before, this project computes and displays the average frequency of TIMER events for each of five consecutive sets of 200 events.
Two time bases running
In this case, there are two different time bases running: the frame rate and the timer rate. Unfortunately, it appears that they are not independent of oneanother.
A rate of 30 TIMER events per second
Figure 3 shows the output when the timer is set to fire 30 events per second and the Flash Player is running at its default rate of approximately 30 framesper second.
1271892152172
1271892159395 200 27.6893257649176231271892166061 400 30.003000300030006
1271892172727 600 30.0030003000300061271892179393 800 30.003000300030006
1271892186062 1000 29.9895036737142 |
Not too bad after a slow start
As you can see in Figure 3, after a somewhat slow start during the first 200 events, the timer event rate was reasonably solid at 30 events per second, on the average, for thenext 800 events.
A rate of 10 TIMER events per second
Figure 4 shows the output when the timer was set to fire 10 events per second and the Flash Player was running at its default rate of approximately 30 framesper second.
1271892525653
1271892548767 200 8.652764558276371271892571894 400 8.64790072209971
1271892594995 600 8.6576338686636941271892618445 800 8.528784648187633
1271892641413 1000 8.707767328456983 |
Not a very accurate event rate
In this case, the event rate was relatively precise at an average of about 8.65 events per second but didn't fare well in terms of accuracy since the target rate was 10 events per second.
Accuracy versus precision
Accuracy and precision don't mean the same thing. According to Wikipedia ,
"In the fields of engineering, industry and statistics, the accuracy of a measurement system is the degree of closeness of measurements of a quantity toits actual (true) value. The precision of a measurement system, also called reproducibility or repeatability, is the degree to which repeated measurementsunder unchanged conditions show the same results."
Another result at a rate of 10 TIMER events per second
Figure 5 shows the output when the timer was set to produce 10 events per second and the Flash Player was running at a frame rate of 10 frames per second.
1271893113643
1271893134531 200 9.5748755266181541271893155027 400 9.758001561280249
1271893175626 600 9.7092091849118881271893195926 800 9.852216748768473
1271893216226 1000 9.852216748768473 |
Close, but no cigar
In this case, the event rate was closer to the target of 10 events per second, but was still consistently below the mark.
Even more troublesome is the difference between the results in Figure 4 and the results in Figure 5, which show that the event rate of the timer depends onthe frame rate of the Flash Player.
An empty Flash Player window
The Flash Player was running in all five cases discussed above, but it was simply displaying an empty white window. No objects were being displayed in theFlash Player window.
Notification Switch
Would you like to follow the 'Object-oriented programming (oop) with actionscript' conversation and receive update notifications?