Copy link to clipboard
Copied
Hey I'm new at AS, and i have been trying to make an object (a ball) fall within gravity but nothing happens when i'm running the swf.
here's the code:
onClipEvent (load) {
fallMax = 0;
}
onClipEvent (enterFrame) {
if (ball._y < 300)
{
_y += fallMax;
if (fallMax < 10)
{
fallmax++;
}
}
}
what am i doing wrong?
you probably have some scope problems. but rather than correct those, you should remove all code from objects and attach code to timelines:
var fallMax:Number=0;
this.onEnterFrame=gameloopF;
function gameloopF():Void{
if(ball._y<300){
ball._y+=fallMax
if(fallMax<10){
fallMax++;
}
} else {
delete this.onEnterFrame;
}
}
Copy link to clipboard
Copied
you probably have some scope problems. but rather than correct those, you should remove all code from objects and attach code to timelines:
var fallMax:Number=0;
this.onEnterFrame=gameloopF;
function gameloopF():Void{
if(ball._y<300){
ball._y+=fallMax
if(fallMax<10){
fallMax++;
}
} else {
delete this.onEnterFrame;
}
}
Copy link to clipboard
Copied
Thank you
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now