A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Setting a Range Variable

  1. #1
    Member
    Join Date
    Feb 2006
    Posts
    37

    Setting a Range Variable

    I need to set a single variable to have more than one numeric values
    like
    i>=1 but i<=40
    I know I can do this with
    for (i=1; i<=40; i++){
    }
    but I want a better method than that
    Thanks for the help

    more info
    What I am trying to do is create a root variable that can simultaneously equal a range of numbers. But I cant use the for command because the variable it will assign will only be confined to those brackets and can only be pulled from code inside the brackets

  2. #2
    Senior Member
    Join Date
    Jun 2007
    Location
    Nottingham, England
    Posts
    203
    If I've understood you correctly..

    'for' is a loop, it can't set a variable as "a range of numbers". It's like a mathematical impossibility for a variable to equal a range of numbers. It just doesn't make sense. Perhaps an array is what you need?

    Like:
    PHP Code:
    var numArray newArray(1,2,3,4,5,6,7,8); 
    Then the variable numArray would be equal to 1,2,3,4,5,6,7,8.

    Also, a variable only exists within parentheses, or 'curly brackets' {}, if you declare it with 'var' within those brackets.

    Eg:
    PHP Code:
    function doSomething(){
    var 
    num 100
    var total 50
    return(num+total);

    In that example, the variables 'num' and 'total' only exist within the function. If I didn't use 'var', the variables would exist throughout the _root timeline.

    Perhaps explain yourself a little better and somebody might be able to help you. What do you need this for, a bit of background would help I think.

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