all groups > flash actionscript > october 2006 >
You're in the

flash actionscript

group:

Counting


Counting thejokerman05
10/14/2006 9:24:02 PM
flash actionscript:
How do I write this to load the appropriate image? I want to load the same
number as the button I click on. Now I have a trace action where the loading
should occur and that only show that I'm loading image number 15 all the time.
Anyone?



function hitButton(nbrID) {
btn = _root["btn"+nbrID];
btn.nbrID = nbrID;
btn.onRollOver = function() {
this.alphaTo(100, .5);
}
btn.onRollOut = function() {
this.alphaTo(30, .5);
}
btn.onRelease = function() {
trace (["bilder/" +i] + ".jpg");
btn1._alpha = 30;
btn1.enabled = true;
for (var i = 2; i<15; i++) {
_root["btn"+i]._alpha = 30;
_root["btn"+i].enabled = true;
this._alpha = 100;
this.enabled = false;
}
}
}

for (var i = 1; i<15; i++) {
_root.hitButton(i);
}
Re: Counting Star Tail Pro
10/14/2006 10:54:07 PM
the reason you get a5 is because of the for. When you press the button the for
has already worked its magic and is on 15. Maybe you should have the seprate
buttons that have on(load) {_root.hitButton(1);} ... I'm not sure that is
correct (it has been a while since I wrote code in a button or movieclip) or in
the frame btn.onLoad = function _root,hitButton(1);. Stupidly enough I'm not
even sure the a btn can have onLoad or even on(load).
Re: Counting kglad
10/15/2006 4:15:47 PM
try:



function hitButton(nbrID) {
btn = _root["btn"+nbrID];
btn.nbrID = nbrID;
btn.onRollOver = function() {
this.alphaTo(100, .5);
}
btn.onRollOut = function() {
this.alphaTo(30, .5);
}
btn.onRelease = function() {
trace (["bilder/" +this.nbrID] + ".jpg");
for (var i = 1; i<15; i++) {
_root["btn"+i]._alpha = 30;
_root["btn"+i].enabled = true;
}
this._alpha = 100;
this.enabled = false; }
}

for (var i = 1; i<15; i++) {
_root.hitButton(i);
}
AddThis Social Bookmark Button