-
I have hundreds of coloured squares which, when the user chooses one, the click sends data to another variable.
Each square is named uniquely. The tedious coding is to have:
on (release) {
myColor = new Color(p1s1);
rgb = myColor.getRGB();
}
Is there any way to make it assume the 'p1s1' bit so I don't have to have special code for every one of the x hundred squares? I've tried (blundered round) several This... variations but none worked.
Thanks...
www.bricksandbrass.co.uk
-
I have hundreds of coloured squares which, when the user chooses one, the click sends data to another variable.
Each square is named uniquely. The tedious coding is to have:
on (release) {
myColor = new Color(p1s1);
rgb = myColor.getRGB();
}
Is there any way to make it assume the 'p1s1' bit so I don't have to have special code for every one of the x hundred squares? I've tried (blundered round) several This... variations but none worked.
Thanks...
www.bricksandbrass.co.uk
-
how are you creating the squares? are they all done on the stage? or are they done by code? cuz if you create them via code (duplicating movie clips, then setting the colour of the squares), then you can name them dynamically. alternately, you can set their colour object on an enterframe using a loop. here's some pseudo-code:
myColor = new Array;
var i = 0;
var j = 0;
for i = 1 to x {
for j = 1 to y {
mySquare = "p" + i + "s" + j;
myColor[mySquare] = new Color(mySquare);
}
}
then you can use an on release to check the color of the square by using "mySquareColor = myColor[square_clip_name].getRGB;", which would work if you've named each square clip properly (like p1s1, p1s2, etc.)
hth
deep (just a guy)
hth,
Deep (just a guy)
<font face="arial" size="2">
Pradeep Kumar Nair, B.Math
Interactive Developer
http://www.bluespark.com
ICQ: 39102360
</font>