PDA

View Full Version : Using An Array With Buttons



tomyknoker
03-27-2007, 05:02 AM
I have six buttons on my stage and whichever one is pressed send the playhead to the framelabel respectively, this is the code



numOfBtn = 6;
stop();
for (i=0; i<numOfBtn+1; i++) {
this["btn"+i].num = i;
this["btn"+i].onRelease = function() {
gotoAndStop("frm"+(this.num+1));
};
}


But before it goes to the framelabel I want the playhead to play first and THEN go to the framelabel... Any ideas? Should I remove this line gotoAndStop("frm"+(this.num+1)); and add it further down the playhead? It doesn't seem to work

Medyman
03-27-2007, 07:04 AM
I have six buttons on my stage and whichever one is pressed send the playhead to the framelabel respectively, this is the code



numOfBtn = 6;
stop();
for (i=0; i<numOfBtn+1; i++) {
this["btn"+i].num = i;
this["btn"+i].onRelease = function() {
gotoAndStop("frm"+(this.num+1));
};
}


But before it goes to the framelabel I want the playhead to play first and THEN go to the framelabel... Any ideas? Should I remove this line gotoAndStop("frm"+(this.num+1)); and add it further down the playhead? It doesn't seem to work


the not-so-clean way of doing it would be to play the playhead at the beginning of each framelabel (i.e. add the playhead play action to the framelabel frame)


another (half-baked) suggestion is to use somethine equivalant
to the onMotionfinished(); method with Tweens. Not sure what that would be though.

BliZZard seems to be MIA or else I'm sure he'd know.