tailieunhanh - O’Reilly Programming Flex 2 phần 5

Ngược lại, về IDE, phải công nhận Flash Builder quả thật có nhiều tiện ích và hỗ trợ tuyệt vời, có thể nói đã đạt đến tầm bộ Visual Studio của Microsoft (với plug-in Amethyst cho Flex). Các templates, autocomplete, generators, refactors. quá phong phú và mạnh mẽ. Tốc độ, kể cả Profiler, hiển nhiên vượt trội so với Flex Builder hay Flash Builder . Flash Builder quá nhanh, quá nguy hiểm. | Example 8-9. Using ActionScript for drag and drop behavior continued mx VBox mx HBox mx Application You ll notice that in this example both data grids have dropEnabled and dragEnabled set to true. This in and of itself allows the user to copy contents from one data grid to the other. However as shown in Example 8-8 this does not ensure the type of behavior required in this case. To achieve the move-only behavior each data grid also listens for dragComplete events. The dragCompleteHandler method handles the events by either dismissing the event if the event action is set to none or deleting the element from the drag initiator s data provider. Custom Drag and Drop Operations The built-in drag and drop functionality will work for many use cases. However there are also many use cases in which you will want to employ drag and drop functionality not supported by the standard built-in features of the handful of drag and drop-enabled components. For these cases you can create custom drag and drop elements. You can create custom drag and drop elements using the events discussed in the preceding section in conjunction with . The DragManager class has several static methods you can use to handle drag and drop functionality. The doDrag method allows you to start a drag and drop operation. The doDrag method requires that you specify the following parameters the drag initiator a DragSource object specifying the data to copy from the initiator and the mouse event used to start the drag operation. In addition in most cases you ll need to pass it a reference to an object to use as the drag proxy image the object that actually drags . Before we look at an example using doDrag let s first discuss the details of working with DragSource. The DragSource object you pass to doDrag is what is passed along to event handlers for drag events. This object contains data that you can use when copying moving or comparing. That means you should generally store whatever data