Groups | Blog | Home
all groups > flash actionscript > august 2004 >

flash actionscript : Help pls! HitTesting, for & movieclip vars



bernizt
8/14/2004 8:25:10 PM
onClipEvent (enterFrame) {
for (z=0; z<2; z+=1) {
current = "_root.p"+z+".statu"
if ((_root.player.hitTest("_root.p"+z)) && ("_root.p"+z+".statu" == "solid")) {
_root.player._y+=100
}
}
}

Well this is the code in my movieclip, what i'm trying to do is:
-Check every time if movieclip player from the main instance is hitTesting one
of the movieclips named p0,p1 ... (but in this case there are only this two
movieclips)
-In case player is hitTesting p0 or p1 AND the var "statu" in p0 or p1 is
"solid" move player's _y 100

Ok, I read the code and it should work but at the end, it doesn't.
I made this change only to test the code:

onClipEvent (enterFrame) {
for (z=0; z<2; z+=1) {
current = "_root.p"+z+".statu"
if ((_root.player.hitTest("_root.p"+z)) && (_root.p1.statu == "solid")) {
_root.player._y+=100
}
}
}

And it works, of course only in case "p1.statu" is "solid", so the problem
should be here. Can someone help me please?
Note: the var I especified as "current" can be erased
Can someone help me please?
kglad
8/14/2004 8:44:59 PM
"_root.p"+z+".statu" is a string. if you want flash to resolve that string into a variable you need to use bracket notation:

bernizt
8/14/2004 8:48:38 PM
kglad
8/14/2004 8:54:38 PM
AddThis Social Bookmark Button