Hi, just finished the usual hours of searching and testing to still be none the wiser so hoping someone here can help. What I am trying to do should work, so why doesn’t it?
My problem is best explained as so…
I have two classes one called ‘LoaderSwf.as’ which is used to talk to all the other classes im using. I also have a ‘GeneralTimer.as’ which works fine from a stand alone ‘GeneralTimer.swf’ file. What I am trying to do is send a value of 10ms to the ‘GeneralTimer.as’ which will then run the timer and when complete send a value back. But for simplicity im trying to send a ms value to trace(“tick”) and trace(“tock”).
I keep getting error “TypeError: Error #1034: Type Coercion failed: Cannot convert 10 to GeneralTimer.” this is according to Adobe “1034 Variables cannot be native.” What does that mean for starters?
Here’s my code:
in LoaderSwf.as
var w:Number = 10;
GeneralTimer(w);
in GeneralTimer.as
package
{
//trace("called as file");
import flash.display.Sprite;
import flash.utils.*;
import flash.events.*;
public class GeneralTimer extends Sprite
{
public var timer:Timer;
trace("inside timer class");
public function GeneralTimer(w:Number)
{
timer = new Timer(w, 10);
timer.addEventListener(TimerEvent.TIMER, onTimer);
timer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
timer.start();
trace("inside timer");
}
private function onTimer(event:TimerEvent):void
{
trace("tick");
}
private function onTimerComplete(event:TimerEvent):void
{
trace("Finished!");
}
}
}
so as you can see I want to send the number 10 to be used in the GeneralTimer. I am sure I have used this before (in CS3) and its worked but am now using CS4 and it doesn’t, any help would be most appreciated.
Cheers