if you want something to happen over and over do a set interval on
mouse down and clear interval on mouse up.


On 5/13/07, dave matthews <[EMAIL PROTECTED]> wrote:
hi All,

  What is the syntax for a continuous loop in AS3?

  Have working code for a code loop using mouse down - one frame-main
timeline, but can't figure out how to maintain the rate of movement when the
mouse is stationary with the mouse button still in down position.

thanks,
Dave_Matthews

  Place symbol instance named 'circle' on stage.
  Paste this code on actions frame:

import flash.events.MouseEvent;
this.stop();

var circleOrigX:Number;
var circleOrigY:Number;
var curOrigX:Number;
var curOrigY:Number;
var panRateX:Number;
var panRateY:Number;

function panSetUpDrag(event:MouseEvent):void {
        circleOrigX = event.stageX - circle.x;
        circleOrigY = event.stageY - circle.y;
        curOrigX= event.stageX ;
        curOrigY= event.stageY ;
        stage.addEventListener(MouseEvent.MOUSE_MOVE, panloop);
}

function panloop(event:MouseEvent):void {
/*want this loop to operate while mouse is stationary
- causing pan actions to reposition circle
at rate based on distance of cursor from start*/

        panRateX =  (event.stageX -curOrigX) * 3 ;
        panRateY =  (event.stageY -curOrigY) * 3 ;
        circle.x = event.stageX - circleOrigX - panRateX;
        circle.y = event.stageY - circleOrigY - panRateY;
        event.updateAfterEvent();
}
function PanStopDrag(event:MouseEvent):void {
        gotoAndStop(1);
        stage.removeEventListener(MouseEvent.MOUSE_MOVE, panloop);

}

stage.addEventListener(MouseEvent.MOUSE_DOWN, panSetUpDrag);
stage.addEventListener(MouseEvent.MOUSE_UP, PanStopDrag);

_________________________________________________________________
More photos, more messages, more storage—get 2GB with Windows Live Hotmail.
http://imagine-windowslive.com/hotmail/?locale=en-us&ocid=TXT_TAGHM_migration_HM_mini_2G_0507

_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to