views:

31

answers:

3

Could you tell how the actionscript code would look like for such a job?

A: 

You use StartDrag() and StopDrag()

http://edutechwiki.unige.ch/en/Flash%5Fdrag%5Fand%5Fdrop%5Ftutorial

David
A: 

do you mean Shape class object or Graphics class object? Shape class is derived from DisplayObject so there is no interactive support for this and one can not instantiate a Graphics class object. For making something drag-gable, one needs to put graphics in some Sprite object.

bhups
A: 

Here is one way:

Create a MovieClip called "Circle". Right-click on the symbol in the library, choose Properties > check the "Linkage" box, then "Export for Actionscript". Name the class "Circle". You can use flash.display.MovieClip as the base class.

Then, in the same folder as your .fla file, create a text file called "Circle.as" (remember to use a capital C, like you name the MovieClip) and type the following:

package {
import flash.display.MovieClip;
import flash.events.MouseEvent;

public class Circle extends MovieClip {


    public function Circle () {
        this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
        this.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);

        this.buttonMode = true;
        this.mouseChildren = false;

    }
    private function mouseDownHandler(e:MouseEvent):void {
        startDrag();
    }
    private function mouseUpHandler(e:MouseEvent):void {

        stopDrag();
    }


}

}

redconservatory