Ask a Question related to Macromedia Flash Actionscript, Design and Development.
-
uncle_3than webforumsuser@macromedia.com #1
I wanna use Use array to make my life easier...help
I'm trying to make my bottons to do bunch of same thing over and over, and I have 4 buttons, I want them to be in an Array, here's what I originally wrote in a old fashioin say
ActionScript:
btn1.onRelease = function(){
trace("btn1 clicked");
}
btn2.onRelease = function(){
trace("btn2 clicked");
}
btn3.onRelease = function(){
trace("btn3 clicked");
}
btn4.onRelease = function(){
trace("btn4 clicked");
}
but now I want to try to put it in array
ActionScript:
myBtns = [btn1, btn2, btn3, btn4];
what I wanna do is to use this array and control my btns, like if myBtns[0] is click, the trace for btn and btn2-4 do somthing else, is there anyway that I can use if else statement to make one btn do one thing and other 3 btns do somthing else?..
somthing like:
ActionScript:
myBtns.onRelease = function(){
if(myBtn == 0){
do this
myBtn[1, 2, 3] do somthing else...
}
}
I know this example sucks but I just want to learn how to do this..thanks a lot for your help..
uncle_3than webforumsuser@macromedia.com Guest
-
MAKE MONEY EASIER
Autor: Carlos Data: 17-10-05 Si dedicas 5 minutos a leer este articulo completo, te darás cuenta de que es algo verdaderamente ingenioso y que... -
AN EASIER WAY TO MAKE MONEY!! IT REALLY WORKS!!
-- Ah An Easier Way To Make Money Post by Lisa Simmons July 6, 2005 @ 3:20 P.M. FIRST OF ALL, THIS IS NOT SPAM! THIS REALLY CAN MAKE YOU EASY... -
make array cell = array?
I want to make a 2D array quickly $item = an array with the associative names , , etc... I want to do: $items_array = $item $i++ -
Wanna buy a Cigar?....
Is this legal???? Or is our legs being pulled. "Infidel Castro" <gimme_info@sympatico.ca> wrote in message... -
how to make a global scope array
<20030725224852.1123.qmail@pb1.pair.com> Jack Lee: global $a; -
Jeckyl #2
Re: I wanna use Use array to make my life easier...help
something like this may work..
for (var x in myBtns) {
myBtns[x].onRelease = function() {
trace(this+" clicked");
}
}
the things that is making it tricky is that the script for the functions is
different for each function. That's not something you can directly code ..
that's why I changes your script a little so each button will use the same
script.
Jeckyl Guest
-
Matheus #3
Re: I wanna use Use array to make my life easier...help
You can use prototype too!
Button.prototype.onRelease = function() {
trace(this._name + " clicked);
}
"uncle_3than" <webforumsuser@macromedia.com> escreveu na mensagem
news:bvul9f$6lh$1@forums.macromedia.com...I have 4 buttons, I want them to be in an Array, here's what I originally> I'm trying to make my bottons to do bunch of same thing over and over, and
wrote in a old fashioin saymyBtns[0] is click, the trace for btn and btn2-4 do somthing else, is there>
> ActionScript:
> btn1.onRelease = function(){
> trace("btn1 clicked");
> }
> btn2.onRelease = function(){
> trace("btn2 clicked");
> }
> btn3.onRelease = function(){
> trace("btn3 clicked");
> }
> btn4.onRelease = function(){
> trace("btn4 clicked");
> }
>
>
>
>
> but now I want to try to put it in array
>
> ActionScript:
> myBtns = [btn1, btn2, btn3, btn4];
>
>
>
>
>
> what I wanna do is to use this array and control my btns, like if
anyway that I can use if else statement to make one btn do one thing and
other 3 btns do somthing else?..a lot for your help..>
> somthing like:
> ActionScript:
> myBtns.onRelease = function(){
> if(myBtn == 0){
> do this
> myBtn[1, 2, 3] do somthing else...
> }
> }
>
>
>
>
>
> I know this example sucks but I just want to learn how to do this..thanks>
>
>
Matheus Guest



Reply With Quote

