[Flash] Image Zoom In/Out

  • Image Zoom In/Out
  • Download: ImageZoom.zip

    有用過Compiz Fusion的特效都知道使用Ctrl+滑鼠就可以任意在畫面上拉出一個範圍來放大,這裡簡單使用Flash的基本的zoom in/out的性質就可以產生類似的特效。

    在畫面上用滑鼠拉出的範圍即可放大。

    主要程式碼其實只有下面這兩段,其餘只是在處理矩形縮放,和範圍修正等訊息。

    private function zoomIn():void{
    var newX:Number = -startX*scale;
    var newY:Number = -startY*scale;

    if((newX+this.width*scale) < this.width){
    newX = -(this.width*(scale-1));
    }

    if((newY+this.height*scale) < this.height){
    newY = -(this.height*(scale-1));
    }

    var xScaleTween:Tween = new Tween(this, "scaleX", Strong.easeOut, 1 , scale, 1, true);
    var yScaleTween:Tween = new Tween(this, "scaleY", Strong.easeOut, 1 , scale, 1, true);
    var xTween:Tween = new Tween(this, "x", Strong.easeOut, this.x, newX, 1, true);
    var yTween:Tween = new Tween(this, "y", Strong.easeOut, this.y, newY, 1, true);

    xTween.start();
    yTween.start();
    xScaleTween.start();
    yScaleTween.start();
    }

    private function zoomOut():void{
    var xScaleTween:Tween = new Tween(this, "scaleX", Strong.easeOut, scale, 1, 1, true);
    var yScaleTween:Tween = new Tween(this, "scaleY", Strong.easeOut, scale, 1, 1, true);
    var xTween:Tween = new Tween(this, "x", Strong.easeOut, this.x, 0, 1, true);
    var yTween:Tween = new Tween(this, "y", Strong.easeOut, this.y, 0, 1, true);

    xTween.start();
    yTween.start();
    xScaleTween.start();
    yScaleTween.start();
    }

No comments:

Post a Comment

Orange - data analysis tool

Installation pip install orange3 Run orange python -m Orange.canvas