-
Adding the values of 2 string variables together?
Hi,
Sorry I screwed up the title, I meant to call it "Convert a value to a variable".
Using CS3, AS2:
If I have a variable that's a string value = the name of another variable, can I extract the value and then look for the extracted value's matching variable name to get it's value?
Ex:
color = "blue"
box = "color"
(Assuming I don't know the value of box) How would I get the value of "box" out so I could search for the value "color" as if it were a variable? I need to convert a value to a variable name is what i'm getting at... I think. 
Thanks,
Spit
Last edited by SpitSpitSpitty; 08-23-2010 at 11:45 PM.
-
First of, do not use the name color for a variable, it is reserved. Let's use myColor instead:
myColor = "blue";
box = myColor;
therefore box has the value of "blue".
will give to box the value of myColor. Assuming the paths (or absence of) to these vars are correct.
gparis
-
Sorry, forgot about "color" as a variable. But though I understand what you posted, I put together a bad example in more than 1 way. Sorry.
I should have put into my question that the value is being put together in my code. I've pasted up my actual code:
Actionscript Code:
T254_MP3_1 = "25460414"; T254_MP3_2 = "25460423"; T254_MP3_3 = "25460428"; T254_MP3_4 = "25460431"; T254_MP3_5 = "25460441"; T254_MP3_6 = "25460457"; T254_MP3_7 = "25460535";
function CurrentMP3():Void { // mp3 T254_ = 1; while (T254_ <= 7) { if ("CH_254_" + T254_ == Indentifer) { T254_Value = "T254_MP3_" + T254_; _global.CurrentMP3_ = T254_Value ; trace(CurrentMP3_); } T254_ = T254_ + 1; } }
Right now "CurrentMP3_ " is coming out equal to "T254_MP3_" plus 1 - 7 depending on the button I'm clicking on, that I have set. But I need to convert that value to a variable, so it can find the correct name to load.
Thanks again,
Spit
-
_global.CurrentMP3_ = this["T254_MP3_"+T254_];
put the path first, here this, then brackets around the first characters of the variable's name in quotes (as a String) then append the variable which value varies.
gparis
-
It works perfect, Thanks!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|