Ask a Question related to Macromedia Flash Actionscript, Design and Development.
-
TeknoPhil webforumsuser@macromedia.com #1
create a dynamic variable
Hi !
i would like to know how to create a dynamic variable with flash.
I'm getting 2 strings from XML and would like to create a variable named with the first string and with the value of the second string ... something like this :
_root.myFirstString = mySecondString;
how can i do this?
Thanks a lot for your help!
TeknoPhil
[email]teknophil@__NO_SPAM__hotmail.com[/email]
TeknoPhil webforumsuser@macromedia.com Guest
-
Dynamic Where variable
I'm attempting to create a complete "Where" statement and save it to a variable. It works fine when comparing a numeric field against a number but... -
Create Variable
Hi, I wanted to ask, how can I for Simple Connection component, username text field, set a variable? Thanks Lanex:beer; -
Create custom CGI. variable
Does anyone know how I could create a variable that would appear in the #cgi# scope ? I have x number of coldfusion servers and on each one of... -
Dynamic Variable ... how can I ?
Hi ! I need to disabled some buttons. Here's some AWEFUL code I have : for (i=1996; i<=2004; i++) { if (_root.year_array == false) { if... -
create variable before redirection.
I'm trying to set a variable before redirection. Here is the code: //header("Location: /ManageProfile.php?UserID=".$id); echo("<input... -
Jack. webforumsuser@macromedia.com #2
Re: create a dynamic variable
str1 = "vari";
str2 = "ables";
this[str1] = str2;
trace(this[str1]);
/* Ctrl+Alt+V to List Variables (MX)
Variable _level0.str1a = "vari"
Variable _level0.str2a = "ables"
Variable _level0.vari = "ables"
*/
regards
Jack..
Jack. webforumsuser@macromedia.com Guest
-
TeknoPhil webforumsuser@macromedia.com #3
Re: create a dynamic variable
Thanks for this VERY quick response Jack!
TeknoPhil
[email]teknophil@__NO_SPAM__hotmail.com[/email]
TeknoPhil webforumsuser@macromedia.com Guest
-
TeknoPhil webforumsuser@macromedia.com #4
Re: create a dynamic variable
something else ;)
if i want to add a string to my variable name ... ?
example :
string1 = "joe"
string2 = "blow"
like add a "a" so my variable name is "ajoe"
thanks a lot
TeknoPhil
[email]teknophil@__NO_SPAM__hotmail.com[/email]
TeknoPhil webforumsuser@macromedia.com Guest
-
Jack. webforumsuser@macromedia.com #5
Re: create a dynamic variable
str1 = "vari";
str2 = "ables";
this["a"+str1] = str2;
/*
Variable _level0.str1 = "vari"
Variable _level0.str2 = "ables"
Variable _level0.avari = "ables"
*/
regards
Jack..
Jack. webforumsuser@macromedia.com Guest
-
TeknoPhil webforumsuser@macromedia.com #6
Re: create a dynamic variable
actually i would likw to get something like this :
str1 = "vari";
str2 = "ables";
so
a_vari = ables
i tried your solution :
this["a_"+str1] = str2;
but it's still give me this :
vari = ables
thanks
TeknoPhil
[email]teknophil@__NO_SPAM__hotmail.com[/email]
TeknoPhil webforumsuser@macromedia.com Guest
-
Jack. webforumsuser@macromedia.com #7
Re: create a dynamic variable
how are you checking your returned variable ?
i have this code -
str1 = "vari";
str2 = "ables";
this["a_"+str1] = str2;
on the main timeline i have a dynamic text field
it has a variable name of - a_vari,
the textfield displays "ables" and listing the variables returns -
Variable _level0.str1 = "vari"
Variable _level0.str2 = "ables"
Variable _level0.a_vari = "ables"
Edit Text: Target="_level0.instance1"
variable = "a_vari",
text = "ables",
regards
Jack..
Jack. webforumsuser@macromedia.com Guest
-
TeknoPhil webforumsuser@macromedia.com #8
Re: create a dynamic variable
I'm using this in a function ... if i trace right after my declaration, everything is fine.
But my problem is that this movie is loaded from another one ... and I want to be able to play this movie alone OR from another movie (loaded in a movie clip) so I was wondering if I can declare the dynamic variable directly on _root ...
Thanks a lot for you help!
TeknoPhil
[email]teknophil@__NO_SPAM__hotmail.com[/email]
TeknoPhil webforumsuser@macromedia.com Guest
-
Jack. webforumsuser@macromedia.com #9
Re: create a dynamic variable
in sub.swf -
str1 = "vari";
str2 = "ables";
this["a_"+str1] = str2;
/* run alone would output
Variable _level0.str1 = "vari"
Variable _level0.str2 = "ables"
Variable _level0.a_vari = "ables"
*/
if loading sub.swf into a movieclip instance - loader that resides in the main movie,
loader.loadMovie("sub.swf");
/* this is the expected result
Movie Clip: Target="_level0.loader"
Variable _level0.loader.str1 = "vari"
Variable _level0.loader.str2 = "ables"
Variable _level0.loader.a_vari = "ables"
*/
if you load to a level,
loadMovieNum("sub.swf",1);
/* the variable in sub.swf remains on its own level
Level #0:
Variable _level0.$version
Level #1:
Variable _level1.$version
Variable _level1.str1 = "vari"
Variable _level1.str2 = "ables"
Variable _level1.a_vari = "ables"
*/
i suggest you make more use of List Variables, (Ctrl+Alt+V shortcut)
most of the answers to all kinds of problem hide there :)
regards
Jack..
Jack. webforumsuser@macromedia.com Guest
-
Vayapues #10
Re: create a dynamic variable
Is the opposite also possible. If not, how would I do it?
example:
var = this["string"+var2+"string"];
Essentially, I need to set var to the value of a second variable. The name of
the second variable will change depending on other factors, and is being
accessed via a while loop.
totalLoops=5;
i=1;
while (i <= totalLoops){
ItemType = this["_root.Item"+i+"Type"];
if (ThisNum==count){
if (_root.ItemType=="Options2"){
gotoAndStop ("item");
}else if (_root.ItemType=="false"){
gotoAndStop ("false");
}else if (_root.ItemType=="drink"){
gotoAndStop ("drink");
}else {
Menu1.ItemName = _root.ItemName1;
Menu1.ItemDescription = _root.ItemDescription1;
Menu1.ItemPrice14 = _root.ItemPrice14One;
Menu1.ItemPrice16 = _root.ItemPrice16One;
Menu1.ItemPrice18 = _root.ItemPrice18One;
}
}
i++;
}
Vayapues Guest



Reply With Quote

