dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Is something wrong with my flash or am I really out of it today??

  1. #1
    Senior Member
    Join Date
    Jan 2004
    Location
    Canada
    Posts
    309

    Is something wrong with my flash or am I really out of it today??

    I need a simple if statement to check a variable and make the products MC move to that frame. I have done this type of thing thousands of times before! I have no idea what I am doing wrong today! lol. Did something change? What can you spot wrong in this code??

    Thanks to anyone that can help me sort this out!!

    Code:
    if (_root.sub_page == "") {
    	_root.products.gotoAndStop("pro-stock");
    } else if (_root.sub_page == "pro-stock") {
    	_root.products.gotoAndStop("pro-stock");
    } else if (_root.sub_page == "comp-xt") {
    	_root.products.gotoAndStop("comp-xt");
    } else if (_root.sub_page == "g-lite") {
    	_root.products.gotoAndStop("g-lite");
    }
    I've tried this both on the main project and on a new file to make sure nothing was broken with the main project file. Is something wrong with this code?

  2. #2
    Senior Member
    Join Date
    Sep 2007
    Location
    UK
    Posts
    194
    Not sure on the code above but have you thought about using a switch statement instead of a multiple if/else statement. It might be easier to manage....

    Just my two pence...

  3. #3

  4. #4
    Senior Member
    Join Date
    Nov 2005
    Location
    dante's inferno
    Posts
    904
    Like vinchenzison said, I would trace sub_page, if it equals null or undefined, your if statement will be skipped all together.

    you can aslo try switch, stated above:

    PHP Code:
    switch(_root.sub_page) {
        case 
    "pro-stock":
            
    _root.products.gotoAndStop("pro-stock");
            break;
        case 
    "comp-xt":
            
    _root.products.gotoAndStop("comp-xt");
            break;
        case 
    "g-lite":
            
    _root.products.gotoAndStop("g-lite");
            break;
        default:
            
    _root.products.gotoAndStop("pro-stock");
            break;    

    with the default, if sub_page equals anything else that is not specified in the case. it will default to the specified page.

    IMS

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