A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: [F8] Simple script issue

  1. #1
    Junior Member
    Join Date
    Mar 2008
    Posts
    5

    [F8] Simple script issue

    Code:
    on(release){
    	if(_root.system.command = "/openfile/v2-rocket"){
    		v2._visible = true;
    	} else {
    		_root.system.command = "/openfile/WrongCommand";
    		v2._visible = false;
    	}
    }
    Anyone see an error with this script?
    It seems to be ignoring the if command, and makes "v2" visible if the if command is correct or not.

  2. #2
    Senior Member dlowe93's Avatar
    Join Date
    Aug 2001
    Location
    Stumptown
    Posts
    621
    Quote Originally Posted by TonyScarface
    Code:
    on(release){
    	if(_root.system.command = "/openfile/v2-rocket"){
    		v2._visible = true;
    	} else {
    		_root.system.command = "/openfile/WrongCommand";
    		v2._visible = false;
    	}
    }
    Anyone see an error with this script?
    It seems to be ignoring the if command, and makes "v2" visible if the if command is correct or not.
    It's the old double equals trick ("==" vs. "=");

    You need to do this:

    PHP Code:
    on(release){
        if(
    _root.system.command == "/openfile/v2-rocket"){
            
    v2._visible true;
        } else {
            
    _root.system.command "/openfile/WrongCommand";
            
    v2._visible false;
        }

    By using a single equals sign you are setting the variable to the value, not comparing it.

    Hope this helps.

    d.
    dlowe93

  3. #3
    Junior Member
    Join Date
    Mar 2008
    Posts
    5
    Thanks for the reply =)
    The thing is, first I tried using "==" then just "=".
    When I use "==", the button doesn't reply at all.
    When I use "=" the button reacts, but it reacts no matter if the if command is correct or wrong.
    I've always used "==" , and this have never been an issue.

    Any advice?

  4. #4
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    add a trace to see if your logic/path is correct -

    on(release){
    trace(_root.system.command);
    }

  5. #5
    Junior Member
    Join Date
    Mar 2008
    Posts
    5
    <p align="left"></p>

    That's the response I got :S
    The thing is, ive got the same problem with all the if commands im using :S

  6. #6
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    and command is a dynamic textfield ?
    is this the variable name or the instance name ?
    make it the instance name only.


    on(release){
    trace(_root.system.command.text); // output = ?
    }

  7. #7
    Junior Member
    Join Date
    Mar 2008
    Posts
    5
    Aaaah... The one thing I didn't test was .text :P
    Thanks alot mate

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