Hi
I have a code on timeline for countDown that works well for mc timerObj
import com.flashspeaks.utils.CountdownTimer;
import com.flashspeaks.events.CountdownEvent;
var currentYear:Number = new Date().fullYear;
var targetDate:Date = new Date(2012, 1, 17);
var countdown:CountdownTimer=new CountdownTimer(targetDate);
countdown.addEventListener(CountdownEvent.COUNTDOWN_UPDATE,
onCountdownUpdate, false, 0, true);
function onCountdownUpdate(e:CountdownEvent):void {
timerObj.days.numberText.text=countdown.days;
timerObj.hours.numberText.text=countdown.hours;
timerObj.minutes.numberText.text=countdown.minutes;
timerObj.seconds.numberText.text=countdown.seconds;
}
I want to do the Class with the same functions
package lib
{
import com.flashspeaks.utils.CountdownTimer;
import com.flashspeaks.events.CountdownEvent;
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.text.*;
public class TimerObject extends flash.display.MovieClip
{
public function TimerObject()
{
this.currentYear = new Date().fullYear;
this.targetDate = new Date(2012, 1, 17);
this.countdown=new CountdownTimer(targetDate);
super();
if (stage)
{
this.init();
}
else
{
addEventListener(flash.events.Event.ADDED_TO_STAGE, this.init);
}
return;
}
public function init(arg1:flash.events.Event=null):void
{
countdown.addEventListener(CountdownEvent.COUNTDOWN_UPDATE,
onCountdownUpdate, false, 0, true);
return;
}
private function onCountdownUpdate(e:CountdownEvent):void {
this.timerObj.days.numberText.text=countdown.days;
this.timerObj.hours.numberText.text=countdown.hours;
this.timerObj.minutes.numberText.text=countdown.minutes;
this.timerObj.seconds.numberText.text=countdown.seconds;
}
public var timerObj:flash.display.MovieClip;
private var currentYear:Number;
private var targetDate:Date;
private var countdown:CountdownTimer;
}
}
Class is linked in the library to mc timerObj
that gives error
TypeError: Error #1009: Не удается вызвать свойство или метод со
ссылкой на объект "null".
at lib::TimerObject/onCountdownUpdate()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.flashspeaks.utils::CountdownTimer/updateTime()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()
What is wrong in my class?
Thank you in advance.
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders