forked from: how can I make a timer.Event work

by yonatan
Hello, I've some problems with the Timer.
I wanna code something, that will redo in every x-seconds (f.e. to create a clock)
The part with the mouseEvent works wonderfull, but the Timer.Event won't work

I have imported the flash.events.TimerEvent;
I've declared the ticker Variable as :Timer;
I've set the ticker as new Timer 
and I've started the ticker.

In Tutorials in the web the allways worked with code in an Flash-movie, so it's hard to find something
that fits to wonderfl.

Your rotateP listener function was expecting a MouseEvent as a parameter.
Timers dispatch TimerEvents. If you go to http://www.adobe.com/support/flashplayer/downloads.html
and install a debugger plugin, flash will show you error messages about bugs like this.
♥0 | Line 27 | Modified 2011-01-02 11:15:54 | MIT License
play

ActionScript3 source code

/**
 * Copyright yonatan ( http://wonderfl.net/user/yonatan )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/NpDL
 */

// forked from tipein123's how can I make a timer.Event work
// Hello, I've some problems with the Timer.
// I wanna code something, that will redo in every x-seconds (f.e. to create a clock)
// The part with the mouseEvent works wonderfull, but the Timer.Event won't work
//
// I have imported the flash.events.TimerEvent;
// I've declared the ticker Variable as :Timer;
// I've set the ticker as new Timer 
// and I've started the ticker.
// 
// In Tutorials in the web the allways worked with code in an Flash-movie, so it's hard to find something
// that fits to wonderfl.

//
// Your rotateP listener function was expecting a MouseEvent as a parameter.
// Timers dispatch TimerEvents. If you go to http://www.adobe.com/support/flashplayer/downloads.html
// and install a debugger plugin, flash will show you error messages about bugs like this.

package {
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import flash.utils.*;
    import flash.events.TimerEvent;

    
    public class FlashTest extends Sprite {
        public function FlashTest() {
            // write as3 code here..


var square:Sprite = new Sprite();
var ticker: Timer;

square.graphics.beginFill(0xeeff00);
square.graphics.drawRect(-50, -50, 100, 100);
square.x = 150;
square.y = 150;
addChild(square);

square.addEventListener(MouseEvent.CLICK, rotateM);

            ticker = new Timer(500);
            ticker.addEventListener(TimerEvent.TIMER, rotateP);
            ticker.start();


function rotateP(event:TimerEvent):void {
        square.rotation += 15;
}            

function rotateM(event:MouseEvent):void {
        square.rotation -= 15;
}            
            
    
        }
    }
}