Re: [flexcoders] how to make drag and drop in flex 3

Friday, December 09, 2011

 

refer the following links

http://livedocs.adobe.com/flex/3/html/help.html?content=dragdrop_4.html#174194

http://livedocs.adobe.com/flex/3/html/help.html?content=dragdrop_6.html#247937

http://livedocs.adobe.com/flex/3/html/help.html?content=dragdrop_7.html#247940

http://livedocs.adobe.com/flex/3/html/help.html?content=dragdrop_8.html#225115


Best Regards,

Sathya Moorthi K | MCA,
mailto: ksathyanm@gmail.com



On Thu, Dec 8, 2011 at 12:55 PM, azHanie <adroit42@excite.com> wrote:
 

hi,

i have problem here. i have list of images to be arranged according to the ranking. however, i cant drop the image. below is the code. may i know where's the mistake?
__________________________________________________________

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"
horizontalAlign="center"
backgroundGradientAlphas="[1.0, 1.0]"
backgroundGradientColors="[#FFFFFF, #FFFFFF]"
creationComplete="service.send()" viewSourceURL="srcview/index.html">

<mx:Script>
<![CDATA[
import mx.core.DragSource;
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
import mx.events.DragEvent;
import mx.managers.DragManager;
import mx.core.UIComponent

[Bindable]
private var images:ArrayCollection;

private function serviceHandler(event:ResultEvent):void{
images = event.result.gallery.image;
}

private function initiateDrag(event:MouseEvent,value:String):void{

var dragInitiator:Image= event.currentTarget as Image;

var dragSource:DragSource = new DragSource();
dragSource.addData(value, 'value');

var dragProxy:Image = new Image();
dragProxy.source = event.currentTarget.source;
dragProxy.width = 100 ;
dragProxy.height = 100 ;

DragManager.doDrag(dragInitiator, dragSource, event, dragProxy);
}

private function dragEnterHandler(event:DragEvent):void {
var dropTarget:List=event.currentTarget as List;
if (event.dragSource.hasFormat('value')) {
DragManager.acceptDragDrop(dropTarget);
}


{
DragManager.acceptDragDrop(UIComponent(event.target));
}
}

]]>
</mx:Script>

<mx:HTTPService id="service" url="datas.xml" result="serviceHandler(event)"/>

<mx:Label text="Drag a thumbnail image inside the black box and drop it to display its bigger version"/>

<mx:HBox>
<mx:Repeater dataProvider="{images}" id="rep">
<mx:Image source="assets/thumbs/{rep.currentItem}"
mouseMove="initiateDrag(event,event.currentTarget.getRepeaterItem())" />
</mx:Repeater>
</mx:HBox>
<mx:List
iconField="image_pic"
dragEnabled="true"
dropEnabled="true"
dragMoveEnabled="true"
rowCount="1"
columnCount="1"
rowHeight="60"
columnWidth="60"
verticalScrollPolicy="off"
alternatingItemColors="[#D3D3D3, #DDDADA]"
width="81" height="63"
paddingLeft="1" paddingRight="1" paddingTop="1" paddingBottom="1"/>
<mx:List
iconField="image_pic"
dragEnabled="true"
dropEnabled="true"
dragMoveEnabled="true"
rowCount="1"
columnCount="1"
rowHeight="60"
columnWidth="60"
verticalScrollPolicy="off"
alternatingItemColors="[#D3D3D3, #DDDADA]"
width="81" height="63"
paddingLeft="1" paddingRight="1" paddingTop="1" paddingBottom="1"/>
<mx:List
iconField="image_pic"
dragEnabled="true"
dropEnabled="true"
dragMoveEnabled="true"
rowCount="1"
columnCount="1"
rowHeight="60"
columnWidth="60"
verticalScrollPolicy="off"
alternatingItemColors="[#D3D3D3, #DDDADA]"
width="81" height="63"
paddingLeft="1" paddingRight="1" paddingTop="1" paddingBottom="1"/>
<mx:List
iconField="image_pic"
dragEnabled="true"
dropEnabled="true"
dragMoveEnabled="true"
rowCount="1"
columnCount="1"
rowHeight="60"
columnWidth="60"
verticalScrollPolicy="off"
alternatingItemColors="[#D3D3D3, #DDDADA]"
width="81" height="63"
paddingLeft="1" paddingRight="1" paddingTop="1" paddingBottom="1"/>

</mx:Application>

thnks



__._,_.___
Recent Activity:
MARKETPLACE

Stay on top of your group activity without leaving the page you're on - Get the Yahoo! Toolbar now.

.

__,_._,___

0 comments:

Post a Comment