Hit Tests + Arrayed objects [Flash AS2]
Started by: Steyene | Replies: 5 | Views: 578 | Closed
SteyenePosts: 2,060
Joined: Apr 2006
Rep: 10
View Profile I have an array with objects in it called square+square_num. There are 15 of them in total, and I am trying to get a hit test for them. But it isn't working.
onClipEvent(enterFrame){
for(i=1;i<=15;i++){
if(this.hitTest(_root["square"+i])){
_root.sqaure_base.speed = 0;
}
else{
_root.sqaure_base.speed = 5;
}
}
}
That could is from the object that is being run into. Please help if you can or if more code is needed just say so.
Scorpioxxx2Posts: 1,454
Joined: Apr 2006
Rep: 10
View Profile onClipEvent(enterFrame){
for(i=1;i<=15;i++){
if(this.hitTest(_root.["square"+i])){
_root.square_base.speed = 0;
}
else{
_root.square_base.speed = 5;
}
}
}
Bolded the bits I changed. Just a '.' and spelling (I think)
Bonk2Posts: 2,778
Joined: Mar 2008
Rep: 10
View Profile Where does the square_num come in?
Scorpioxxx2Posts: 1,454
Joined: Apr 2006
Rep: 10
View Profile Where does the square_num come in?
He's using variable 'i' to represent the number of squares I think.
Rather Cheesy2Posts: 2,137
Joined: Apr 2007
Rep: 10
View Profile Yeah, Scorpio fixed the code as far as I can see. What you did was just typo's really, you missed a . on _root. and you miss-spelled square in the speed lines but the code I think you did correctly
SteyenePosts: 2,060
Joined: Apr 2006
Rep: 10
View Profile I fixed up the typos. But when I added the "." for the hit test part. It returned an error.
Edit:
Got it working, I needed to change the ["square"+i]'s speed not the base movie clips one >_>