IT Admin

Tag: drop

Flash Tutorial, Drag and Drop

by frenchsquared on Nov.26, 2008, under Flash, Tutorials

Naming Objects
The very basics of ActionScript are the objects and classes. Sound, Graphic and Text are a few examples of Data Type Objects. A data object can pull information from a source of you choice, such as an array, XML or simply the time. All objects belong to a larger group referred to as classes. Flash has prebuilt class that help flash understand how to handle data. such as Array, Math, Sound and Video.

Objects need to be named for ActionScript to be able to use them.
When you have the object on the stage and selected you can enter the name in this field.



Applying a Method
In the file you will find a box called “box”. First you need to name the box, currently it is called box in the Library, but for ActionScript it needs to be named in the Properties panel. (see example above). Click on the box symbol and go to the Properties panel. Name this box “box_mc”

The object has been named, so lets make the object do something, such as following the mouse around. Open the Actions panel (press F9)

Flash CS3 Actions

select the first key frame in the actions layer and

ActionScript

then add the following code:

box_mc.addEventListener(MouseEvent.MOUSE_MOVE, drag);
function drag(event:MouseEvent):void{
box_mc.startDrag();
};

This Code calls the method “startDrag()” a built in in feature of Flash CS3. You named the box “box_mc“ so “startDrag()“ is applied to “box_mc“

Now press contol-enter to publish this file. When you run your mouse over the .swf you will see the box follow your mouse. A .swf is the file extension that flash uses to create a file referred to as a movie. You can then embed the .swf into an html page. If you haven’t changed the name of your flash file you will see that pressing control-enter created a new file called start01.swf.


Press Control-Enter and test you movie.

Download Flash CS3 Source Files

  • Share/Bookmark
Leave a Comment :, , , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...