A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: if > problem

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

    if > problem

    this is driving me crazy, hopefully you can help.

    the problem I have is if "myversion" equal 3.00 and "currentversion" equals 3.00 flash goes to frame 2. what am I doing wrong?

    Code:
    var myversion:Number = _root.updates.myversion.text;
    var currentversion:Number = _root.updates.currentversion.text;
    
    if(myversion >= currentversion){
    		   downloadlink.gotoAndStop(3);}
    else {
    if(myversion < currentversion){
    			downloadlink.gotoAndStop(2);}}

  2. #2
    Member
    Join Date
    Oct 2006
    Location
    Australia
    Posts
    56
    var myversion:Number = _root.updates.myversion.text;
    var currentversion:Number = _root.updates.currentversion.text;

    if(myversion >= currentversion){
    downloadlink.gotoAndStop(3);}
    else if(myversion < currentversion){
    downloadlink.gotoAndStop(2);
    }


    and if the mc called downloadlink is on the root timeline you should change
    it to

    if(myversion >= currentversion){
    downloadlink.gotoAndStop(3);}
    else if(myversion < currentversion){
    downloadlink.gotoAndStop(2);
    }

  3. #3
    Junior Member
    Join Date
    Feb 2006
    Posts
    14
    ok. i changed the code but am having the exact same problem.I can't get a function to work if the variables are the same/equal.

    new code:
    Code:
    var myversion:Number = _root.updates.myversion.text;
    var currentversion:Number = _root.updates.currentversion.text;
    
    if(myversion >= currentversion){
    		   downloadlink.gotoAndStop(3);}
    else if(myversion < currentversion){
    			downloadlink.gotoAndStop(2);}

  4. #4
    Member
    Join Date
    Oct 2006
    Location
    Australia
    Posts
    56
    try this.

    if(myversion == currentversion){
    downloadlink.gotoAndStop(3);}
    else if(myversion < currentversion){
    downloadlink.gotoAndStop(2);
    }


    oh!

    lol, i forgot to change that second code i posted in my last post ;P
    it should liik like this.

    if(myversion >= currentversion){
    _root,downloadlink.gotoAndStop(3);}
    else if(myversion < currentversion){
    _root.downloadlink.gotoAndStop(2);
    }

    and if the first and second dont work. try posting what you are trying to make and ill hav a look at it if you want ;P

  5. #5
    Junior Member
    Join Date
    Feb 2006
    Posts
    14
    well, this is weird because it works if i put the data in the field myself but when I retrieve the data from the server it does not work right. I made a new .fla with just the code I'm trying to get to work. It's attached. I'm perplexed
    Attached Files Attached Files

  6. #6
    Member
    Join Date
    Oct 2006
    Location
    Australia
    Posts
    56
    AAAHHHH!!!, i poked and prodded everything possible and cant get it working lol

    i tried changing else if to just else i traced every possible variable to make sure it was working properly

    sorry but i cant help :P

  7. #7
    Junior Member
    Join Date
    Feb 2006
    Posts
    14
    thanks for trying. someone told me that when retrieving data from external text file, flash makes it a string . So i need to convert it to number somehow, i guess. but i just can't get it...

  8. #8
    Junior Member
    Join Date
    Feb 2006
    Posts
    14
    someone helped me from another board. here is the fix:

    "getMinorVersion(...) takes your string data from text fields and convert them to ints, so you can then compare "apples to apples" (ints againts ints, like 0 againts 1 read from "3.00" and "3.01"),"

    Code:
    //
    function getMajorVersion(aVersion:String):Number {
        var majVersion:Number = parseInt(aVersion.substr(0, aVersion.indexOf(".")));
        return majVersion;
    }
    function getMinorVersion(aVersion:String):Number {
        var minVersion:Number = parseInt(aVersion.substr(aVersion.indexOf(".")+1));
        return minVersion;
    }
    //
    var myversion:Number = getMinorVersion(_root.updates.myversion.text);
    var currentversion:Number = getMinorVersion(_root.updates.currentversion.text);
    trace(myversion);
    trace(currentversion);
    if (myversion>=currentversion) {
        trace("up to date");
        downloadlink.gotoAndStop(3);
    } else if (myversion<currentversion) {
        trace("update required");
        downloadlink.gotoAndStop(2);
    }

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