View Poll Results: Was this post clear and to the point?
- Voters
- 1. You may not vote on this poll
-
Wait what? say that again....complete jibberish
-
i don't think u knwo what yoru talking about
-
you could clarify your post better
-
VERY CLEAR POST!
-
array and indexing movie clips
In the following code, the on1,on2,on3,on4,on5 are instance names given to 5 buttons. all five of the buttons ARE SUCCESFULLY responding to the Press1 function below.
Code:
var ONarray:Array=new Array("on1","on2","on3","on4","on5");
for (var i:uint; i < ONarray.length; i++) {
var ON:MovieClip=getChildByName(ONarray[i]) as MovieClip;
stop();
ON.buttonMode = true;
ON.addEventListener(MouseEvent.MOUSE_DOWN, Press1);
}
function Press1(e:MouseEvent):void{
"FUNCTION HERE"
}
The problem: when each button is clicked it needs to send out its number (i'm using binary sockets for that).
the problem is i dont' want to copy the code for each button (cause there's eventually gonna be nearly 200 buttons), so in my function, when the button is clicked, it needs to write two things: it's instance name, and the fact that it was pressed:
Code:
binarySocket.writeUTFBytes("ONarray[i]"+"Pressed");
when i try this i traced it and it says "undefined Pressed" when it should say something like "on3 Pressed"
when i trace just [i] by itself, it always comes out as the number 5....no matter which button is clicked.
any ideas? i think im really close. thanks for any advice
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|