AS3实例教程:拖拽实例源码收集.
1.Drag and Drop in ActionScript 3.0
Creating drag and drop functionality in Flash CS3 is quite different than in older versions if you’re using the new ActionScript 3.0. While still relatively straightforward, the code can be a little more intimidating to users who are less familiar with ActionScript programming. If you’re like me, you’re here to try to keep your knowledge up-to-date, so let’s learn how to create a simple ActionScript 3.0 drag and drop game step-by-step. Download the FLA and follow along with these steps.
2.as3-drag-and-drop-tilelist
Description
The dd_tile_list class extends the as3 TileList component to add drag and drop functionality. Dropping between components is supported. This class aims to be CellRenderer and Style agnostic.
3.swapDepth in AS3 for drag n drop
The swapDepth is not available on AS3, rather much more simplest way is available.
The below commented code can be achieved through the single line: event.target.parent.addChild(event.target);
4.Drag n’ Drop in AS3
I used to teach drag-n-drop funtionality using startDrag() and stopDrag() MovieClip methods. This is the easiest and fastest way but it tends to be choppy when the framerate is low. To solve this problem, you should employ MOUSE_MOVE event as shown in this tutorial by Flash and Math.
Their tutorial is great and I’ll use their concept in this article. But I don’t want the draggable object to snap to its center when dragging. I’ll put in a lockcenter option and a swapDepths() alternative.
Notes:
- We capture the broadcasted MOUSE_MOVE event from the stage and not from the draggable object. This ensures it will keep on dragging even if the mouse cursor moves outside the object. I guess Flash and Math already explained this.
- 1 is subtracted from numChildren because children are placed in an Array thus child index is length-1.
- updateAfterEvent() just makes things a lot smoother.
5.Drag-and-Drop in Flash CS3
The drag-and-drop interface is particularly valuable for educational purposes. Since much of the standard documentation on Flash CS 3 and Actionscript 3 is focused (at least initially) on animation and multimedia applications, we felt it would be useful to provide some tutorial pages on using the drag and drop interface written for those who have only a rudimentary understanding of Adobe Flash. If you have never written a line of code in Flash before, we recommend you start with one of the earlier Basic tutorials on this site such as Simple Line Segment: Creating Sprites and Shapes from Mouse Clicks.
6.AS3 example Drag and Drop
This example belongs to the AS3 Tutorials Novice and is part of our Actionscript 3 tutorial series.
You will learn how to implement simple drag and drop applications.
7.Flash drag and drop tutorial
Dragging and dropping objects is a popular brick in edutainment programs. This is part of Flash CS3 tutorials. It is probably not suitable for Flash designers without any programming experience.
- Learning goals
- Learn how to create simple drag and drop programs with Flash 9 (CS3) components
- Learn a little bit of Action Script 3
8.Actionscript 3 Dragging Methods
This tutorial is all about dragging an object around the stage. You will learn different ways to implement dragging. I’ll also show you how to add some animation with the dragging. So start your Flash IDE and let’s get going!
9.ActionScript 3.0 : Buttons and Drag & Drop
In ActionScript 3.0, buttons and interactive movieclip stuff is scripted differently. To understand in depth about how ActionScript 3.0 works for interactivity see the diagram beside.
Diagram besides show, a pin with a tag attached to it. In Action Script 3.0, all events such as mouse clicks, mouse move, mouse over, keyboard inputs, even movieclip’s frame movement is controlled using event listeners. You can attached this event listeners to any movieClip, components, stage or sprites to add interactivity features to it. Just like how the pin works…just attach the pin to the object.
Each event listeners has a trigger function. Trigger function is a script which triggers because of the specific event for example, a mouse click. This means if you attached an event listener for mouse click on a button, the trigger function itself will be the script for the button. This is how you make button scripts in Action Script 3.0. Similar to our old on(Press) function.
来自:http://www.lemlinh.com/flash-tutorials-as3-drag-and-drop/