A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: syntax for variable condition

Hybrid View

  1. #1
    Senior Member
    Join Date
    Nov 2000
    Posts
    251

    syntax for variable condition

    Flash MX 2004 Pro
    Actionscript 2

    Hi

    Ive got a generic button which is produced dynamically for various variables. I want all of these buttons to go to the same point in the timeline except for 1 button. So i need to be able to check the variables and if the variable is "quicklinks" then it goes to a different point on the timeline.

    I think i am making a mistake with my syntax in the variable recognition part straight after the if statement.

    if (sectionName+"Section_"+numberVar+"Var")=="quickli nks"{
    _root.gotoAndPlay("MAIN");
    }


    Im sure its a very simple correction required, like square brackets or something.

    Any suggestions?

    Many thanks

    M

  2. #2
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    that will never evaluate to true, the quoted bits are strings that dont appear in string your comparing it to.

    if
    code:

    sectionName = "gentilejews";
    numberVar = 10;



    then your example
    code:

    trace(sectionName+"Section_"+numberVar+"Var");



    would output
    code:

    gentilejewsSection_10Var



    you could try using a for..in loop, something like this
    code:

    for (everyobject in _root) {
    if (typeof (_root[everyobject]) == "object") {
    checkVariable(_root[everyobject]);
    }
    }
    function checkVariable(variablevalues) {
    if (variablevalues== "quicklinks") {
    _root.gotoAndPlay("MAIN");
    }
    }



    that's untested and probably butchered horribly but might get you started; there's a good help section on loops in the prog and on livedocs.

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