A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: if statements

  1. #1
    Member
    Join Date
    Feb 2002
    Posts
    67

    Thumbs up

    First off I have a button that when I roll over it it tells an mc to move to a certain location. What I want to know is if I have all ready rolled over it and the mc is in its other location, how would I tell that same button that if I rollover it and the mc is in that location not to do anything? Otherwise, if I roll over it again it jumps to the first frame and moves again, looks tacky...
    Any help would be great, thanks william

  2. #2
    Senior Member
    Join Date
    Jan 2001
    Posts
    472
    Well, you've figured out the logic to it, so work out some pseudocode:

    Code:
    on (rollOver) {
    	if (mc not at other location) {
    		mc.gotoAndPlay(other location)
    	}
    }
    Now, what frame number is the other location? Use that for your conditional:
    Code:
    on (rollOver) {
    	if (mc._currentframe != frame#) {
    		mc.gotoAndPlay(frame#)
    	}
    }
    --tyard
    http://www.27Bobs.com

  3. #3
    Junior Member
    Join Date
    Jun 2002
    Posts
    3
    williamwright,

    Scenario:
    Move an instance of a MovieClip one time only when rolling over a button.

    Main timeline contains one button and a MovieClip instance called "Sample".

    // Frame 1 code in main timeline
    // Let this variable signify the initial non-moved state
    var clipMoved = false;

    // Button code
    on (release) {
    if (clipMoved == false) {
    Sample._x = Math.random() * 550;
    Sample._y = Math.random() * 400;
    }
    clipMoved = true;
    }

    Now, in your code you would set the value of _x and _y to your liking. However, I deliberately randomized the values to illustrate a point. Comment out the clipMoved = true; statement in the button code and test the movie. You will see the random placement of Sample on the stage (the default stage size is 550x400) each time you click the button. Uncomment the clipMoved = true; statement and test the movie. The first time you click the button, Sample will be randomly placed on the stage, but each click thereafter will no longer affect the position of Sample.

    Good luck.


    Respectfully,

    ASP-ASP

  4. #4
    Member
    Join Date
    Feb 2002
    Posts
    67

    Beautiful

    Thats exactly what I wanted, but didn't know how to script it. Thanks for the help,Tyard. And as for ASP-ASP, I'm new to actionscripting and that sounds too complicated for me right now, but I will experiement w/ it anyway, because with playing comes wisdom

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