PDA

View Full Version : "Pan" question...



fruityDJ
November 7th, 2005, 06:53 AM
first have a look here:
http://www.marinapenno.com

i would like to know a start point on how to acheive a "pan" navigation like that BUT just left & right pan (horizontal , not allowing to go up & down).

any idea & guide will be great

40Unregistered
November 7th, 2005, 10:38 AM
this is not exactly that u looking for, but it'll enlight you
i recreated pan fx of www.gorillaz.com.
the result is infinite panning (http://www.geocities.com/situsindo/gorillaz.html)

here is the trick:
create new document: 300x 150 px
create a mc that you want to pan (in this case i named it, instance name: "gorila1"). its height is 200 px.
copy paste "gorila1" and place it in the right after gorila1, name it: "gorila2". this will create infinite panning.
create new layer, create an invisible button as big as stage (its for mouse event), name it "tombol_mc"
masking mc and button layers. the mask is cover all over stage.
create new layer, an action layer.
fill this actionscript into it:



lebar = 310;//stage width
tinggi = 150;//stage height
speed = 0.1;//higher speed is faster but ugly. 0.1 or 0.2 is good enough.
gorila1._y = -25;//mc gorila1 height is 200. it has 50 px off stage, 25 at top, 25 at bottom. this will create tilt up and down fx.
gorila2._y = -25;
tengahx = lebar/2;// x mid point. no slide here.
tengahy = tinggi/2;// y mid point. no slide here.
atas = 30; //button's top area. slide dow while mouse over the area
bawah = 120;//bottom area
anchorx = gorila1._width;//start position of gorila2 mc is the end of gorila1 mc
gorila1._x = 0;
gorila2._x = (0-anchorx);//starting position of gorila2 is following the anchor


// sliding function

function geser() {
gorila1.onEnterFrame = function() {
if (_xmouse != tengahx) {
if (_xmouse<tengahx) {
geseranx = Math.abs(_xmouse-tengahx)*speed;

if (gorila1._x>lebar || gorila2._x>lebar) {
if (gorila1._x>lebar) {
gorila1._x = (gorila2._x-anchorx);
} else {
gorila2._x = (gorila1._x-anchorx);
}
gorila1._x += geseranx;
gorila2._x += geseranx;
} else {
gorila1._x += geseranx;
gorila2._x += geseranx;
}
//
} else {
geseranx = Math.abs(_xmouse-tengahx)*speed;
if (gorila1._x<(0-anchorx) || gorila2._x<(0-anchorx))

{
if (gorila1._x<(0-anchorx)) {
trace("ini mc gorila1");
gorila1._x = (gorila2._x+anchorx);
} else {
trace("ini mc gorila2");
gorila2._x = (gorila1._x+anchorx);
gorila1._x -= geseranx;
gorila2._x -= geseranx;
}
} else {
gorila1._x -= geseranx;
gorila2._x -= geseranx;
}
}
}

if (_ymouse<atas) {
geserany = Math.abs(atas-_ymouse)*speed;
if (gorila1._y >= 0 || gorila2._y >=0) {
gorila1._y = 0;
gorila2._y = 0;
}
gorila1._y += geserany;
gorila2._y += geserany;
}
else if (_ymouse>bawah) {
geserany = Math.abs(bawah-_ymouse)*speed;
if (gorila1._y <= -50 || gorila2._y <=-50) {
gorila1._y = -50;
gorila2._y = -50;
}
gorila1._y -= geserany;
gorila2._y -= geserany;
}
else {
gorila1._y = gorila1._y;
gorila2._y = gorila2._y;
}


}
}

tombol_mc.onRollOver = function() {
geser();
}

tombol_mc.onRollOut = function() {
delete gorila1.onEnterFrame;
}


i hope this help

edit* if u like only left n right pan, just remove the "_y" part of the code ["if (_ymouse<atas) bla bla bla"]

fruityDJ
November 7th, 2005, 06:53 PM
thats very nice of you..and its close to what i want but not quite.

i dont want the "pan" infinite.(for example my stage will be 600px wide while the content being panned as much as flash can handle hehehe ...i think is 2800px.

the next thing is the pan should be activated only if you move your mouse to the very edge of the movie either is left or right but not to pan while your mouse is let say in the center.
one more thing is the whole thing should not appear as button (on your movie instead of cursur the "hand" is activated which treats the whole thing as a button)

i hope i make sence..
thanks again for your info though.