-
Sprite y based on mouse position?
So I'm working on my portfolio and I got this problem. The code posted scrolls the sprite "cellContainer" based on the position of stage.mouseY. Perfect.
Problem is that I want stage.mouseY to equal the entire cellContainer height. Kind of like how a small tablet equals a huge monitor. So when stage.mouseY = 0, cellContainer.y = 0 and when stage.mouseY = stage.stageHeight, cellContainer.y = stage.stageHeight - cellContainer.height. Right now, it scrolls, but it takes a while to scroll throught the entire height of cellContainer. I want it to be proportional to stage.mouseY.
Actionscript Code:
private function scrollStart(e:Event):void { cellContainer.y += Math.cos((-stage.mouseY/stage.stageHeight)*Math.PI) * 10;
if (cellContainer.y > 0) { cellContainer.y = 0; } if (-cellContainer.y>(cellContainer.height - stage.stageHeight)) { cellContainer.y = -(cellContainer.height - stage.stageHeight); } }
Any help would be appreciated! Thanks!
-
Here's a link to what I would it to resemble:
http://www.werkstette.dk
-
Okay, no one replied, but I figured it out. If anyone is interested, place this inside ENTER_FRAME:
Actionscript Code:
var containerY:Number = ((stage.mouseY * (stage.stageHeight - cellContainer.height))/stage.stageHeight); TweenLite.to(cellContainer, .5, {y:containerY});
-
Senior Member
No one replied, most likely, because this is the non-technical conversation only forum. Please only use the technical forums listed here for technical questions.
Also, do not put it in ENTER_FRAME. TweenLite has its own ENTER_FRAME event. By using ENTER_FRAME, you're having TweenLite reset itself over and over again, even if the mouse isn't moving. Instead, use MouseEvent.MOUSE_MOVE and make sure it's not checking for a mouse movement globally, but only within the bounds of the gallery preview images.
-
Mom said "make me a Mod"
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
|