-
MindGem Graphics Inc.
Extracting numeric values from concats
Yo.
Is there a way to extract a numeric value from my variable using concatination.
var i:Number = 1;
var test1value:Number = 3;
trace(this["test"+i+"value"]);
I tried all kinds of tricks but I just can get the string name of the variable instead of the value it holds.
Anyone?
-
Registered User
hi,
I don't understand the "extract" part.
Would it be just
Actionscript Code:
var i:Number = 1; var test1value:Number = 3;
trace("test"+i+"value");
If not, provide more details please.
-
MindGem Graphics Inc.
"extract" is just my fancy name for getting the value the variable holds.
However,
trace("test"+i+"value");
and trace(this["test"+i+"value"]);
gives the same result, the name of the variable and not the number. Can you think of a way to get the value of the variable out?
-
Registered User
Actionscript Code:
var i:Number = 1; var test1value:Number = 3;
trace(this["test"+i+"value"]); // 3 trace("test"+i+"value"); // test1value
They don't give the same result.
The first evaluates the string and gives the value the variable hold: 3 (number)
The second concatenates the string and gives it: test1value (string)
-
Senior Member
is the variable test1value in your situation actually a property of "this"?
this["test"+1+"value"] == this.test1value
try creating the variable in your class variable definitions, or in a dynamic class (or a frame script) specify it as this.test1value=3 instead of scoping it locally with var test1value=3.
-
MindGem Graphics Inc.
Doh!
this["test"+1+"value"] worked.
and I have that in my snippet and still it doesnt work when I do it.
So it gotta be something else.
I guess you get codeblind after a while, I'll keep searching bugs.
thx.
-
Registered User
-
I think there is no revers script to get the variable name.
var x=100;
If you provide x, you will get 100.
But if you provide 100 and ask for x, you will not.
But there should be something.
Hope for the best...
Is that you are talking about?
MarlöPax
Last edited by marlopax; 10-09-2010 at 05:25 PM.
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
|