View Full Version : Error #1023: Incompatible override.
skyp
May 25th, 2007, 08:34 PM
override protected function draw(event:Event = null):void {
ReferenceError: Error #1065: Variable ClockTest is not defined.
the code is from <<Advanced Actionscript 3.0 With Design Patterns>>
/**
*
* ABSTRACT METHOD TO BE OVERRIDDIN
*
**/
protected function draw(event:Event):void {
}
/**
*
* OVERRIDE METHOD
*
**/
override protected function draw(event:Event = null):void {
var time:Time = _data.time;
// Set the rotation of the hands based on the time
// values.
_hourHand.rotation = 30 * time.hour + 30 * time.minute / 60;
_minuteHand.rotation = 6 * time.minute + 6 * time.second / 60;
_secondHand.rotation = 6 * time.second;
}
wondering any one can help? thanks.
senocular
May 26th, 2007, 08:33 AM
method signatures have to match. The overriding method has an extra "= null" that needs to be removed for it to work.
skyp
May 26th, 2007, 07:16 PM
senocular (http://www.kirupa.com/forum/member.php?u=2867), thanks for your reply, I played around and still cannot get it right, can you please have a look the source code attached here.
thanks in advance. :)
mathew.er
May 26th, 2007, 08:19 PM
Like Senocular said, just replace
override protected function draw(event:Event = null):voidwith
override protected function draw(event:Event):void
skyp
May 26th, 2007, 08:37 PM
it will cause another problem //1136: Incorrect number of arguments. Expected 1.
cause the constructor is calling the draw() method.
I think the source I provided in the above attachment might be more clearer to state my problem.
thanks again..:)mathew.er
senocular
May 26th, 2007, 11:16 PM
thats because you're calling the function when it requires an event. Whenever you call it, you have to pass it an event
draw(new MouseEvent())
Either that or you have to have =null for both methods
visnik
February 2nd, 2011, 10:49 AM
I had the same exact issue, I think it is a typo in the book.
colomjimmy28
February 7th, 2011, 08:02 PM
I had the same exact issue, I think it is a typo in the book.
Im reading the same book. This worked for me pass null to the function draw( null );
public function AnalogClock( $data:ClockData )
{
super( $data );
this._face = new Sprite();
this._face.graphics.lineStyle( 0, 0x000000, 1 );
this._face.graphics.drawCircle( 0, 0, 100 );
this.addChild( this._face );
this._hourHand = new Sprite();
this._hourHand.graphics.lineStyle( 5, 0x000000, 1 );
this._hourHand.graphics.lineTo( 0, -50 );
this.addChild( this._hourHand );
this._minuteHand = new Sprite();
this._minuteHand.graphics.lineStyle( 2, 0x000000, 1 );
this._minuteHand.graphics.lineTo( 0, -80 );
this.addChild( this._minuteHand );
this._secondHand = new Sprite();
this._secondHand.graphics.lineStyle( 0, 0x000000 , 1 );
this._secondHand.graphics.lineTo( 0, -80 );
this.addChild( this._secondHand );
draw( null );
}
override protected function draw( $event:Event ):void
{
var time:Time = this._data.time;
this._hourHand.rotation = 30 * time.hour + 30 * time.minute / 60;
this._minuteHand.rotation = 6 * time.minute + 6 * time.second / 60;
this._secondHand.rotation = 6 * time.second;
}
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.