Parallax
- Started
- Last post
- 18 Responses
- Haydesign
Yo,
I'm doing a site using this parallax effect..... http://dev.askoki.co.uk/default.…
Its all done but does anyone know what actionscript is required to pause the whole rolling effect when the mouse leaves the flash area?Cheers.
- Haydesign0
not sure?
- Haydesign0
I was told people here were useless but i didn't believe them. You all gonna stand for that?
- detritus0
Ooh, reverse-psychology?
I know jack about flash, but wouldn't you modify the same event handler that takes your mouse position and feeds it to the parallax mechanic and tell it to 'not move anything' when the values are outside the movie?
If you want some useful help, I'd suggest you describe exactly how you've achieved your parallax effect - I can think of a couple of different was of achieving that, which leaves your question painfully open.
- flashbender0
your best bet is to use a time interval function that checks the x/y position of the mouse and if it returns null, then stop the scrolling effect.
I have not used this, but apparently it is quite easy is AS3:
- Haydesign0
Thanks guys here is the code for the left & right movement. I suppose its some sort of mouse out handler I need in there. But my skills are weak!
function parallax (layer, speed)
{
var distance=_root._xmouse-Stage.wid...if (_xmouse > Stage.width/2){
layer._x -= distance*speed;}else{
layer._x += distance*-speed;
}if(layer._x = layer._width/2){
layer._x = layer._x - layer._width/2;
}
}trees_mc.onEnterFrame = function() { parallax(this, 1/15);}
lane_mc.onEnterFrame = function() { parallax(this, 1/30); }
city_mc.onEnterFrame = function() { parallax(this, 1/50); }
sky_mc.onEnterFrame = function() { parallax(this, 1/70); }
- ********0
flash can't tell if the mouse isn't on flash. If the mouse leaves the flash area, it leaves the mouse at the last-tracked position.
SO
just check the mouse position with a timer, if the mouse is in the same spot for 10 iterations or whatever, then power down the math formula that makes it move.
- ********0
flash can't tell if the mouse isn't on flash. If the mouse leaves the flash area, it leaves the mouse at the last-tracked position......
j_red
(Nov 1 07, 07:38)....with AS2. AS3 you can track that now...
- ********0
thats not a great solution j_red as you might just simply be holding the mouse still to the right to scroll continuously.
You should set up a dead area within the flash around the area that scrolls, and if your mouse is within that area, stop the movement.
- Haydesign0
Thanks j_red & skt. I didn't actually understood any of what j_red wrote but appreciate the help.
Skts solution sounds doable. How do you create a "dead area" mate?
- rafalski0
You should set up a dead area within the flash around the area that scrolls, and if your mouse is within that area, stop the movement.
skt
(Nov 1 07, 07:42)Something along the lines of
if (_root._xmouse > a && _root._xmouse < b && _root._ymouse > c && _root._ymouse < d && )
inserted into each onEnterFrame definition before parallax call should do the trick
- Haydesign0
Thanks raf. That was a little over my head but looks like a good solution.
If my flash file is 880 x 267 what are those values now? Noob alert!
if (_root._xmouse > a && _root._xmouse < b && _root._ymouse > c && _root._ymouse < d && )
- rafalski0
I guess some near-border, ie. a=2,b=878,c=2,d=265
and lose the final &&, that's my typo from copy&paste :)
not sure if all that will work though, heh
- Haydesign0
one more thing raf.
where in this code...
trees_mc.onEnterFrame = function() { parallax(this, 1/15);}
do i put this...
if (_root._xmouse > 2 _root._xmouse < 878 _root._ymouse > 2 _root._ymouse < 265 )
- flashbender0
That is a simplified version of something I found here:
http://www.actionscript.org/foru…Things you need to change - the stage height/width is hard coded as 550 and 400, change that to suit your size.
The
- Haydesign0
Amazing!
Thank you guys especially
Raf & Blender.Much love.
- rafalski0
Just curious, did the thing I emailed yesterday work for you?
- Haydesign0
Raf, I emailed you back.
Yes, that was genius and it works like a dream.I had to increase the “dead area” to get it to recognise the mouse out properly everytime but its great!
Cheers buddy.
- rafalski0
No problem dude, anything to keep the nt crowd usefulness hype alive ;)