MACROMEDIA FLEX 2-MIGRATING APPLICATIONS TO FLEX 2 Manuel d'utilisateur Page 179

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 184
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 178
Using the drag-and-drop feature 179
Flex 2:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script><![CDATA[
import mx.managers.DragManager;
// Import events package for MouseEvent:
import mx.events.*;
// Specify types for all arguments:
function dragIt(event:MouseEvent, text:String, format:String) {
var ds:mx.core.DragSource = new mx.core.DragSource();
ds.addData(text, format);
// New doDrag signature:
DragManager.doDrag(event.target, ds, event);
}
function doDragEnter(event:DragEvent) {
if (event.dragSource.hasFormat('color')) {
/? For a drop target to accept an item for dropping, it calls the
// acceptDragDrop() method and does not use the
// event.handled property:
DragManager.acceptDragDrop(event.target);
}
}
function doDragDrop(event:DragEvent) {
var data:Object = event.dragSource.dataForFormat('color');
myCanvas.setStyle("backgroundColor", data);
}
]]></mx:Script>
<mx:HBox>
<mx:Canvas backgroundColor="#FF0000" borderStyle="solid" width="30"
height="30" mouseMove="dragIt(event, 'red', 'color')"/>
<mx:Canvas backgroundColor="#00FF00" borderStyle="solid" width="30"
height="30" mouseMove="dragIt(event, 'green', 'color')"/>
</mx:HBox>
<mx:Label text="Drag the item into this canvas"/>
<mx:Canvas id="myCanvas" backgroundColor="#FFFFFF" borderStyle="solid"
width="100" height="100" dragEnter="doDragEnter(event)"
dragDrop="doDragDrop(event)"/>
</mx:Application>
Vue de la page 178

Commentaires sur ces manuels

Pas de commentaire