A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Need help with If statement, and _currentframe

  1. #1

    Need help with If statement, and _currentframe

    Thanks to this forum i've managed to get this code to work:

    Code:
    on (press) {
    	if (_root.leftAnimal._currentframe != "snake" && _root.rightAnimal._currentframe != "monekey") {
    		_root.leftAnimal.gotoAndStop(1);
    		_root.rightAnimal.gotoAndStop(1);
    		_root.animal.splicedAnimal.gotoAndStop("snakeMonkey");
    		_root.animal.gotoAndPlay("go");
    }}
    BUT when I put an else in the first statement continues to work.

    Code:
    on (press) {
    	if (_root.leftAnimal._currentframe != "snake" && _root.rightAnimal._currentframe != "monekey") {
    		_root.leftAnimal.gotoAndStop(1);
    		_root.rightAnimal.gotoAndStop(1);
    		_root.animal.splicedAnimal.gotoAndStop("snakeMonkey");
    		_root.animal.gotoAndPlay("go");
    	} else {
    		_root.leftAnimal.gotoAndStop(1);
    		_root.rightAnimal.gotoAndStop(1);
    		_root.animal.gotoAndStop("fail");
    		}
    }

    I'm probably missing something really obvious but the code reports no errors so I'm going a bit mad staring at it.

    Does anyone know why it doesn't want to do the else statement?
    Thankyou very much in advance!!

    Fran

  2. #2
    Actually it seems to be ignoring the 'if' and the 'else'. It's like this code:

    Code:
    on (press) {
    	if (_root.left.animal._currentframe != "snake" && _root.right.animal._currentframe != "monekey") {
    		_root.left.gotoAndPlay("go");
    		_root.right.gotoAndPlay("go");
    		_root.animal.splicedAnimal.gotoAndStop("snakeMonkey");
    		_root.animal.gotoAndPlay("go");
    	} else {
    		_root.leftAnimal.gotoAndStop(1);
    		_root.rightAnimal.gotoAndStop(1);
    		_root.animal.gotoAndStop("fail");
    	}
    }
    is just...

    Code:
    on (press) {
    	_root.left.gotoAndPlay("go");
    	_root.right.gotoAndPlay("go");
    	_root.animal.splicedAnimal.gotoAndStop("snakeMonkey");
    	_root.animal.gotoAndPlay("go");
    }
    I'm so confused...I'd understand if there were errors but it reports none

    Can anyone see where i'm going wrong?
    Thanks!!

  3. #3
    Ha ha! Figured it out! I needed to use frame numbers instead of names!

  4. #4
    Oh and i needed to use a double == instead of !=

    Hope my findings can help other people

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