Flash Builder DataGrid DragEvent
Olá pessoal beleza?
Pois é em ritmo de AudiCup.
Eis que então o pessoal da Audi entrou em contato comigo essa semana para fazer algo em Web 2.0 para cadastrar os times que irão participar da AudiCup.
Segue os links abaixo:
http://www.audi.com/com/brand/en/experience/sponsoring/sportsponsoring/the_audi_cup_2011.html
http://www.audi.com/com/brand/en/experience/sponsoring/sportsponsoring/the_audi_cup_2011/schedule_and_tickets.html
Inter , estaremos contigo ..
Tu és minha paixão !
Não importa o que digam
Sempre levarei comigo
Minha camisa vermelha ..
e a cachaça na mão
O Gigante me espera ..
Para começar a festa !
O exemplo é mais ou menos o que esta abaixo:
Veja o Fonte é simples:
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="application1_creationCompleteHandler(event)"> <fx:Declarations> </fx:Declarations> <fx:Script> <![CDATA[ import mx.collections.ArrayCollection; import mx.events.CloseEvent; import mx.controls.Alert; import mx.events.DragEvent; import mx.events.FlexEvent; import mx.managers.DragManager; [Bindable] private var time:Time; [Bindable] private var times:ArrayCollection; [Bindable] private var timesConvocados:ArrayCollection=new ArrayCollection(); private function onDrop(event:DragEvent):void { if(event.dragSource.formats.toString() == "items,itemsByIndex,caretIndex") { var dragList:Array = event.dragSource.dataForFormat('items') as Array; var draggedTimes:Time = dragList[0] as Time; if(draggedTimes.fifa == 'N') { Alert.show("Não foi possível adicionar este time!\n\n"+draggedTimes.nome+" não tem mundial de Clubes FIFA!", "AudiCup"); event.preventDefault(); event.target.hideDropFeedback(event); DragManager.showFeedback(DragManager.NONE); }else if(draggedTimes.fifa == 'T') { Alert.show("Time Adicionado!\n\n"+draggedTimes.nome+" foi campeão do mundialito de Gentil em 2010!", "AudiCup"); }else{ Alert.show("Time Adicionado!\n\n"+draggedTimes.nome+" foi campeão Mundial FIFA!", "AudiCup"); } } } protected function application1_creationCompleteHandler(event:FlexEvent):void { times=new ArrayCollection(); time=new Time(); time.id=1; time.nome="FC Barcelona"; time.fifa="S"; times.addItem(time); time=new Time(); time.id=2; time.nome="SC Internacional de Porto Alegre"; time.fifa="S"; times.addItem(time); time=new Time(); time.id=3; time.nome="FC Bayern"; time.fifa="S"; times.addItem(time); time=new Time(); time.id=4; time.nome="AC Milan"; time.fifa="S"; times.addItem(time); time=new Time(); time.id=5; time.nome="Grêmio de Porto Alegre"; time.fifa="N"; times.addItem(time); time=new Time(); time.id=6; time.nome="SC Juventude de Caxias do Sul"; time.fifa="N"; times.addItem(time); time=new Time(); time.id=7; time.nome="FC Bãrdei de Marau"; time.fifa="T"; times.addItem(time); } ]]> </fx:Script> <s:Label x="10" y="10" fontSize="14" fontWeight="bold" text="Audi Cup 2011 Meet the best"/> <mx:DataGrid x="10" y="32" width="250" height="220" dataProvider="{times}" dragEnabled="true" dragMoveEnabled="true" dropEnabled="true"> <mx:columns> <mx:DataGridColumn dataField="nome" headerText="Times disponíveis para a AudiCup"/> </mx:columns> </mx:DataGrid> <mx:DataGrid x="268" y="32" width="250" height="220" dataProvider="{timesConvocados}" dragEnabled="true" dragMoveEnabled="true" dropEnabled="true" dragDrop="onDrop(event);"> <mx:columns> <mx:DataGridColumn dataField="nome" headerText="Convoque você mesmo - Arraste Aqui"/> </mx:columns> </mx:DataGrid> </s:Application>
package { [Bindable] public class Time { public var id:Number; public var nome:String; public var fifa:String; public function Time() { } } }
Felipe Borella.
Share on Facebook
Comentários