flex: Drag and drop of copy- image instantiation in AS
I am working on a flex project
I am building drag-and-drop functionality in AS. I have a situation where I need to pick image items from the left and drop it onto a grid. Three specific requirements a) some conditions around alignment b) I want a copy of the image to be dropped- not the original c) the dropped image needs to be movable 开发者_如何学Cagain
while I know how to create a drag-droppable object in mxml using
<mx:Image id="img" x="100" y="100" source="img.png" mouseMove="mouseMoveHandler(event);"/>
how do I do a equivalent where I need to achieve (c). My current approach is to achieve (b) do as follows- Create a new image
var newImage:Image=new Image();
newImage.id="Element"+String(count); //increment count to create newer objects
newImage.source = draggedImage.source;
//conditions to do alignment
How do I do equivalent of newimage.mouseMove as in the mxml above
Your post feels a bit scattered; so I believe this is the only question:
How do I do equivalent of newimage.mouseMove as in the mxml above
The MXML version, from your sample is like this:
<mx:Image id="img" mouseMove="mouseMoveHandler(event);"/>
In ActionScript, you would do something like this:
img.AddEventListener(MouseEvent.MOUSE_MOVE,mouseMoveHandler);
精彩评论