Groups | Blog | Home
all groups > flash actionscript > may 2006 >

flash actionscript : I need a help


2m
5/31/2006 8:32:46 PM
i'd say:
_global.lig = 0;
for (var i = 11; i < 16; i++){
this["c"+i].onPress = function(){
++_global.lig;
if (lig >5) lig = 1;
var c = new Color(this);
c.setRGB(couleur[_global.lig]);
}

Assuming that I guessed right what you want to do.

The cricial part is to know that the on press function executes in the scope
of the issuing clip, therfore I used lobal on lig, assuming you want one lig
for all, if not, you could use this.lig to make things clearer.
Adressing the couleur array is also something that depends on the scope.

if all that is old news to you, may it is just the dot too much in your not
working code.
Dave
5/31/2006 9:58:48 PM
Hello

I would like to do that but with little line
I know it's not possible to do that
this.["c"+i+j].onPress =
function() {
do you have a good solution please

this.c11.onPress = function() {
++lig;
if (lig>5) lig=1;
var c:Color = new Color(c11) ;
trace(couleur[lig])
c.setRGB(couleur[lig]);
}
this.c12.onPress = function() {
++lig;
if (lig>5) lig=1;
var c:Color = new Color(c12) ;
c.setRGB(couleur[lig]);
}
this.c13.onPress = function() {
++lig;
if (lig>5) lig=1;
var c:Color = new Color(c13) ;
c.setRGB(couleur[lig]);
}
this.c14.onPress = function() {
++lig;
if (lig>5) lig=1;
var c:Color = new Color(c14) ;
c.setRGB(couleur[lig]);
}
this.c15.onPress = function() {
++lig;
if (lig>5) lig=1;
var c:Color = new Color(c15) ;
c.setRGB(couleur[lig]);
}

AddThis Social Bookmark Button