-
Pixel Artéést
problem setting :String
Hey,
Here's my code;
Code:
eval("card"+movecard).card.command = [topbot+movecard+"to"+secondnum];
Can someone tell me why it comes up with an error when i put ;
Code:
eval("card"+movecard).card.command:String = [topbot+movecard+"to"+secondnum];
Reason i have to do this is because i'm setting the variable "command" to some text but i think it doesn't return as text when u do the eval/[] bracket thing.
Thanks for you help.
-
All 1s and 0s
Hi,
You can only use strict typing when you declare the variable using the 'var' statement. You can either declare a new variable and then copy it to the movieClip, like this:
code:
var shouldBeString:String = [topbot+movecard+"to"+secondnum]
(which by the way ISN'T a string, its an array because you used [] brackets,) or you can test to see if it's a string using the typeof operator:
code:
trace(typeof(eval("card"+movecard).card.command) == "string");
Hope this helps.
"If I have seen further, it is by standing on the shoulders of giants." - Sir Isaac Newton
-
Pixel Artéést
awesome, thank you.
Just so you know - i was over complicating it, i didn't need to put the last part in brackets, it should have been;
Code:
eval("card"+movecard).card.command = topbot+movecard+"to"+secondnum;
Thanks though!
Last edited by chriso20; 04-02-2006 at 07:19 AM.
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
|