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!

Actionscript zoom

Status
Not open for further replies.

AP81

Programmer
Apr 11, 2003
740
AU
Hi Guys,

Wondering if someone can help me out with this.

I have a flash slideshow that I created which is basically a script (no frames) with a timer that uses the TransitionManager class to do transitions.

I am trying to do a zoom/pan effect with pure action script but am having no luck. I am not a Flash programmer (am PHP/Delphi), so bear with my example.

In the code below I am trying to do a zoom but I only see the end result (not the animation)
Code:
 for (i=0;i<10;i++)
  {
    mc._xscale = mc._xscale+5;
    mc._yscale = mc._yscale+5; 
    myInterval = setInterval(pauseIt, 1000);
   }
  function pauseIt() {
   clearInterval(myInterval);
  }

I take it that I need to duplicate the movie clip to have an animated effect. Any ideas? I've included the entire function if it helps (see case 8 in the switch statement)

Code:
function initTransition(mc:MovieClip) {
	/* 
	if (trans_effect == "fade") {	// if fade, always set transition to 2 (fade)
		rnd =2; 				
	}else{							// otherwise generate an integer between 1 & 7
		rnd = Math.floor(Math.random()*7)+1;  	
	}
	*/
   rnd = 8;
	switch (rnd) {
		case 1:		// blinds
			dimension_num = Math.round(Math.random()*1); // dimension: 0=horizontal,1=vertical
			TransitionManager.start(mc, {type:Blinds,direction:Transition.IN, duration:trans_delay,easing:Regular.easeInOut,numStrips:10,dimension:dimension_num});
			break;
		case 2:		// fade
			TransitionManager.start(mc, {type:Fade,direction:Transition.IN, duration:trans_delay,easing:None.easeInOut});
			break;
		case 3:		// Iris
			effect_rnd = Math.floor(Math.random()*2)+1;
			if (effect_rnd == 1) {
				TransitionManager.start(mc, {type:Iris, direction:Transition.IN, duration:trans_delay, easing:None.easeInOut, startPoint:5, shape:Iris.CIRCLE});
			}else{
				TransitionManager.start(mc, {type:Iris, direction:Transition.IN, duration:trans_delay, easing:None.easeInOut, startPoint:5, shape:Iris.SQUARE});
			}
			break;
		case 4:		// pixel dissolve
			TransitionManager.start(mc, {type:PixelDissolve,direction:Transition.IN, duration:trans_delay,easing:None.easeInOut,xSections:4,ySections:4});
			break;
		case 5:		// rotate
			ccw_num = Math.round(Math.random()*1);	// ccw = false/true
			TransitionManager.start(mc, {type:Rotate,direction:Transition.IN, duration:trans_delay,easing:None.easeInOut,ccw:ccw_num, degrees:90});
			break;
		case 6:		// squeeze
			dimension_num = Math.round(Math.random()*1); // dimension: 0=horizontal,1=vertical
			TransitionManager.start(mc, {type:Squeeze,direction:Transition.IN, duration:trans_delay,easing:Regular.easeInOut,dimension:dimension_num});
			break;
		case 7:		// wipe (1,5=TopL, 2=Top, 3=TopR, 4=L, 6=R, 7=BottomL, 8=Bottom, 9=BottomR)
			startpoint_num = Math.floor(Math.random()*(9-2))+2;
			TransitionManager.start(mc, {type:Wipe,direction:Transition.IN, duration:trans_delay,easing:Regular.easeInOut,startPoint:startpoint_num});
			break;
		case 8:
			for (i=0;i<10;i++)
			{
			   mc._xscale = mc._xscale+5;
			   mc._yscale = mc._yscale+5; 
			   myInterval = setInterval(pauseIt, 1000);
			}
			function pauseIt() {
			  clearInterval(myInterval);
			}
		    /*
			beginLocation = new Object();
			beginLocation.x = 640;
			beginLocation.y = 0;
			endLocation = new Object();
			endLocation.x = 250;
			endLocation.y = 170;
			new Tween(mc, "_x", None.easeInOut, beginLocation.x, endLocation.x, (delay/1000)+trans_delay, true);
			new Tween(mc, "_y", None.easeInOut, beginLocation.y, endLocation.y, (delay/1000)+trans_delay, true);
			*/
			break;
		default:
			TransitionManager.start(mc, {type:Fade,direction:Transition.IN, duration:trans_delay,easing:None.easeInOut});
			break;
	}
		
	slideshow();

}


------------------------------------
There's no place like 127.0.0.1
------------------------------------
 
One thing to remember is "for" loop runs as fast as possible. Your count 0 to 9 happens in nano seconds, that's why you only see the end result.

You can use onEnterFrame to increase the scale on each frame refresh, or may be better still, use the Tween Class.

Kenneth Kawamoto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top