A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [RESOLVED] Transformation with mouse click and hold

  1. #1
    Junior Member
    Join Date
    Jan 2014
    Posts
    12

    resolved [RESOLVED] Transformation with mouse click and hold

    I have a movie-clip

    In itself, it transforms an another shape.

    What I want to achieve is, as I press and hold over the movie-clip it will start transforming. When I release the mouse button, it will stop and when I press and hold again, it will continue.

    Sounds easy, but I am not familiar with Actionscript 3 that much.

    Appreciate if you can help me.

    Thank you.

  2. #2
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    var Frame:int = 1;

    yourMovieClipName.addEventListener(MouseEvent.MOUS E_DOWN, down);
    function down(e:MouseEvent):void
    {
    yourMovieClipName.addEventListener(Event.ENTER_FRA ME, run);
    }

    yourMovieClipName.addEventListener(MouseEvent.MOUS E_UP, up);
    function up(e:MouseEvent):void
    {
    trace("asda");
    yourMovieClipName.removeEventListener(Event.ENTER_ FRAME, run);
    yourMovieClipName.stop();
    }

    function run(e:Event):void
    {
    yourMovieClipName.gotoAndPlay(Frame);
    Frame++;
    }
    Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries

  3. #3
    Junior Member
    Join Date
    Jan 2014
    Posts
    12
    Quite straightforward!

    Thanks so much.

    Quote Originally Posted by angelhdz View Post
    var Frame:int = 1;

    yourMovieClipName.addEventListener(MouseEvent.MOUS E_DOWN, down);
    function down(e:MouseEvent):void
    {
    yourMovieClipName.addEventListener(Event.ENTER_FRA ME, run);
    }

    yourMovieClipName.addEventListener(MouseEvent.MOUS E_UP, up);
    function up(e:MouseEvent):void
    {
    trace("asda");
    yourMovieClipName.removeEventListener(Event.ENTER_ FRAME, run);
    yourMovieClipName.stop();
    }

    function run(e:Event):void
    {
    yourMovieClipName.gotoAndPlay(Frame);
    Frame++;
    }

  4. #4
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    If you don't have any other question, and your question is solved, please mark this thread as Resolved.
    Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries

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