|
-
Getting my ship to move D:
For a specific class task I've been set, I need to make my ship move from one side of the screen to the other. This would be just fine if didn't have to use an actionscript, rather than motion tween...
I've gone to my ship symbol and named the instance "ship". After making a new layer for my actionscript, in Action- Frame I was told to enter:
_root.ship.onEnterFrame = function(){
this._x -= 8;
if(this._x < -300){
this._x = 700;
}
}
I've done that, but when I test my movie, my ship just sits there and a compiler error pops up saying:
"1120: Access of undefined property _root."
Please help me? This is my first time making an actionscript so I have no idea at all what I'm doing... >___<"
-
Teacosy is coming
That looks like AS1 code, you'll have to change your syntax for it to work as AS3.
something like:
Code:
ship.addEventListener(Event.ENTER_FRAME, moveShip, false, 0, true);
function moveShip(event:Event):void
{
var myShip = event.target;
myShip.x -= 8;
if(myShip.x < -300)
{
myShip.x = 700;
}
}
Put this code on the mainTimeline, not inside or on the ship MovieClip.
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
|