A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: problem setting :String

  1. #1
    Pixel Artéést chriso20's Avatar
    Join Date
    Apr 2003
    Location
    Notts, UK
    Posts
    325

    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.

  2. #2
    All 1s and 0s dmonkey's Avatar
    Join Date
    Nov 2005
    Location
    Leeds, UK
    Posts
    606
    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

  3. #3
    Pixel Artéést chriso20's Avatar
    Join Date
    Apr 2003
    Location
    Notts, UK
    Posts
    325
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center