SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: zooming effect

  1. #1
    SitePoint Member
    Join Date
    Mar 2004
    Location
    WI
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    zooming effect

    I’m trying to see if I can get a zooming effect to work. So far I have it working properly b/4 and after the zoom, but during the zoom effect the _xscale/_yscale seems to default the location of the movie to the upper left, and if you watch carefully you can see the zoom “stretch” into place instead of focusing on the particular location that the mask is supposed to focus on.

    This is basically what I have:


    stop();
    zoomto=100;
    // **************************************************
    *******
    doZoom.onPress = function() {
    zoomto = 180;
    }
    // **************************************************
    *******
    unZoom.onPress = function() {
    mask.myzoom._xscale=100;
    mask.myzoom._yscale=100;
    zoomto=100;
    }
    // **************************************************
    *******
    onEnterFrame=function(){
    SCALE(mask.myzoom, zoomto);
    _root.Mask.myzoom._x = ((.5*595)-_root.Mask._x)* (zoomto/100);
    _root.Mask.myzoom._y = ((.5*400)-_root.Mask._y)* (zoomto/100);
    }
    // **************************************************
    *******
    function SCALE(CLIP, SET) {
    //scale
    if(CLIP._xscale < SET){
    start = CLIP._xscale;
    end = SET-start;
    CLIP._xscale = start+(end/12);
    CLIP._x = ((.5*595)-_root.Mask._x)* (CLIP._xscale/100);
    CLIP._yscale = start+(end/12);
    CLIP._y = ((.5*400)-_root.Mask._y)* (CLIP._yscale/100);
    }
    }

    Any suggestions? The CLIP._x= doesn’t seem to help, I’ve tried a few variations with no luck moving the movie during zoom.

    here is what it looks like right now: http://www.rohdedesigns.net/v3
    you can drag the focus window around, use the left button to zoom and right to reset.

  2. #2
    SitePoint Member
    Join Date
    Mar 2004
    Location
    WI
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    figured er out

    finally figured it out, had to make sure the adjustment x/y position
    was being calculated based on the CURRENT x/yscale. so when i zoom from 100 to 180%... say its only @ 120, you need to do the x/y positioning based on the current scale.

    basically changed to this:

    //*********************************************************
    onEnterFrame=function(){
    SCALE(mask.myzoom, zoomto);
    _root.Mask.myzoom._x = ((.5*595)-_root.Mask._x)* (_root.Mask.myzoom._xscale/100);
    _root.Mask.myzoom._y = ((.5*400)-_root.Mask._y)* (_root.Mask.myzoom._yscale/100);
    }

  3. #3
    SitePoint Member
    Join Date
    Mar 2004
    Location
    WI
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Another idea for less CPU overhead usage:

    CLIP._xscale = start+2+(Math.floor(end/12));
    CLIP._yscale = start+2+(Math.floor(end/12));

    basically the math.floor rounds up so there is less decimal calculations, and the +2 makes it so that you dont have to do another round of calculations, basically so you are not doing another calculation if you are already at 178% enroute to 180%.

    I think you there is a way to do division w/o worrying about decimals (float maybe?)

  4. #4
    SitePoint Wizard bronze trophy JRMillion's Avatar
    Join Date
    Apr 2004
    Location
    Arlington VA
    Posts
    2,094
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well the way to make it CPU efficient is to only assign the onEnterFrame handler when you need it, such as onRollOver. If you have it running all the time, it will use CPU all the time.
    you can remove onEnterFrame handlers by doing
    "delete myClip.onEnterFrame"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •