PDA

View Full Version : parallax scrolling effect


atslopes
02-08-2005, 10:26 PM
Just ran across this cool site,

http://www.thepowerofallofus.com/flash.html

seems like they used parrallax scrolling does anyone know how to accomplish this in code or after effects.

By the way how are the rollovers done.

thanks in advance/

devonair
02-09-2005, 05:20 AM
hey, atslopes,

I put something together to answer a similar question in another forum.. This (http://www.onebyonedesign.com/junk/plax/parallax.html) is what I came up with.

Basically, you just want to move a forgeground movie clip at twice the speed of a background movieclip..

To get the mouse movement, I used a movieclip only 8 pixels wide (named scrollButton_mc) which I then scaled up to fill the entire stage.. the relative xmouse values, though, will remain -4 through 4 (therefore the background speed will range from -4 -4 and the foreground speed will be -8 - 8).. Here's the entire script:

stop();
scrollButton_mc._alpha = 0;
scrollButton_mc.useHandCursor = false;
// "fg" == "foreground"
// "bg" == "background"
// "lt" == "left"
var bgltStop:Number = -1500;
var fgltStop:Number = -900;
var bgSpeed:Number = 1;
var fgSpeed:Number = 2;
scrollButton_mc.onRollOver = function() {
bg_mc.onEnterFrame = function() {
this._x -= this._parent.scrollButton_mc._xmouse * bgSpeed;
if (this._x <= bgltStop) {
this._x = 0;
} else if (this._x > 0) {
this._x = bgltStop;
}
};
fg_mc.onEnterFrame = function() {
this._x -= this._parent.scrollButton_mc._xmouse * fgSpeed;
if (this._x <= fgltStop) {
this._x = 0;
} else if (this._x > 0) {
this._x = fgltStop;
}
};
};
scrollButton_mc.onRollOut = scrollButton_mc.onDragOut = scrollButton_mc.onRollOut = scrollButton_mc.onDragOut = function () {
delete bg_mc.onEnterFrame;
delete fg_mc.onEnterFrame;
};

Hope that helps out..

d.

atslopes
02-09-2005, 03:21 PM
followed ur code did exactly what you said but i got the following errors.

**Error** Scene=Scene 1, layer=actions2, frame=1:Line 12: Operator '=' must be followed by an operand
****bg_mc.onEnterFrame == function() {

**Error** Scene=Scene 1, layer=actions2, frame=1:Line 13: Syntax error.
********this._x -= this._parent.scrollButton_mc._xmouse * bgSpeed;

**Error** Scene=Scene 1, layer=actions2, frame=1:Line 14: Syntax error.
********if (this._x <= bgltStop) {

Total ActionScript Errors: 3 Reported Errors: 3

if you could help me fix this that would be great.thanks

devonair
02-09-2005, 05:29 PM
hmm. how's about a .fla? Never hurts.. lol..

http://www.onebyonedesign.com/junk/plax/parallax.zip

That may make it easier..

d.

atslopes
02-09-2005, 07:45 PM
u da man. thanks a million
never thought your were going to post of file, but hey dreams do come true.thanks

devonair
02-09-2005, 08:11 PM
glad it helped out..

chriskunz
06-14-2005, 10:50 PM
hello,

m a beginner in AS.

so my question is, is it possible to use this parallax scrolling

http://www.onebyonedesign.com/junk/plax/parallax.zip

with buttons insides the two seperated movie clips?

simply said, i want buttons in the parallaxplane.

thx in advance

jennymcc
02-09-2006, 07:45 PM
Any chance you could post this file again? I know it was a while ago, but this is just what I was looking for! Thanks!

devonair
02-11-2006, 09:05 PM
Hey, jennymcc,

the file's still available at http://www.onebyonedesign.com (where -> downloads)..

hope it helps out..

d.