A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: Controlling movieclip's ._x using button

  1. #1
    Junior Member
    Join Date
    Feb 2002
    Posts
    19

    Controlling movieclip's ._x using button

    Hi,

    I've delved back into flash after a couple of years and am tearing my hair out just trying to achieve basic things in actionscript.

    I'm currently trying to get a button to control the ._x position of a movieclip. I've had some success (please see attached file), but rather than moving continuously, the movieclip only moves once when the mouse rolls over the button.

    Can anyone help, please?
    Lily

  2. #2
    anyone else hear that? flashpipe1's Avatar
    Join Date
    Jan 2003
    Location
    Upstate NY
    Posts
    1,929
    attached file?

    sounds like you need to use an onEnterFrame that's called when the button is rolled over and delete it when it's rolled off...
    Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.

  3. #3
    Junior Member
    Join Date
    Feb 2002
    Posts
    19
    Hmmm - I'll try pasting the link in for the file again, sorry about that

    http://www.fortescueonline.co.uk/move.fla
    Lily

  4. #4
    anyone else hear that? flashpipe1's Avatar
    Join Date
    Jan 2003
    Location
    Upstate NY
    Posts
    1,929
    Yep, just change your script to this:

    Code:
    play_but.onRollOver = function() {
    	my_mc.onEnterFrame = function() {
    		this._x += 50;
    	};
    };
    play_but.onRollOut = function() {
    	delete my_mc.onEnterFrame;
    };
    Hope that helps!
    Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.

  5. #5
    Junior Member
    Join Date
    Feb 2002
    Posts
    19
    Excellent:*thank you :-)
    Lily

  6. #6
    Senior Member
    Join Date
    Aug 2006
    Posts
    322
    well guide flashpipe1

    I'm just adding some lines on your script. please don't mind


    play_but.onRollOver = function() {
    my_mc.onEnterFrame = function() {
    this._x += 10;
    };
    };
    play_but.onRollOut = function() {
    my_mc.onEnterFrame=function() {
    this._x -= 10;
    };
    };
    play_but.onPress = function() {
    delete my_mc.onEnterFrame;
    };

  7. #7
    Junior Member
    Join Date
    Feb 2002
    Posts
    19
    I have no problem with that at all :-)

    In fact, if you fancy helping me out with my current quest - which is to work out how to put the above code into an IF statement, I'd be most grateful.

    My first attempt: if my_mc._x +=< 0 then {

    Has had no success...

    Thanks again for your help
    Lily

  8. #8
    Senior Member
    Join Date
    Aug 2006
    Posts
    322
    test your my_mc in a x position greater and less than 0

    play_but.onRollOver = function() {
    if(my_mc._x <= 0){
    my_mc.onEnterFrame = function() {
    this._x += 10;
    }
    }
    }
    Last edited by marlopax; 01-07-2009 at 03:52 PM.

  9. #9
    Junior Member
    Join Date
    Feb 2002
    Posts
    19
    Thank you - I've now sussed it using the trace function :-)
    Last edited by lilymayhew; 01-08-2009 at 02:46 PM.
    Lily

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