0

fla ファイルと という外部クラスがありtheAlarmClockます。時計の針は動いているはずですが、その後Ctrl+Enter- それらはアイドル状態です。

package 
{
import flash.display.MovieClip;
import flash.events.TimerEvent;
import flash.utils.Timer;

public class theAlarmClock extends MovieClip
{
    var myDate:Date;
    var mySec:int;
    var myMin:int;
    var myHou:int;
    var myTimer:Timer = new Timer(1000);

    public function theAlarmClock()
    {

        myTimer.addEventListener(TimerEvent.TIMER, updateClock);
        myTimer.start();


        function updateClock(t:TimerEvent):void
        {
            myDate = new Date();
            mySec = myDate.seconds;
            myMin = myDate.minutes;
            myHou = myDate.hours;
            clockHandSeconds_mc.rotation = mySec * 6;
            clockHandMinutes_mc.rotation = myMin * 6;
            clockHandHours_mc.rotation = myHou * 30 + myMin * 0.5;
            trace("tick");


        }


    }
}

}
4

2 に答える 2

0
package {


    import flash.display.Shape;
    import flash.display.Sprite;
    import flash.events.TimerEvent;
    import flash.sensors.Accelerometer;
    import flash.utils.Timer;

    public class ToolClass extends Sprite
    {
        private var myDate:Date;
        private var mySec:uint;
        private var myMin:uint;
        private var myHou:uint;
        private var myClock:Sprite;
        private var myHour:Shape;
        private var myMins:Shape;
        private var mySeco:Shape;

        private var myTimer:Timer=new Timer(1000);

    public function ToolClass()
    {
        drawClock();

        myTimer.addEventListener(TimerEvent.TIMER,updateClock);
        myTimer.start();
    }

    private function drawClock():void
    {
        myClock=new Sprite();
        myClock.graphics.lineStyle(0,0x000000,1);
        myClock.graphics.drawCircle(0,0,100);
        addChild(myClock);
        myClock.x=150;
        myClock.y=150;

        myHour=new Shape();
        myHour.graphics.lineStyle(5,0x00000,1);
        myHour.graphics.lineTo(0,-50);
        myClock.addChild(myHour);

        myMins=new Shape();
        myMins.graphics.lineStyle(2,0x000000,1);
        myMins.graphics.lineTo(0,-80);
        myClock.addChild(myMins);


        mySeco=new Shape();
        mySeco.graphics.lineStyle(1,0x000000,1);
        mySeco.graphics.lineTo(0,-80);
        myClock.addChild(mySeco);


    }
    public function getTime():void
    {
        myDate=new Date();

        myHou=myDate.hours;
        myMin=myDate.minutes;
        mySec=myDate.seconds;

    }
    private function updateClock(e:TimerEvent):void
    {
        getTime();
        myHour.rotation=myHou*30+30*myMin/60;
        myMins.rotation=myMin*6+6*mySec/60;
        mySeco.rotation=mySec*6;
        trace("tick");
    }
    }
}
于 2013-04-08T08:23:58.530 に答える