Thanks for helping MiM, but… I can’t Understand it at all ( I mean I Don’t know were to place this action, the name to give to the variables(if any), the button that’ll start the countdown etc…(I’m not too andvance in actionScript you know)). Plus each time i try to “paste” these action somewhere flash tells me that it contains errors and displays this in the output window :
Clipboard Actions: Line 1: ‘;’ expected
class Countdown{
Clipboard Actions: Line 2: ‘;’ expected
private var seconds:Number;
Clipboard Actions: Line 3: ‘;’ expected
private var interval:Number;
Clipboard Actions: Line 5: ‘;’ expected
public function Countdown(aNumber:Number){
Clipboard Actions: Line 8: ‘;’ expected
public function start():Void{
Clipboard Actions: Line 11: ‘;’ expected
public function stop():Void{
Clipboard Actions: Line 14: Unexpected ‘}’ encountered
}
Here is the original scripyou sent to me :
class Countdown{
private var seconds:Number;
private var interval:Number;
public function Countdown(aNumber:Number){
seconds = aNumber;
}
public function start():Void{
interval = setInterval(substractSeconds, 1000, this);
}
public function stop():Void{
clearInterval(interval);
// doSomething
}
private function substractSeconds(target):Void{
trace(target.getSeconds());
target.setSeconds(target.getSeconds()-1);
if(target.seconds <= 0){
target.stop();
}
}
public function setSeconds(aNumber:Number):Void{
seconds = aNumber;
}
public function getSeconds():Number{
return seconds;
}
}
usage:
ActionScript:
var CD:Countdown = new Countdown(120);
CD.start();
Can you help me. (the best would be someting compatible with flash 5 if possible(but it doesn’t really matter), i don’t know if it is not already the case,tough).Thanks