Controlling Sprite with Classes
Ok the solution to this will probably be so simple, it'll hurt me!
I used to know how to do this, but have since forgotten, and can't remember how, or find the resource I used to learn it in the first place.
Basically, I want to move a sprite made in AS3, with an external class.
This is the code I want to use as an example, just so I can get to grips with it, and apply it in other things.
Library:
MovieClip with AS name of "orb"
Main File Timeline:
Code:
import flash.events.Event;
addEventListener(Event.ENTER_FRAME, enteringFrame);
function enteringFrame(e:Event):void{
var spr:orb = new orb();
spr.x = 175;
spr.y = 30;
spr.addEventListener(Event.ENTER_FRAME, animateOrb);
addChildAt(spr,0);
}
function animateOrb(e:Event):void{
e.target.animate();
}
animate.as
Code:
package {
import flash.display.MovieClip;
public class animate extends MovieClip{
public function animate() {
this.y += 10;
}
}
}
I seem to remember linking the as file to the movieclip somehow, but the error i get for this right now is:
Code:
TypeError: Error #1006: animate is not a function.
at animate/animateOrb()
What do I need to make sure of to get this to work?
Thanks for any help in advance!