Chris,
Your sample code is a bit over-complicated. Let's break it down. I'm
going to re-arrange the order of things, a bit, hoping it will make things
more clear for you.
var set1 = main1._xscale = 50;
First off, I would add the "var" keyword. No reason not to; after all,
you're declaring a variable here. Assuming this code is in the main
timeline, you are doing two things in this one line: A) declare a variable,
set1, and set its value to the value of the _xscale property of a movie clip
with the instance name main1; B) set the value of the _xscale property of
main1 to 50. In short, both set1 and main1._xscale are set to 50.
onEnterFrame = function() {
SCALE(main1, set1);
};
Next, you're assigning a function to the onEnterFrame event handler of
the main timeline (aka the _root). Basically, you're saying, "Hey, _root,
every time you enter a frame, do the following," and then you tell it what
to do (happens to be the SCALE() function). It should be noted that by
default, FLAs are set to 12fps (frames per second), so in something as short
as 3 seconds, this function will be invoked 36 times; in one minute, 720
times.
Now, a couple thoughts ... there's nothing wrong with assigning a
function to the onEnterFrame event handler of the _root, but I would use
"this" for sake of clarity (this.onEnterFrame = ...). In addition, since
this event handler is available to all movie clip instances (see
MovieClip.onEnterFrame), why not use it on the clip itself, rather than the
main timeline? You could assign the same SCALE() function to the
onEnterFrame handler of any given movie clip ...
main1.onEnterFrame = function() {
_root.SCALE(this, _root.set1);
}
.... which means you could re-use it anywhere you like. By assigning it to
the _root instead, you can only use it once. If you tried to assign another
onEnterFrame event handler to the _root, it would overwrite the first one.
Now we come to the meat of the matter.
function SCALE(CLIP, SET) {
start = CLIP._xscale;
end = SET - start;
CLIP._xscale = start + (end / 5);
CLIP._yscale = start + (end / 5);
if (CLIP._xscale < 850 && CLIP._xscale >= 1) {
CLIP._visible = 1;
} else {
// "camera"...
CLIP._visible = 0;
}
};
This function is called repeatedly by the previously-mentioned event
handler. The function accepts two parameters, arbitrarily named CLIP and
SET.
Line one sets a variable "start" to the _xcale
[quoted text, click to view] "dilate2003" <webforumsuser@macromedia.com> wrote in message
news:d7b5c4$btk$1@forums.macromedia.com...
> Hey thanks for replying so quick!!
>
> ive posted the code i was playing with below... the code was actually
> written
> for another movie that had 6 circles that zoomed in on the press of a
> button..
> what i tried to do was replace the circles with one movie clip which takes
> up
> the size of the stage.. i put a small cross inside the movie clip at the
> top
> left of the stage.. and used this as a goal to zoom in on..
>
> i then tried modifying the code to look to the following:
>
> "button1.onPress = function() {
> set1 = 100; <this scales the movie clip on button press.
> set1 = _x = _x +50;
> }"
>
> but this somehow scaled the clip 50% its size... instead of scaling it to
> 100%
> and moving it..
>
> if you could edit my code or suggest a new way of doing it... i would
> appreciate it.. i still have to design the movie i want.. but ill do that
> once
> i get the code sorted...
>
> basically what i wanna learn is zooming and positioning a movie clip with
> fluid movement on the press of a button.
>
>
>
> -----------------------------------------------------------------
>
> function SCALE(CLIP, SET) {
> start = CLIP._xscale;
> end = SET-start;
> CLIP._xscale = start+(end/5);
> CLIP._yscale = start+(end/5);
>
> if (CLIP._xscale<850 && CLIP._xscale>=1) { <<<this makes the movie clip
> disapear when it reaches 850% or less than 1%
> CLIP._visible = 1;
> this give the appearance of the camera going out of sight or behind the
> } else {
> "camera"...
> CLIP._visible = 0;
> }
> }
> set1 = main1._xscale= 50; <<<this scales the movie clip when its loaded.
>
> onEnterFrame=function(){
> SCALE(main1, set1);
> }
>
> button1.onPress = function() {
> set1 = 100; <this scales the movie clip on button press.
> }
>
>
> Thanks again!
> Chris.
>