|
-
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?
-
anyone else hear that?
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.
-
Hmmm - I'll try pasting the link in for the file again, sorry about that
http://www.fortescueonline.co.uk/move.fla
-
anyone else hear that?
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.
-
-
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;
};
-
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
-
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.
-
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|