-
Thumbnail scroll with mouseOver
First, I feel so guilty, Flash Kit community has helped me out SOOO much in the past, and I have not been able to contribute much to it.
But I am very grateful for this community.
Having said that I again need help with Actionscript 3 again.
What I am trying to do is the old thumbnail scroller that scrolles up and down or side ways using the mouse over.
And Unlike AS2 where I used the tween and "gotoNext" to play the animation. Wanted to try full actionscript.
So what I have is a movieclip with all the thumnails loaded and I can animate it using the ENTER_FRAME, but what I wanted to do was run the animation only when you mouse over it.
The ENTER_FRAME method:
addEventListener(Event.ENTER_FRAME, loop);
function loop(e:Event):void
{
if(scene.y <= 1 && scene.y >= -1016){
scene.y -= (mouseY - 100) * 0.1;
}
if(scene.y > 1) {scene.y = 1;}
if(scene.y < -1016) {scene.y = -1015;}
}
However, this method animates or scrolls all the time. I tried to convert this using the if statements of mouseY <= 200 && mouseY >=0
and calling the function on mouse over.
scene.addEventListener(MouseEvent.ROLL_OVER, loop);
But this will only move the thumbnails and once doesn't loop.
I tried searching the boards and through out internet and there doesn't seem to be any tutorials.
So if anyone can just even show me how you can have a loop animation when you do a mouseOver it would be a starting point for me.
And again. This community have helped me so much in the past I hope you guys can help me once more.
Thank you in advance.
-
For a up and down scroll:
my_Thumbnails.addEventListener(MouseEvent.MOUSE_MO VE, scrollThumbs);
function scrollThumbs(e:MouseEvent):void
{
my_Thumbnails.y += Math.sin((stage.mouseY / stage.stageHeight) * Math.PI) * 5;
// Changing that number (5) here will change the speed at which it scrolls
if (my_Thumbnails.y <= 0) my_Thumbnails.y = 0;
// Replace "0" with minimum Y value
if (my_Thumbnails.y >= 400) my_Thumbnails.y = 400;
// Replace "400" with maximum Y value
}
For a x scroller, change the first line in the function to:
my_Thumbnails.x += Math.cos((stage.mouseX / stage.stageWidth) * Math.PI) * 5;
And the mininum and maximum Y values to X values.
Let me know if that doesn't make sense.
-
Hey Beathoven,thanks for the help. I'll give it a shot.
I take it my_thumbnails would be my movie that contains all the thumbs...(that was a dumb question)
Thanks so much. I'll probably try it out tomorrow after some sleep but this is awsome.
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
|