[Flash]ActionScript2.0 Help thread

Started by: DarkCloud | Replies: 8 | Views: 550

DarkCloud

Posts: 164
Joined: Dec 2009
Rep: 10

View Profile
Dec 26, 2009 3:14 AM #528686
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
2

Posts: 617
Joined: Aug 2005
Rep: 21

View Profile
Dec 26, 2009 5:20 AM #528708
onClipEvent(load){
moveSpeed=5;
}
on
ClipEvent(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

Posts: 164
Joined: Dec 2009
Rep: 10

View Profile
Dec 26, 2009 1:01 PM #528798
oh so you need like a right left top bottom wall crap.
Aycaramba
2

Posts: 766
Joined: Apr 2007
Rep: 10

View Profile
Dec 26, 2009 1:41 PM #528808
I don't think you can use the onEnterFrame function on an object more than once.
DarkCloud

Posts: 164
Joined: Dec 2009
Rep: 10

View Profile
Dec 26, 2009 1:58 PM #528810
oh I cant I didnt know that :Ohhhhh: .
slipe_rock

Posts: 1
Joined: Dec 2009
Rep: 10

View Profile
Dec 26, 2009 8:41 PM #528859
this site
makes me so very proud to be a member ^_^
WUOSA> ! ! ! ! ! ! !
DarkCloud

Posts: 164
Joined: Dec 2009
Rep: 10

View Profile
Dec 26, 2009 9:22 PM #528870
wtf who the hell are you...
Zero
2

Posts: 4,727
Joined: Aug 2009
Rep: 10

View Profile
Dec 27, 2009 5:07 AM #528956
Some kind of a begginer I think.
CGIllusion
2

Posts: 617
Joined: Aug 2005
Rep: 21

View Profile
Dec 27, 2009 5:49 AM #528961
Quote from slipe_rock

WUOSA> ! ! ! ! ! ! !


It's obviously Martin Lawrence...