Jump to content
xisto Community
Sign in to follow this  

[flash Cs4] Button Acting As A Scroll With Mouse Event In As3?

Recommended Posts

Hi all! I'm new here, just found these forums on Google.

First of all, I want to appologise if there is some topics like this, but I searched whole forums and didn't find any
that finishes my problem.

Now the important one. As I stated in topic title, I need an AS3 code that's doing the thing. This is what I want to
accomplish. I have a MC(image) in the center of my screen, and have two buttons, one on right and one on left
side of that MC. I want to scroll (image is like a menu) that MC left or right on mouse events, down or over.
So, I just want to change MCs X value while holding mouse button on buttons or just hovering over them.
I have managed to do that, but it's only moving by one value I have entered after a mouse event.
Here's a piece of code I did.

buttonL1_btn.addEventListener(MouseEvent.MOUSE_OVER, buttonL1Pressed);

function buttonL1Pressed(event:MouseEvent):void{

var temp:int = 0;
var temp1:int = 0;
temp = paleta1_mc.x;
temp1 = temp - 5;
paleta1_mc.x = temp1;


I hope you understood me, and have a clue how to help me with this.

Thank you very much in advance!


Share this post

Link to post
Share on other sites

I think the problem is in this line:temp = paleta1_mc.x;the value of temp variable will be always equal to paleta1_mc.xMaybe if you use ENTER_FRAME event to increase that variable that will make the picture move.But you'll need to remove that event once the mose is up to stop the movement.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.