I have a Hero class and am trying to move the mc character:
class Hero {
private var hero:MovieClip;
function Hero() {
hero = _root.attachMovie("hero", "hero", _root.getNextHighestDepth());
hero.onEnterFrame = mover;
}
function mover() {
this._x += 5;
}
}
This throws the following error:
There is no property with the name '_x'.
this._x += 5;
Total ActionScript Errors: 1 Reported Errors: 1
I tried changing hero.onEnterFrame = mover to hero.onEnterFrame = mover.call(hero); but that doesn’t work either.
This does work but it’s not how I would like to have structured the code:
hero.onEnterFrame = function() { this._x += 5 }
Any ideas?