-
scrolling an image with AS
Hey guys
so i have found some code that i have used and adapted into my own project The script allows the user to scroll about an image along the x axis.
what i was curious about changing was the area that it scrolls, the image i am scrolling along is 1300pixels wide and at the moment it scrolls much further along the x axis reveling the movies black background.
on the movies maintime line on frame 1 i have
fscommand("allowscale", "false");
stop();
var mainVar = 0;
then applied to the movieclip of the actual image i am scrolling in relation to the users cursor i have:
onClipEvent (enterFrame) {
if (_root.mainVar == 0) {
homeX = (-_root._xmouse)+700;
} else {
homeX = (-_root.mainVar)+700;
}
thisX = _x;
diffX = homeX-thisX;
if (_root.mainVar == 0) {
moveX = diffX/30;
} else {
moveX = diffX/5;
}
_x = thisX+moveX;
}
thats all of it.
you can also have alook at my FLA here if you can help or are curious
www.arterrastudios.com/matt/scroll.fla
so yeah, i want to limit the image to only scroll the size of the image wich is 1300 wide.
Thanks alot for your time, i hope someone can shed some light for me!
Matt
Last edited by design_pain; 03-30-2006 at 02:37 AM.
-
-
-
anyone else hear that?
Here you go!
The first thing you have to do is center your graphic in the movieClip. Then, basically, since you changed the size of the graphic, you now want to move your graphic from an _x of 0 to an _x of 400 and make that inversely proportional to the mouse, and also make it stay within your 800 pixel wide stage (the math would be easier if the stage was 607 pixels...half your image size). So, the code (broken down to...just the essentials) is:
homeX = ((-_root._xmouse*.5)+607);
thisX = _x;
diffX = (homeX-thisX);
moveX = diffX/30;
_x = (thisX)+(moveX);
Hope that helps!!
Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.
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
|