Monday, June 4, 2012

[Action Script] Rotate object on hold and drag June,2012

Hi there,
I'm basically trying to do this in as3:

Code: var pressing:Boolean=false;
var myRadians:Number;
var mydegrees:Number;
bean_mc.onPress=function  () {
        pressing=true;
        spin ();
}
bean_mc.onRelease=bean_mc.onReleaseOutside=function  () {
        pressing=false;
        delete bean_mc.onEnterFrame;
}
function spin () {


bean_mc.onEnterFrame=function  () {
        if (pressing) {
               
                myRadians=Math.atan2((_ymouse-bean_mc._y),(_xmouse-bean_mc._x));
                mydegrees=Math.round(myRadians*180/Math.PI);
                bean_mc._rotation=mydegrees+90;
}

}
}(This came from a post the user neilmmm answer in 07-16-2007)

I want the user to be able to drag 3 circles around a wheel (one by one). This is what i got so far.

Code: import flash.events.MouseEvent;

var myRadians:Number;
var myDegrees:Number;

circ1.addEventListener(MouseEvent.MOUSE_DOWN, pressing1);
function pressing1(evt:MouseEvent):void {
        myRadians = Math.atan2((circ1.target.x - this.circ1.x),(circ1.target.y - this.circ1.y));
        myDegrees = Math.round(myRadians*180/Math.PI);
        circ1._rotation = myDegrees;               
};I couldn't figure out how to change the the circ1._rotation part.

I supose I should just copy the code for the other 2 circles and change the function to pressing2 and pressing3.


PS.: I search the forums but the 3 posts I found on this problem were in as2.
Rotate object on hold and drag

Related Post



0 comments: