-
addEEventListener don't work when using Citrus Engine
Hi,
I'm a newbie in as3 and I recently tried using the as3 platformer Citrus Engine.
I create a player class which extends the Hero class from the Citrus Engine, I want to add extra abilities and properties such as ability to hit (the Hero class from the Citrus Engine is able to move and jump like in typical platformer game)
I haven't create the code for the specific additions yet, but I thought I'll use addEvenListener in this code.
Code:
package {
import com.citrusengine.core.CitrusEngine;
import com.citrusengine.objects.platformer.box2d.Hero;
import flash.events.Event;
public class player extends Hero{
public function player(name, properties){
super(name, properties);
addEventListener(Event.ENTER_FRAME, enterFrame);
}
public function enterFrame(e:Event):void {
\\additional functions
}
}
}
this is the error i got:
1180: Call to a possibly undefined method addEventListener.
wonder why the method is undefined even though i already import the Event class
the addEventListener works when I'm using classes that I made myself without using any engines, but somwhow it doesn't work here
Can anyone help me with this issue? Thanks a lot
-
Senior Member
why the method is undefined even though i already import the Event class
importing Event class only prevents things like Event.ENTER_FRAME from being undefined. addEventListener method has nothing to do with importing Event. it tries to find the method in your player class (not found), then in its base class Hero (not found again), then in Hero's base class, etc etc. if this whole chain of classes does not have addEventListener method (as apparently the case is), you get this error message.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|