Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ken Burns Effect 1

Status
Not open for further replies.

AP81

Programmer
Apr 11, 2003
740
AU
Hi guys,

I am trying to replicate a Ken Burns effect (see :
I have a fairly good idea how to do this, however my main issue here is zooming in to a picture at a particular point.

For example, if the stage is 640x480 and the picture is MovieClip is 640x480, how would I zoom to the TopRight or BottomRight?

Thx


------------------------------------
There's no place like 127.0.0.1
------------------------------------
 
Flash uses top left corner (0, 0) as the registration point when you scale the MovieClip, therefore this point is the zooming focal point.

What I usually do is create a child MovieClip and load the image into it. Then move the child MC to the negative position: for example (-600, -400). Then move the parent MC to the opposite direction: in this case (600, 400). Now you have a 640x480 image filling the Stage nicely, but the registration point of the parent MC is placed at (600, 400) on Stage - bottom right.

Then start scaling up. The image will appear to zoom into the bottom right corner.

Hope you get this. If you need a code to do this let us know.

Kenneth Kawamoto
 
Thanks kennethkawamoto, now that I know that I think I can give this a try.

Thanks again.


------------------------------------
There's no place like 127.0.0.1
------------------------------------
 
I'm starting to get somewhere, thanks kennethkawamoto

Code:
			mc._x = 640;
			mc._y = 480;
			
			var mc2 = mc.createEmptyMovieClip("container", this.getNextHighestDepth());
			mc2._x = -640;
			mc2._y = -480;
			mc2.loadMovie(image[p]);
			
			mc.onEnterFrame = function(){
				this._xscale++;
				this._yscale++;
			}


------------------------------------
There's no place like 127.0.0.1
------------------------------------
 
I managed to get this working on the Bottom Right And Top Left only.

Given the bottom right:
mc._x = 640;
mc._y = 480;

- and -

mc2._x = -640;
mc2._y = -480;

One would assume that the top right would be:
mc._x = -640;
mc._y = 480;
mc2._x = 640;
mc2._y = -480;

This does not work. Can you possibly point out where I've gone wrong in the positioning?


------------------------------------
There's no place like 127.0.0.1
------------------------------------
 
Thanks kennethkawamoto, that has helped.


------------------------------------
There's no place like 127.0.0.1
------------------------------------
 
OK, I am almost there. I can zoom to TopLeft, TopRight, BottomLeft and BottomRight.

How can I zoom to other sections, like Left, Top, Right, Bottom and middle? I take it that this would be harder, as zoom starts from the left corner.

// Top Left - don't really need a child clip
parent._x = 0;
parent._y = 0;
child._x = 0;
child._y = 0;

// Top Right
parent._x = 640;
parent._y = 0;
child._x = -640;
child._y = 0;

// Bottom Left
parent._x = 0;
parent._y = 480;
child._x = 0;
child._y = -480;

// Bottom Right
parent._x = 640;
parent._y = 480;
child._x = -640;
child._y = -480;


------------------------------------
There's no place like 127.0.0.1
------------------------------------
 
I take "left" means the middle of the left edge:

// Left
parent._x = 0;
parent._y = 240;
child._x = 0;
child._y = -240;

// Top
parent._x = 320;
parent._y = 0;
child._x = -320;
child._y = 0;

// Right
parent._x = 640;
parent._y = 240;
child._x = -640;
child._y = -240;

// Bottom
parent._x = 320;
parent._y = 480;
child._x = -320;
child._y = -480;

// Middle
parent._x = 320;
parent._y = 240;
child._x = -320;
child._y = -240;

Kenneth Kawamoto
 
Care to share some code?

I am still having troubles with this...


------------------------------------
There's no place like 127.0.0.1
------------------------------------
 
OK, here's my quick Ken Burns Random Zoom-in Flash movie.

The set up:
[ul]
[li]320 x 240 Stage, 20 fps[/li]
[li]3 320 x 240 pictures "pic1.png", "pic2.png", and "pic3.png" placed next to the FLA[/li]
[li]Nothing on Stage, just the following code in the frame 1[/li]
[/ul]
The code:
Code:
var picArray:Array = ["pic1.png", "pic2.png", "pic3.png"];
var picCnt:Number = picArray.length;
var picID:Number = 0;
function newImg():Void {
	var mc:MovieClip = this.createEmptyMovieClip("mc2", 2).createEmptyMovieClip("mc", 1);
	var mcl:MovieClipLoader = new MovieClipLoader();
	var lo:Object = new Object();
	mcl.addListener(lo);
	lo.onLoadInit = function(mc:MovieClip):Void  {
		mc._x = Math.floor(Math.random()*-321);
		mc._y = Math.floor(Math.random()*-241);
		startZoom(mc);
	};
	mcl.loadClip(picArray[picID],mc);
	(picCnt-picID == 1) ? picID=0 : picID++;
}
function startZoom(mc:MovieClip):Void {
	var container:MovieClip = mc._parent;
	container._x = -mc._x;
	container._y = -mc._y;
	container._alpha = 0;
	container.onEnterFrame = function():Void  {
		if (this._alpha<100) {
			this._alpha += 2;
		}
		this._xscale = this._yscale=this._xscale+1;
		if (this._xscale>200 && !(this.swapped)) {
			this.swapped = true;
			this.swapDepths(1);
			this._name = "mc1";
			newImg();
		}
	};
}
newImg();
You can put any number of images by changing the Array at the top.

Kenneth Kawamoto
 
OK, I see what you have done.

I was using two MovieClips with two MovieClipLoaders to load the images with two listeners. That was the first place I went wrong.

Thank you for your help & sorry for all the bother.

One last question:

Code:
var mc:MovieClip = this.createEmptyMovieClip("mc2", 2).createEmptyMovieClip("mc", 1);

Am I correct in assuming that mc gets destroyed every time is is re-declared?


------------------------------------
There's no place like 127.0.0.1
------------------------------------
 
Thanks for all your help, but I think that I will drop this project. Flash is just way too jerky when it comes to things like this (even with a very high FPS).

Thanks again.


------------------------------------
There's no place like 127.0.0.1
------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top