Answered
can't get the timer to work
hello,
I'm new to AS 3. However, I'm finding it to be baffling overall. Every time I try to go deeper with it I find I can't get what appear to be simple tasks to function.
This time I'm trying to work with the timer class. I have two layers: display and actions. In the display layer (which is below the actions layer), I've got a single instance of dynamic text. I gave it an instance name of dtDisplay.
In the actions layer, I have a keyframe and this code:
import flash.utils.Timer;
function runMany(event:TimerEvent):void {
trace("runMany() called @ " + getTimer() + " ms");
}
var myTimer:Timer = new Timer(25000,1);
myTimer.addEventListener(TimerEvent.Timer, runMany);
myTimer.start();
dtDisplay.text = 'haha';
What I'm trying to achieve with this code is a 25 second delay, then the dynamic text being applied to the control.
However, when I run this flash file, I get an error on the line with myTimer.addEventListener:
"1119: Access of possibly undefined property Timer through a reference with static type Class."
Now, I think this could be related to my class path. I've set the class path to have two values:
c:\program files\Adobe\Adobe Flash CS3\en\Configuration\ActionScript 3.0\Classes
C:\Program Files\Adobe\Adobe Flash CS3\en\First Run\Classes\mx\utils
The second path has at least the 'utils' part of the import statement at the top of my frame. However, when i peruse the utils.as, i see no reference to a timer class.
I have searched my hard drive for AS files that contain the timer class but don't see it.
Does anyone have any ideas? Thanks.
I'm new to AS 3. However, I'm finding it to be baffling overall. Every time I try to go deeper with it I find I can't get what appear to be simple tasks to function.
This time I'm trying to work with the timer class. I have two layers: display and actions. In the display layer (which is below the actions layer), I've got a single instance of dynamic text. I gave it an instance name of dtDisplay.
In the actions layer, I have a keyframe and this code:
import flash.utils.Timer;
function runMany(event:TimerEvent):void {
trace("runMany() called @ " + getTimer() + " ms");
}
var myTimer:Timer = new Timer(25000,1);
myTimer.addEventListener(TimerEvent.Timer, runMany);
myTimer.start();
dtDisplay.text = 'haha';
What I'm trying to achieve with this code is a 25 second delay, then the dynamic text being applied to the control.
However, when I run this flash file, I get an error on the line with myTimer.addEventListener:
"1119: Access of possibly undefined property Timer through a reference with static type Class."
Now, I think this could be related to my class path. I've set the class path to have two values:
c:\program files\Adobe\Adobe Flash CS3\en\Configuration\ActionScript 3.0\Classes
C:\Program Files\Adobe\Adobe Flash CS3\en\First Run\Classes\mx\utils
The second path has at least the 'utils' part of the import statement at the top of my frame. However, when i peruse the utils.as, i see no reference to a timer class.
I have searched my hard drive for AS files that contain the timer class but don't see it.
Does anyone have any ideas? Thanks.