Skip navigation
BarbaraSchmoyer
Currently Being Moderated

Photo Zoom

Jan 13, 2010 12:46 PM

What is the technique for the effect of a photo zooming in larger on the screen. If an image is imported as .png how do you make it appear to grow from small photo to large photo? Shape Tween is disabled.

 
Replies
  • kglad
    62,007 posts
    Jul 21, 2002
    Currently Being Moderated
    Jan 13, 2010 12:52 PM   in reply to BarbaraSchmoyer

    you can scale the image using its scaleX and scaleY properties (as3) or _xscale and _yscale properties (as2).

     
    |
    Mark as:
  • kglad
    62,007 posts
    Jul 21, 2002
    Currently Being Moderated
    Jan 13, 2010 1:26 PM   in reply to BarbaraSchmoyer

    are you using as2 or as3?

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 13, 2010 3:35 PM   in reply to kglad

    AS3, please

     
    |
    Mark as:
  • kglad
    62,007 posts
    Jul 21, 2002
    Currently Being Moderated
    Jan 13, 2010 4:02 PM   in reply to BarbaraFEWW

    you don't need to change the code below the dotted line:

     

    to scale any display object from startZoom to endZoom in steps number of steps, you can call startScaleF().  for example:

     

    startScaleF(mc1,1,4,100);  // to scale mc1 from 100% to 400% in 100 steps

    startScaleF(mc2,1,-4,100);  // to scale mc2 from 100% to -400% in 100 steps

    startScaleF(mc3,.1,-5.2,40);  // to scale mc3 from 10% to -520% in 40 steps

     

     

    ----------------------------------

    function startScaleF(dobj:DisplayObject,startZoom:Number,endZoom:Number,steps: uint):void{
        var mc:MovieClip = new MovieClip();
        mc.step = 1;
        mc.dobj = dobj;
        mc.startZoom = startZoom;
        mc.endZoom = endZoom;
        mc.steps = steps;
        dobj.scaleX = dobj.scaleY = startZoom;
        mc.addEventListener(Event.ENTER_FRAME,scaleF);
    }

     

    function scaleF(e:Event):void{
        e.currentTarget.dobj.scaleX = e.currentTarget.dobj.scaleY += (e.currentTarget.endZoom-e.currentTarget.startZoom)/e.currentTarget.s teps;
        if(e.currentTarget.step>=e.currentTarget.steps){
            e.currentTarget.removeEventListener(Event.ENTER_FRAME,scaleF);
        } else {
            e.currentTarget.step++;
        }
    }

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points