For

I tried to shroten my code using a for statement but cant get it to exactly work when trying to use it with buttons…

[AS]
lnk0.onRelease = function() {
boxb._x = _root.lnk0._x;
_root.moviplay = “1”;
};
lnk1.onRelease = function() {
boxb._x = _root.lnk1._x;
_root.moviplay= “4”;
_root.flag = 1;
};
lnk2.onRelease = function() {
boxb._x = _root.lnk2._x;
_root.moviplay = “7”;
};

[/AS]

too
[AS]
framenum = new array(“1”, “4”, “7”)

for (j=0; j<3; j++) {
[“lnk”+j].onRelease = function() {
boxb._x = _root[“lnk”+j]._x;
_root.moviplay = framenum[j];
};
}
[/AS]

[“lnk”+j] won’t work.

If the code is on the same timeline as the clips use this[“lnk”+j] (that way its loadMovie compatible).

Also… inside the onRelease you have _root[“lnk”+j], you don’t need that, you can replace it with “this” (as in this._x).

Should work.

yeah, now you can load the swf into a MovieClip and the onRelease handler will be assigned to the Buttons/MovieClips.

however, there’s a problem…

_root.moviplay = framenum[j];

you’ll need to change that line to:

this._parent.moviplay = framenum[j];

but there’s still one problem… :stuck_out_tongue:

the value of the variable j, will be 3 after the script is executed, therefore framenum[j] will return undefined.

you have to save the value of j in a variable of each Button/MovieClip:

for (j=0; j<3; j++) {
this["lnk"+j].j = j;
}

in the end, you’d have this script:

framenum = new array("1", "4", "7");
for (j=0; j<3; j++) {
	this["lnk"+j].j = j;
	this["lnk"+j].onRelease = function() {
		boxb._x = this._x;
		this._parent.moviplay = framenum[this.j];
	};
}

=)

Very good catch… I didn’t examine that closely.

But I think I should take a break from the forum. My lack of ability to code recently is dampering my reputation on the forum… and giving me a headache as well… sigh… I can’t wait to get out of this funk :frowning:

nah… you will always be my hero. :love:

seriously, i agree with you, you need a break.
suddenly without a notice you’ll be coding like keith peters. :wink:

Originally posted by senocular
**lostinbeta is AWESOME and really knows his stuff! **
^ I hear the guy who said that knows what hes talking about to and can be trusted :wink:

LOL… thanks Kax and Sen… but seriously, I agree with what kax seriously agrees with about what I said… I just need to take a break… i’m fried right now :hangover:

But anywho… no more thread hijacking and just a lame attempt to get this back on course…

[AS]framenum = new array(“1”, “4”, “7”);[/AS]

Can also be written as…

[AS]framenum = [“1”, “4”, “7”];[/AS]

[edit]removed some stuff because I was being stupid[/edit]

ok well we need to think of a good quick rehab for lost because I know I cant make up for his lost time! Who can handle that much slack? No one!

how about a 5 min hot shower… with Mr Bubbles… and a rubber ducky… That should do it, right?

with mr bubbles and a rubber ducky!? :stuck_out_tongue:

yeah… that could work too. :stuck_out_tongue:

I don’t have any Mr. Bubbles and my rubber ducky drowndeded :(…lol. I think I just need a bit off from AS then when I come back just head first right back into it and try to learn something new in it. I want to get some books on AS too, but thats not going to happen for a while, so I mostly just gotta go from experimentation.

thanks lost and kax for fixing my mistakes

And lost, I wish I was half as good as you are in AS… but then again I suck

no problem, JuXtA. =)

no problem JuXtA :slight_smile: