Skip navigation
a.bisewski
Currently Being Moderated

Load frames conform mouse position

Apr 24, 2013 1:45 PM

Hi.

 

Look this site:

www.perpendicular.tk

 

This site use javascript to show image by image. It is not a 3D model, only images are showed one by one in relation position mouse.

 

In actionscript, how Can I make this?

 

I think that I need start putting the images in frames. After, Stop(). When Mouse clicked, I need to compare with the last position and verify the direction, if mouse direction is left ou right and gtonextframe.

 

But how can I make this accelerate system. Look in site that the image are load more fast is mouse moviment is fast...

 

Thanks and sorry for my english...

 
Replies
  • kglad
    72,357 posts
    Jul 21, 2002
    Currently Being Moderated
    Apr 25, 2013 11:54 AM   in reply to a.bisewski

    to scroll the frames for any movieclip (eg, mc) based on mouse x position, you can use:

     

    paramF(mc,0,1,stage.stageWidth,mc.totalFrames);

    this.addEventListener(MouseEvent.MOUSE_MOVE,moveF);

     

    function moveF(e:MouseEvent):void{

    mc.gotoAndStop(Math.round(mc.m*mouseX+mc.b));

    }

     

    function paramF(mc:MovieClip,x1:Number,y1:Number,x2:Number,y2:Number):void{

    mc.m=(y1-y2)/(x1-x2);

    mc.b=y1-mc.m*x1;

    }

     
    |
    Mark as:
  • kglad
    72,357 posts
    Jul 21, 2002
    Currently Being Moderated
    Apr 25, 2013 11:57 AM   in reply to a.bisewski

    the code i suggested will change movieclip frames more rapidly if the mouse is moved quickly, too.

     

    are you looking for some sort of easing?

     
    |
    Mark as:
  • kglad
    72,357 posts
    Jul 21, 2002
    Currently Being Moderated
    Apr 25, 2013 1:25 PM   in reply to a.bisewski

    copy and paste the code you're using.

     
    |
    Mark as:
  • kglad
    72,357 posts
    Jul 21, 2002
    Currently Being Moderated
    Apr 25, 2013 2:38 PM   in reply to a.bisewski

    use:

     

    paramF(mc,0,1,stage.stageWidth,mc.totalFrames);

    this.addEventListener(MouseEvent.MOUSE_MOVE,moveF);

     

    this.addEventListener(MouseEvent.MOUSE_DOWN,moveD);

    this.addEventListener(MouseEvent.MOUSE_UP,moveU);

    var testa:Boolean = false;

     

    function moveF(e:MouseEvent):void{

    mc.gotoAndStop(Math.round(mc.m*mouseX+mc.b));

    }

    function moveD(e:MouseEvent):void{

    testa = true;

    }

    function moveU(e:MouseEvent):void{

    testa = false;

    }

     

    function paramF(mc:MovieClip,x1:Number,y1:Number,x2:Number,y2:Number):void{

    if(testa){

    mc.m=(y1-y2)/(x1-x2);

    mc.b=y1-mc.m*x1;

    }

    }

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points