thanks glen

a

On Thu, Feb 5, 2009 at 6:29 PM, Glen Pike <[email protected]> wrote:

> Hi,
>
>   It looks better than my deadzone calc's which take up a lot more code (I
> have 2 directions and a deadzone area in the middle and around the outside
> of the "mouse area" controlling the velocity), but you are welcome to
> compare below - I think mine is a bit more verbose, but I was trying to make
> sure I could debug and come back to it in a few months time and understand.
>  Whatever works for you I guess.
>
>   Glen
>
>
>    private function _mouseMoveHandler(event:MouseEvent):void {
>           var tmpX:Number;
>           var tmpY:Number;
>           //Get x, y in relation to centre of stage - need to "clamp"
>           tmpX = this.mouseX - WIDTH / 2;//event.stageX -
> this.stage.stageWidth / 2;
>           tmpY = this.mouseY - HEIGHT / 2;//event.stageY -
> this.stage.stageHeight / 2;
>           var absX:uint = Math.abs(tmpX);
>           var absY:uint = Math.abs(tmpY);
>           var dirX:int = tmpX / absX;
>           var dirY:int = tmpY / absY;
>           //clamp the movement to a maximum;
>           tmpX = Math.min(_clampMax, absX) * dirX;
>           tmpY = Math.min(_clampMax, absY) * dirY;
>           //App.debug("mouse " + this.mouseX + ", " + this.mouseY + " tmp"
> + tmpX + ", " + tmpY + " abs " + absX + ", " + absY);
>                     //only respond to a minimum position from centre within
> our square..
>           if (_clampMax <= absX || _clampMax <= absY) {
>               _mouseClamp = true;
>               return;
>           }
>           _mouseClamp = false;
>           if(_clampMin < absY) {
>               _velX = (absY * dirY) / _mouseDamping;
>           } else {
>               _velX = 0;
>           }
>                     if(_clampMin < absX) {
>               _velY = -((absX * dirX) / _mouseDamping);
>           } else {
>               _velY = 0;
>           }
>           //App.debug("mouse Move " + _velX + ", " + _velY);
>
>       }
>
>
> allandt bik-elliott (thefieldcomic.com) wrote:
>
>> hi guys
>>
>> I'm working on a carousel and i have a quick question about adding a
>> non-active area in the middle
>>
>> at the moment, the carousel will move forward and backward based on the
>> mouse's position in relation to the center of the carousel but I'd like to
>> widen that by nDeadzoneRadius
>>
>> here is the way that i'm doing it at the moment - it seems very clunky to
>> me
>> but it's doing the job
>>
>> this is on the onMouseMove listener
>>
>>    private function adjustSpeed():Void
>>    {
>>        var nMousePos:Number = _root._xmouse - nCenterX;
>>
>> // !HACK! this is the bit i'm querying
>>        if (Math.abs(nMousePos) < nDeadzoneRadius) nMousePos = 0;
>>        else nMousePos = (nMousePos > 0) ? nMousePos - nDeadzoneRadius :
>> nMousePos + nDeadzoneRadius;
>> // end of !HACK!
>>
>>        nSpeed = nMousePos / ((36 / _nNumberOfItems) * 1000); //4:800,
>> 8:4000, 12:3000, 24:1500
>>    }
>>
>> so i guess my question is, is there a more elegant solution to this,
>> please?
>>
>> ta
>> a
>> _______________________________________________
>> Flashcoders mailing list
>> [email protected]
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>>
>>
>>
>
> --
>
> Glen Pike
> 01326 218440
> www.glenpike.co.uk <http://www.glenpike.co.uk>
>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to