PDA

View Full Version : Continuous Zoom



Rattz
June 7th, 2004, 06:02 PM
hi folks just wondering if someone could help me with a wee problem i have.

i've made a button that zooms into a movie clip on a rollover, but it on moves it a certain amount each time you rollover the button. code below:

on (rollOver){

_root.Mypic._width += 5;
_root.Mypic._height += 5;

}

wot i want it to do is to continue zooming in for as long as the mouse is over the button, is there anyway i can change the code to zoom in at the same amount but do it continuously until the mouse is moved off the button.

Also is there anyway that i can set it so that the zoom stops at a certain percentage, i.e. it only zooms in so much and then stops. What i mean is that the user can zoom in but the picture will only zoom in to say 200% of the original size.

thanks in advance for any help on this matter.

rattz

ch0pstikninja
June 7th, 2004, 06:11 PM
on (load) {
_root.Mypic.origWidth = _root.Mypic._width;
_root.Mypic.origHeight = _root.Mypic._height;
}
on (rollOver){
if (_root.Mypic._width <= (_root.Mypic.origWidth*2))
_root.Mypic._width += 5;
if (_root.Mypic._height <= (_root.Mypic.origHeight*2))
_root.Mypic._height += 5;
}

that code resizes to 200%
hope that helps...

senocular
June 7th, 2004, 06:21 PM
you can use _xscale and _yscale which are size calculations based on %

Rattz
June 7th, 2004, 06:30 PM
ive put that code in to the button and i get the following error message.

Scene=Scene 1, Layer=Layer 1, Frame=1: Line 1: Invalid mouse event specified.
on (load) {

Scene=Scene 1, Layer=Layer 1, Frame=1: Line 2: Statement must appear within on handler
_root.Mypic.origWidth = _root.Mypic._width;

Scene=Scene 1, Layer=Layer 1, Frame=1: Line 3: Statement must appear within on handler
_root.Mypic.origHeight = _root.Mypic._height;

Scene=Scene 1, Layer=Layer 1, Frame=1: Line 4: Unexpected '}' encountered
}

Rattz
June 7th, 2004, 06:31 PM
sorry to be a pain but i'm new at this lol

Rattz
June 7th, 2004, 07:27 PM
i've had a look on the net and i found out about setInterval and how to set a function. so this is what i've come up with so far.

Frame 1:

function zoomin (){
_root.Mypic._xscale += 5;
_root.Mypic._yscale += 5;
}

Zoomin Button:

on (rollOver) {
zoom = setInterval(zoomin, 50);
}

on (rollOut) {
clearInterval (zoom)
}

ive now got it to zoom in real nice and stop zooming as the mouse rolls off the button, but i still need to set the maximum zoom percentage to 200%, but i dont know how.

can anyone help

radicaljugnu
June 8th, 2004, 06:48 AM
on(rollOver){
zoomin=true
zoomout=false
}
on(rollOut){
zoomin=false
zoomout=true
}
onClipEvent(enterFrame){
if(zoomin){
_root.myPic._xscale+=(200-_root.myPic._xscale)/5
_root.myPic._yscale+=(200-_root.myPic._yscale)/5
}
if(zoomout){
_root.myPic._xscale-=(_root.myPic._xscale-100)/5
_root.myPic._yscale-=(_root.myPic._yscale-100)/5
}
}

Rattz
June 8th, 2004, 09:21 AM
i cant get this to work.

this is how i see it, tell me where i've gone wrong:

on(rollOver){
zoomin=true
zoomout=false
}
on(rollOut){
zoomin=false
zoomout=true
}

goes on the button

and:

onClipEvent(enterFrame){
if(zoomin){
_root.myPic._xscale+=(200-_root.myPic._xscale)/5
_root.myPic._yscale+=(200-_root.myPic._yscale)/5
}
if(zoomout){
_root.myPic._xscale-=(_root.myPic._xscale-100)/5
_root.myPic._yscale-=(_root.myPic._yscale-100)/5
}
}

goes in the Mypic movieclip or does it go on the first frame

ch0pstikninja
June 8th, 2004, 09:57 AM
well, you can put it on the first frame and put it like so:



myPic.onEnterFrame = function() {
if (zoomin) blah blah blah
yada yada
}

Rattz
June 8th, 2004, 10:09 AM
well i've now got that bit working cheers everbody. but i'm now stuck with the fact that it scales up on the rollover and then scales down on the rollout. what i need it to do is stay scaled up until the mouse is moved over the zoomout button.

the way i had it set up before with the function and the setInterval is there anyway to set the maximum amount of zoom that way?

scotty
June 8th, 2004, 10:25 AM
Try this (with Voets his golden formula;) )

MovieClip.prototype.zoomTo = function(tarZ) {
this.onEnterFrame = function() {
this._xscale = tarZ-(tarZ-this._xscale)/1.2;
this._yscale = this._xscale;
if (Math.abs(this._xscale-tarZ)<1) {
this._xscale = this._yscale=tarZ;
delete this.onEnterFrame;
}
};
};
zoomIn.onRollOver = function() {
myPic.zoomTo(200);
};
zoomOut.onRollOver= function() {
myPic.zoomTo(100);
};

scotty(-:

Rattz
June 8th, 2004, 10:33 AM
thats perfect Scotty, your a genius. Thanks and thanks to everybody else thats help me with this mess.

as a newbie i really should try to kerb my imagination, cos my skills with flash just aren't up to the things going through my brain, lol.

cheers everyone, plus thanks for a great forum, cos i've posted this on a number of forums and your the only people that have got back to me with help, so once again thanks for everything, and keep your eyes open cos i'll more than likely be back for more help lol

Rattz

scotty
June 8th, 2004, 11:00 AM
no problem=)

Rattz
June 9th, 2004, 10:41 AM
Scotty was just wondering about this:

i was talking to senocular on another problem i had about the registration point of a movieclip, and the fact that the zoom of a movieclip automatically zooms in and out to the top left corner. so what i was wondering is is it possible to have a .jpg loaded into a movie, convert it to a graphic, and then manipulate like you would a movieclip, i.e. control the zoom and pan functions as you stated above. all this has to happen when the movie is published and online.

if ya have any thoughts could ya please let me know, and if anybody else has anything to say on the matter please do so.

cheers

Rattz

senocular
June 9th, 2004, 10:58 AM
thats where the two movieclips come into play... give me a few and Ill make a swf that explains the process in greater detail...

Rattz
June 9th, 2004, 11:00 AM
senocular your a star thanks

senocular
June 9th, 2004, 12:06 PM
well not that much more detail, but it should show the idea behind it. Note that MC1 becomes *inside* MC2 when it fades in.

width=300 height=310

Rattz
June 9th, 2004, 12:10 PM
i think i get the idea, is there any chance you could post the .fla file?

i know thats a bit cheeky but if ya dont ask ya dont get lol

i just dont quite get the way u've got it set up, i get how it works, but not how to get it to work if ya know wot i mean

rattz

Rattz
June 9th, 2004, 12:29 PM
it's ok senocular i've figured it out, took me a while to get what ya meant but i got there hehehehehe.

thanks for the help my friend!!

i've now got my zoom and pan controls working with the mc and i can load and unload any mc i want and it zooms from the center, now just got to put that into the website design itself. thanks again

Rattz