Flash Vista - ˹ÑÒáá
àÇçºãËÁèÅèÒÊØ´
The Two Tales
à¡ÕèºÂǡѺàÇçºä«·ì | Archive
á¹ÇÔࡪÑè¹ËÅÑ¡
˹ÑÒáá
ÅÔ駤ìÁÒãËÁè
¤Ðá¹¹ÊØ´ÊØ´
¹ÔÂÁ·ÕèÊØ´
àÅ×Í¡â´ÂºÃóҸԡÒÃ
¤é¹ËÒ

º·àÃÕ¹á¿Åª
áËÅè§¢éÍÁÙÅá¿Åª
¢èÒÇ Flash
á¿Åªà·Áà¾Å·
á¿Åªà·Áà¾Å·ÍÔ¹â·Ã
Website Templates
á¿Åªà¡ÁÊì
˹ѧÊ×Íá¿Åª
FlashVista â¾ÅÊì
Sitemap


ÊØèÁÅÔ§¡ì
EnglishJapanese
Intentionallies
à¡ÕèºÂǡѺàÇçºä«·ì | Get another
FlashVista
à¢éÒÊÙèÃкº
ÊÁѤÃà»ç¹ÊÁÒªÔ¡
ÊÁѤÃÃѺ¨´ËÁÒ¢èÒÇ

à¾ÔèÁÅÔ駤ì
á¡éä¢ÅÔ駤ì
ÃÒ¡ÒÃâ»Ã´
á¹Ð¹ÓËÁÇ´

â¦É³Ò¡ÑºàÃÒ
ʹѺʹعàÃÒ
Credits / Thanks
µÔ´µè͡ѺàÃÒ

Flash Templates:

More Templates ...

ÃѺ¨´ËÁÒ¢èÒÇ
¼Ùéãªé

ÃËÑ´¼èÒ¹



ÊÁѤÃà»ç¹ÊÁÒªÔ¡
Å×ÁÃËÑʼèÒ¹?
Partner websites
Free Hit Counter
Free Seo Tools
Free Tutorials
Free Video Tutorials
Forum signatures
Best Free Scripts
Wii Fit
Wii Fit News
Cool Tech Gadgets
Other Resources
á¹Ð¹Ó
á¹Ð¹ÓàǺ¹ÕéãËéà¾×è͹


ÃѺ¨´ËÁÒ¢èÒÇ
ʶҹÐ: äÁèä´éà¢éÒÊÙèÃкº

Thai English German French Spanish Italian Portuguese Russian Polish Finnish Dutch Swedish Thai Romanian Traditional Chinese Simplified Chinese
¤é¹ËÒäÁèä´éà¢éÒÊÙèÃкº
¤Ó¤é¹: ÊÔè§·Õè¤é¹ËÒ: ¤é¹ËÒẺ¡Ó˹´à§×è͹ä¢


Variable variables in Flash actionscript


NEW Flash Tutorials in Video Format - Powered by LearnFlash.com: 45 minutes of flash tutorials now available in streaming format or download. Topics Include flash for beginners, text effects, actionscripting, audio/video, flash 8 and more.


Printer version



by Mirza Hatipovic

I often make use of variable variables, because I generally use interpreted languages like PHP. Variable variables are not supported in compiled languages like C++ etc. The same applies for Actionscript. Because I make extensive use of variable variables in PHP, I had some difficulties solving specific problems in Actionscript. Fortunately I found a trick to solve my problem. But before I show you the sample script I will give a short introduction to variable variables in PHP.

Sample PHP script:

//my_var has a string value of “mirza”
$my_var = “mirza”;
//allocate a variable variable of the variable $my_var
$$my_var = 1;
//the upper line of code now has the same meaning like $mirza = 1; !!!


In words, with variable variables you can dynamicaly create variable names and give them values!!!

Now on to Actionscript...

With eval() you can achieve similar results in AS.


//my_var has a string value of “mirza”
my_var = “mirza”;
//allocate a variable variable of the variable my_var
mirza = 1;
//has a value of 1
trace(eval(my_var));

Well, I know that this looks very strange. But I use this method in loops to dynamically create variables like pic1, pic2, pic3.

for(i = 1; i<=5; i++){
//current variable
curr_var = eval(pic + '' + i);
//handle variable…pic1, pic1, etc
}


Hope you’ll find it usefull.


(à¾ÔèÁä»áÅéÇ: 11-04-2003, ÎÔµ: 0, ¤Ðá¹¹: 2.78, âËÇ´: 32, ¤ÓÇÔ¨Òóì: 4)
à¾ÔèÁã¹ÃÒ¡ÒÃâ»Ã´ á¹Ð¹ÓãËéà¾×è͹

¤ÓÇÔ¨Òóì: (4)

Good Tutorial
(à¾ÔèÁä»áÅéÇ: 12-20-2005 ¼Ùéãªé: Guest)

But it is very usefull if you want to insert arrays into flash with javascript which you can't do directly. But if you set each var like: array[1] => array1 then you can use this function to get your original array back.
(à¾ÔèÁä»áÅéÇ: 02-19-2005 ¼Ùéãªé: Guest)


for(i = 1; i<=5; i++){
//current variable
curr_var = eval(pic + '' + i); _root.addProperty("pic" + i, get, set);
//handle variable…pic1, pic1, etc
setProperty("_root.pic" + i, value, "Value: " + i);
}

//===>

for (i = 1; i<= 5; i++) {
trace(eval("_roo.pic" + i));
}

(à¾ÔèÁä»áÅéÇ: 02-04-2005 ¼Ùéãªé: Guest)

Much as this tutorial offers useful advice, it is very bad programming practise to do what is done above.

Use arrays instead. Eval was put in actionscript before arrays were put in. Between arrays and ["property"] eval is practially useless. It is only needed in advanced techniques.

(à¾ÔèÁä»áÅéÇ: 05-25-2004 ¼Ùéãªé: Guest)


à¢Õ¹¤ÓÇÔ¨Òóì
Please note:
We review EVERY comment before it appears on the site, so please dont waste your time by posting spam links :)
No URLs allowed, no HTML please.

If you register or login first, your review will contain your nickname


ãËé¤Ðá¹¹



´Õ·ÕèÊØ´
´ÕÁÒ¡
´Õ
¾Íä´é
äÁè´Õ,äÁèÊÁºÙóì