A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Variables - Text or Number?

  1. #1
    Junior Member
    Join Date
    Feb 2006
    Posts
    29

    Variables - Text or Number?

    Hi
    I'm trying to get a global variable to go to the next consecutive number (i.e. +1), but I'm not getting the basics.

    Here is my script:

    _root.whichflick = _root.whichflick + 1

    I am getting the text variable 11.

    Also is there a way to call a movie with a variable,

    which = 1
    _level.which.play()?

    Sorry in advance if I'm ahead of myself.

    Thanks!

  2. #2
    Senior Member Shotsy247's Avatar
    Join Date
    Apr 2001
    Location
    Be there in a minute!
    Posts
    1,386
    Try:

    _root.whichflick = Number(_root.whichflick) + 1;

    The problem seems to be that the orignal setting of whichflick was as a string otherwise you could use something like:

    _root.whichflick = 1; // to set the variable

    _root.whichflick++; //to increment the variable


    *edit

    To prevent variables that should be numbers from becoming strings and such you should use strong datatyping when creating your variables:

    code:
    //set a variable on the main timeline

    var whichFlick:Number = 1;

    //Now the variable whichFlick can only hold a number as a value. If it ever tries to hold a different value it will give you an error.



    _t
    Last edited by Shotsy247; 03-16-2006 at 01:54 PM.
    I don't feel tardy.

  3. #3
    Junior Member
    Join Date
    Feb 2006
    Posts
    29
    Thanks a lot. Do you know of a basic variable tutorial anywhere?

  4. #4
    Moderator enpstudios's Avatar
    Join Date
    Jun 2001
    Location
    Tampa, Fl.
    Posts
    11,282
    _global.whichflick= 1;
    whichflick ++;

  5. #5
    Senior Member Shotsy247's Avatar
    Join Date
    Apr 2001
    Location
    Be there in a minute!
    Posts
    1,386
    Quote Originally Posted by Lawnchair
    Thanks a lot. Do you know of a basic variable tutorial anywhere?
    Search the tutorials section of this site. I would imagine there is one there.

    _t
    I don't feel tardy.

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