Zoom Image
From Director Online Wiki
Zoom an image in and out.
Drop this behaviour on a bitmap image sprite and zoom in and out with left mouse clicks.
property pSprite property pMember property pCurrentRect property pMemberImage property pZoomLevel on beginSprite me pSprite = sprite(me.spriteNum) pMember = pSprite.member pMemberImage = pMember.image.duplicate() pCurrentRect = pMemberImage.rect pZoomLevel = 1.0 end on endSprite me pMember.image = pMemberImage end on mouseDown me tImage = image(pSprite.width,pSprite.height,32) _movie.stage.image.copyPixels(tImage, pSprite.rect, tImage.rect) relLoc = _mouse.mouseLoc - point(pSprite.left,pSprite.top) normlH = relLoc[1]/float(pSprite.width) normlV = relLoc[2]/float(pSprite.height) imgLocH = pCurrentRect[1] + (normlH * pCurrentRect.width) imgLocV = pCurrentRect[2] + (normlV * pCurrentRect.height) if (the commandDown) then pZoomLevel = pZoomLevel / 2.0 newWidth = pCurrentRect.width * 2.0 newHeight = pCurrentRect.height * 2.0 newLeft = imgLocH - (newWidth / 2.0) newRight = imgLocH + (newWidth / 2.0) newTop = imgLocV - (newHeight / 2.0) newBottom = imgLocV + (newHeight / 2.0) newRect = rect(newLeft,newTop,newRight,newBottom) pCurrentRect = newRect else pZoomLevel = pZoomLevel * 2.0 newWidth = pCurrentRect.width / 2.0 newHeight = pCurrentRect.height / 2.0 newLeft = imgLocH - (newWidth / 2.0) newRight = imgLocH + (newWidth / 2.0) newTop = imgLocV - (newHeight / 2.0) newBottom = imgLocV + (newHeight / 2.0) newRect = rect(newLeft,newTop,newRight,newBottom) pCurrentRect = newRect end if _movie.stage.image.copyPixels(pMemberImage, pSprite.rect, newRect) end