A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: Convert action script

  1. #1
    Junior Member
    Join Date
    Jan 2004
    Posts
    17

    Convert action script

    Hi, I need to convert this code to ActionScript 2 or ActionScript 3. I prefer ActionScript 2.

    Code:
    onClipEvent (mouseDown) {
       if (i>0) {
          return;
       }
       zoom = true;
       dir == 1 ? (dir=-1) : (dir=1);
       if (dir == 1) {
          pt = {x:_root.zoom_this._xmouse, y:_root.zoom_this._ymouse};
       }
    }
    onClipEvent (enterFrame) {
       if (!zoom) {
          return;
       }
       _root.zoom_this._xscale += dir*i*100/8;
       _root.zoom_this._yscale += dir*i*100/8;
       var pt2 = {x:pt.x, y:pt.y};
       _root.zoom_this.localToGlobal(pt2);
       _root.zoom_this._x -= (pt2.x-pt.x);
       _root.zoom_this._y -= (pt2.y-pt.y);
       i++;
       if (i == 10) {
          zoom = false;
          i = 0;
       }
    }
    Thanks in advance!

  2. #2
    Senior Member
    Join Date
    May 2010
    Location
    Russia: Western Siberia
    Posts
    268
    Isn't it as2 already?

  3. #3
    Junior Member
    Join Date
    Jan 2004
    Posts
    17
    No. This code works only on Flash Player 6 and Actionscript1 or below.

  4. #4
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    You should be able to replace the onClipEvent lines with these:

    PHP Code:
    onMouseDown = function():Void{

    // ...

    onEnterFrame = function():Void
    Please use [php] or [code] tags, and mark your threads resolved 8)

  5. #5
    Junior Member
    Join Date
    Jan 2004
    Posts
    17
    Code:
    onMouseDown = function():Void{ 
       if (i>0) {
          return;
       }
       zoom = true;
       dir == 1 ? (dir=-1) : (dir=1);
       if (dir == 1) {
          pt = {x:_root.zoom_this._xmouse, y:_root.zoom_this._ymouse};
       }
    }
    onEnterFrame = function():Void{ 
       if (!zoom) {
          return;
       }
       _root.zoom_this._xscale += dir*i*100/8;
       _root.zoom_this._yscale += dir*i*100/8;
       var pt2 = {x:pt.x, y:pt.y};
       _root.zoom_this.localToGlobal(pt2);
       _root.zoom_this._x -= (pt2.x-pt.x);
       _root.zoom_this._y -= (pt2.y-pt.y);
       i++;
       if (i == 10) {
          zoom = false;
          i = 0;
       }
    }
    Doesnt seem to work.
    I'm using this flash as a template:
    http://www.flashkit.com/movies/Inter...8487/index.php

  6. #6
    Senior Member
    Join Date
    Aug 2006
    Posts
    322
    ActionScript Code:
    var zoom:Boolean;
    var dir:Number = 0;
    var i:Number = 0;
    var pt;
    var pt2;
    zoom_this.onRelease = function() {
        if (i>0) {
            return;
        }
        zoom = true;
        dir == 1 ? (dir=-1) : (dir=1);
        if (dir == 1) {
            var pt = {x:this._xmouse, y:this._ymouse};
        }
    };

    zoom_this.onEnterFrame = function() {
        if (!zoom) {
            return;
        }
        this._xscale += dir*i*100/10;
        this._yscale += dir*i*100/10;
        pt2 = {x:pt.x, y:pt.y};
        this.localToGlobal(pt2);
        this._x -= (pt2.x-pt.x);
        this._y -= (pt2.y-pt.y);
        i++;
        if (i == 10) {
            zoom = false;
            i = 0;
        }
    };

  7. #7
    Junior Member
    Join Date
    Jan 2004
    Posts
    17
    This one doesnt seem to work either. Unless I'm doing something wrong.

  8. #8
    Senior Member
    Join Date
    Aug 2006
    Posts
    322
    The code will go to Frame1 on TimeLine.

    Post a sample fla of your work.
    OR your source.

    marlopax
    Last edited by marlopax; 01-04-2011 at 05:48 PM.

  9. #9
    Junior Member
    Join Date
    Jan 2004
    Posts
    17
    The source is here:
    http://www.flashkit.com/movies/Inter...8487/index.php
    direct link:
    http://www.flashkit.com/downloads/mo.../Zoom%20me.zip
    Basicaly I need this script to be compatible with flash player 9 and actionscript2.

  10. #10
    Senior Member
    Join Date
    Aug 2006
    Posts
    322
    Well, Create a New FLA.
    Copy This Code in Frame1 on TimeLine:

    ActionScript Code:
    var zoom:Boolean;
    var dir:Number = 0;
    var i:Number = 0;
    var pt;
    var pt2;
    zoom_this.onRelease = function() {
        if (i>0) {
            return;
        }
        zoom = true;
        dir == 1 ? (dir=-1) : (dir=1);
        if (dir == 1) {
            mag.plus._visible=0;
            pt = {x:this._xmouse, y:this._ymouse};
        }else{
            mag.plus._visible=1;
        }
    };

    zoom_this.onEnterFrame = function() {
        if (!zoom) {
            return;
        }
        this._xscale += dir*i*100/8;
        this._yscale += dir*i*100/8;
        pt2 = {x:pt.x, y:pt.y};    
        this.localToGlobal(pt2);
        this._x -= (pt2.x-pt.x);
        this._y -= (pt2.y-pt.y);
        i++;
        if (i == 10) {
            zoom = false;
            i = 0;
        }
    };
    Mouse.hide();
    var mouseListener:Object = new Object();
    mouseListener.onMouseMove = function() {
        mag._x = _xmouse;
        mag._y = _ymouse;
        updateAfterEvent();
    };
    Mouse.addListener(mouseListener);

    Copy only the zoom_this MovieClip into Frame1.

    Make a magnifier MovieClip instance name "mag".

    Inside of mag make another MovieClip instance name "plus".

    This plus MovieClip is just a verticle line, not a plus sign.

    Copy & paste plus clip and give instance name "minus".

    Rotate minus clip 90 degree from transform.

    Test Movie.

    This will work on FLP 9, AS2.

    marlopax
    Last edited by marlopax; 01-04-2011 at 06:53 PM.

  11. #11
    Junior Member
    Join Date
    Jan 2004
    Posts
    17
    Thanks, I did it as you described and the zoom works, but now the movieclip started to lag really bad. zoom_this contains some other movieclips like flying birds and once I zoom in, flash movie starts to stutter and lag.

Tags for this Thread

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center