PDA

View Full Version : [Flash]ActionScript2.0 Help thread



DarkCloud
12-25-2009, 08:14 PM
Ok guys if you haven't noticed I'ved asked for help on as2 many times and I need it again so if I have more questions(I probably will)I'll post them here unless a mod says I can't so anyways. I've made a hitTest but it doesnt work heres the code of the ball.
onClipEvent(load){
moveSpeed=5;
}
onClipEvent(enterFrame){
if(Key.isDown(Key.UP)){
this._y-=moveSpeed;
}
if(Key.isDown(Key.DOWN)){
this._y+=moveSpeed;
}
if(Key.isDown(Key.LEFT)){
this._x-=moveSpeed;
}
if(Key.isDown(Key.RIGHT)){
this._x+=moveSpeed;
}
}
onClipEvent(enterFrame){
if(this.hitTest(_root.Wall)){
this._x+=moveSpeed;
}
if(this.hitTest(_root.Wall)){
this._x-=moveSpeed;
}
if(this.hitTest(_root.Wall)){
this._y+=moveSpeed;
}
if(this.hitTest(_root.Wall)){
this._y-=moveSpeed;
}
} Im not sure why it doesnt work when i try to hit the object Wall I just pass through it...help guys.

CGIllusion
12-25-2009, 10:20 PM
[CODE]onClipEvent(load){
moveSpeed=5;
}
onClipEvent(enterFrame){
if(Key.isDown(Key.UP) && this._y > top){
this._y-=moveSpeed;
}
if(Key.isDown(Key.DOWN && this._y < floor)){
this._y+=moveSpeed;
}
if(Key.isDown(Key.LEFT) && this._x < leftWall){
this._x-=moveSpeed;
}
if(Key.isDown(Key.RIGHT) && this._x > rightWall){
this._x+=moveSpeed;
}
}

roof = 0;
floor = document height
leftwall = 0;
rightwall = document width

That's all you need relle for collissions with the walls. HitTesting an object in the middle of the screen with a controlled player is much more advanced and requires more thought.

DarkCloud
12-26-2009, 06:01 AM
oh so you need like a right left top bottom wall crap.

Aycaramba
12-26-2009, 06:41 AM
I don't think you can use the onEnterFrame function on an object more than once.

DarkCloud
12-26-2009, 06:58 AM
oh I cant I didnt know that :Ohhhhh: .

slipe_rock
12-26-2009, 01:41 PM
this site
makes me so very proud to be a member ^_^
WUOSA> ! ! ! ! ! ! !

DarkCloud
12-26-2009, 02:22 PM
wtf who the hell are you...

Zero
12-26-2009, 10:07 PM
Some kind of a begginer I think.

CGIllusion
12-26-2009, 10:49 PM
WUOSA> ! ! ! ! ! ! !

It's obviously Martin Lawrence...