How to pageScroll mx.DataGrid programmatically? - actionscript-3

If there are some mistakes in English, I'd like to apologize.
I want to scroll datagrid programmatically by click buttonbar event.
Following code is work, but it scrolls one by one.
What I need is page scrolling, like clicking empty horizontal scrollTrack area.
Any help would be greatly appreciated.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.events.ItemClickEvent;
import mx.collections.ArrayCollection;
private var arr:ArrayCollection = new ArrayCollection([
{COL1:"aaa",COL2:"bbb",COL3:"ccc",COL4:"ddd",COL5:"eee",COL6:"fff",COL7:"ggg",COL8:"hhh",COL9:"iii",COL10:"jjj",COL11:"kkk",COL12:"lll",COL13:"mmm",COL14:"nnn",COL15:"ooo",COL16:"ppp",COL17:"qqq",COL18:"rrr",COL19:"sss",COL20:"ttt"}
]);
public function init(): void
{
scrollController.dataProvider=["|<", "<", ">", ">|"];
grid.dataProvider = arr;
}
public function doScroll(event: ItemClickEvent): void
{
if (event.index ==0)
{
// force move to left end.
grid.horizontalScrollPosition = 0;
}
else if (event.index ==1){
// move left one by one
// *** I want modify here.
if (grid.horizontalScrollPosition > 0){
grid.horizontalScrollPosition -= 1;
}
}
else if (event.index ==2){
// move right one by one
// *** I want modify here too.
if (grid.horizontalScrollPosition < grid.maxHorizontalScrollPosition){
grid.horizontalScrollPosition += 1;
}
}
else{
// force move to right end.
if (grid.horizontalScrollPosition < grid.maxHorizontalScrollPosition){
grid.horizontalScrollPosition = grid.maxHorizontalScrollPosition;
}
}
}
]]>
</mx:Script>
<mx:ButtonBar id="scrollController" y="0" itemClick="doScroll(event)"/>
<mx:DataGrid id="grid" y="30" width="340" horizontalScrollPolicy="on">
<mx:columns>
<mx:DataGridColumn headerText="COL1" dataField="COL1" width="100"/>
<mx:DataGridColumn headerText="COL2" dataField="COL2" width="100"/>
<mx:DataGridColumn headerText="COL3" dataField="COL3" width="100"/>
<mx:DataGridColumn headerText="COL4" dataField="COL4" width="100"/>
<mx:DataGridColumn headerText="COL5" dataField="COL5" width="100"/>
<mx:DataGridColumn headerText="COL6" dataField="COL6" width="100"/>
<mx:DataGridColumn headerText="COL7" dataField="COL7" width="100"/>
<mx:DataGridColumn headerText="COL8" dataField="COL8" width="100"/>
<mx:DataGridColumn headerText="COL9" dataField="COL9" width="100"/>
<mx:DataGridColumn headerText="COL10" dataField="COL10" width="100"/>
<mx:DataGridColumn headerText="COL11" dataField="COL11" width="100"/>
<mx:DataGridColumn headerText="COL12" dataField="COL12" width="100"/>
<mx:DataGridColumn headerText="COL13" dataField="COL13" width="100"/>
<mx:DataGridColumn headerText="COL14" dataField="COL14" width="100"/>
<mx:DataGridColumn headerText="COL15" dataField="COL15" width="100"/>
<mx:DataGridColumn headerText="COL16" dataField="COL16" width="100"/>
<mx:DataGridColumn headerText="COL17" dataField="COL17" width="100"/>
<mx:DataGridColumn headerText="COL18" dataField="COL18" width="100"/>
<mx:DataGridColumn headerText="COL19" dataField="COL19" width="100"/>
<mx:DataGridColumn headerText="COL20" dataField="COL20" width="100"/>
</mx:columns>
</mx:DataGrid>
</mx:Application>
Run demo on wonderfl
Updated Sep 16 17:15(JST)
I wrote this code in CustomDateGrid(extended mx.DataGrid) and call from ButtonBar.
But nothing occurred.
public function scrollToRightPage(): void{
var delta:Number = this.horizontalScrollBar.pageScrollSize != 0 ? this.horizontalScrollBar.pageScrollSize : this.horizontalScrollBar.pageSize;
var direction:Number = 1;
var scrollPosition:Number = this.horizontalScrollPosition + direction * delta;
var oldPosition: Number = this.horizontalScrollPosition;
var event:ScrollEvent = new ScrollEvent(ScrollEvent.SCROLL);
event.detail = ScrollEventDetail.PAGE_RIGHT;
event.position = scrollPosition;
event.delta = scrollPosition - oldPosition;
event.direction = ScrollBarDirection.HORIZONTAL;
this.horizontalScrollBar.dispatchEvent(event);
// Call scrollHandler(the protected function defined at DataGrid.as) instead of horizontalScrollBar.dispatchEvent was also nothing occurred.
// scrollHandler(event);
}

I gave up to dispatch ScrollEvent.
But anyway I solved it by setting horizontalScrollPosition.
First, I added these functions to CustomDataGrid.
public function scrollToRightPage(): void{
// I got a hint from "mx_internal function pageScroll"(defined at ScrollBar.as).
var delta:Number = this.horizontalScrollBar.pageScrollSize != 0 ? this.horizontalScrollBar.pageScrollSize : this.horizontalScrollBar.pageSize;
var direction:Number = 1;
var scrollPosition:Number = this.horizontalScrollPosition + direction * delta;
this.horizontalScrollPosition = scrollPosition;
}
public function scrollToLeftPage(): void{
var delta:Number = this.horizontalScrollBar.pageScrollSize != 0 ? this.horizontalScrollBar.pageScrollSize : this.horizontalScrollBar.pageSize;
var direction:Number = -1;
var scrollPosition:Number = this.horizontalScrollPosition + direction * delta;
this.horizontalScrollPosition = scrollPosition;
}
And call from external class like below.
if (event.index ==0)
{
grid.horizontalScrollPosition = 0;
}
else if (event.index ==1){
if (grid.horizontalScrollPosition > 0){
//grid.horizontalScrollPosition -= 1;
// Jump to left page.
grid.scrollToLeftPage();
}
}
else if (event.index ==2){
if (grid.horizontalScrollPosition < grid.maxHorizontalScrollPosition){
//grid.horizontalScrollPosition += 1;
// Jump to right page.
grid.scrollToRightPage();
}
}
else{
if (grid.horizontalScrollPosition < grid.maxHorizontalScrollPosition){
grid.horizontalScrollPosition = grid.maxHorizontalScrollPosition;
}
}

Related

Display total sum of rows values in arraycollection - Adobe Flex

I want to display total sum of rows values in an arraycollection. For example:
Definition Value
Product 1 20.00
Product 2 50.00
Product 3 30.00
Total 100.00
I have this code:
<mx:DataGrid id="srcgrid">
<mx:columns>
<mx:DataGridColumn dataField="Definition"/>
<mx:DataGridColumn dataField="Value"/>
</mx:columns>
</mx:DataGrid>
<s:Form>
<s:FormItem label="Total">
<s:Label text="{total()}"/>
</s:FormItem>
</s:Form>
And the script:
public function total():String {
var i:Number = 0;
for each(var obj:Object in ArrayCollection(DataGrid(srcgrid).dataProvider)){
i = i + obj.Value;
}
return i.toString();
}
Any idea?
Thanks in advance
The total() function was called before there was anything inside the dataProvider.
Also srcgrid.dataProvider can be looped as an Object
<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" applicationComplete="addInitData(event)">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<mx:DataGrid id="srcgrid">
<mx:columns>
<mx:DataGridColumn dataField="Definition"/>
<mx:DataGridColumn dataField="Value"/>
</mx:columns>
</mx:DataGrid>
<s:Form x="250">
<s:FormItem label="Total">
<s:Label id="total"/>
</s:FormItem>
</s:Form>
<fx:Script>
<![CDATA[
import flash.events.Event;
import mx.collections.ArrayList;
private function addInitData(e:Event = null):void{
var dataProvider:ArrayList = new ArrayList();
for (var i:int = 0; i < 12; i++){
dataProvider.addItem({Definition : 'item_' + i, Value : i});
}
srcgrid.dataProvider = dataProvider;
updTotal();
}
private function updTotal():void{
var sum:Number = 0;
for (var k:String in srcgrid.dataProvider){
sum += srcgrid.dataProvider[k]['Value'];
}
total.text = sum.toString();
}
]]>
</fx:Script>
</s:Application>

How to disable a component inside Datagrid which is rendered using inline item renderer

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private var myTimer:Timer;
[Bindable] public var isEnabled:Boolean = true;
public function getDetails():void {
Alert.show("Got it!!");
isEnabled = false;
myTimer = new Timer(5000, 1);
myTimer.addEventListener(TimerEvent.TIMER_COMPLETE, timerHandler);
myTimer.start();
}
public function timerHandler(event:TimerEvent):void {
isEnabled = true;
}
]]>
</mx:Script>
<mx:ArrayCollection id="myAc">
<mx:source>
<mx:Object version="1.0" telephone="9875454214" />
<mx:Object version="2.0" telephone="8794568784" />
<mx:Object version="3.0" telephone="8796454487" />
</mx:source>
</mx:ArrayCollection>
<mx:HBox>
<mx:DataGrid verticalScrollPolicy="on" focusEnabled="false" name="Version" id="Version" width="100%" height="65" dataProvider="{myAc}" >
<mx:columns >
<mx:DataGridColumn width="150" dataField="version" headerText="Version" />
<mx:DataGridColumn width="70" dataField="telephone" headerText="Telephone" />
<mx:DataGridColumn width="90" paddingLeft="20" headerText="Download">
<mx:itemRenderer>
<mx:Component>
<mx:Image height="10%" source="css/page_excel.png" click = "outerDocument.getDetails()" enabled = "{outerDocument.isEnabled}" />
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
</mx:HBox>
</mx:Application>
This application is programmed to disable the Image when it is clicked and Enable the same after 5 sec. But it is disabling whole Column. I want it to disable only the clicked Image.
Change your mxml
<!--<mx:Image height="10%" source="css/page_excel.png" click = "outerDocument.getDetails()" enabled = "{outerDocument.isEnabled}" />-->
<mx:Image height="10%" source="css/page_excel.png" click = "outerDocument.getDetails(event)" />
And here is the AS code.
public function getDetails(event: MouseEvent):void {
Alert.show("Got it!!");
//isEnabled = false;
event.target.enabled = false; // Disable clicked Object.
myTimer = new Timer(5000, 1);
//myTimer.addEventListener(TimerEvent.TIMER_COMPLETE, timerHandler);
myTimer.addEventListener(TimerEvent.TIMER_COMPLETE, nextfuncWithParams(timerHandler, event.target)); // Pass clicked object.
myTimer.start();
}
public function nextfuncWithParams(nextfunc: Function, params: Object): Function {
return function(event:TimerEvent): void{
nextfunc(event, params);
}
}
public function timerHandler(event: TimerEvent, MouseEventTarget: Object):void {
//isEnabled = true;
MouseEventTarget.enabled = true; // Enable passed object.
}
Working Example: http://wonderfl.net/c/Gv9k
Update
For using Image.
public function getDetails(event: MouseEvent):void {
//Alert.show("Got it!!");
//event.target.enabled = false; // event.target was Loader...
var obj: Object = event.target;
while (obj.parent)
{
if (obj is Image)
{
Image(obj).enabled = false;
break;
}
obj = obj.parent;
}
myTimer = new Timer(5000, 1);
//myTimer.addEventListener(TimerEvent.TIMER_COMPLETE, timerHandler);
myTimer.addEventListener(TimerEvent.TIMER_COMPLETE, nextfuncWithParams(timerHandler, obj));
myTimer.start();
}

OK button in a dialog popup not working in flex

I am new to learning flex and I have this application which opens up a popup displays some checkbox values and the once the user clicks the OK button populates an array and then closes. But in my code, when I click the OK button nothing happens.
private function closeDialog(event : CloseEvent) : void {
PopUpManager.removePopUp(this); // close this dialog
}
private function onClickOK (event : CloseEvent) : void {
var values:ArrayCollection = new ArrayCollection();
for (i = 0; i < table.length; i++) {
var row:Array = table.getItemAt(i);
if (row["selected"]) {
var valueRow:Array = new Array();
arrayRow["colA"] = row["colA"];
values.addItem(valueRow);
}
}
page.model["choosenvalues"] = values;
closeDialog(event);
}
And here is the flex code
<mx:VBox paddingLeft="10" paddingRight="10">
<mx:HBox width="100%" height="100%">
<mx:Spacer width="2%" />
<mp:Table id="selectTable" dataProvider="{table}" title="" height="350">
<mp:columns>
<mx:AdvancedDataGridColumn dataField="selected" headerText=" " editable="true" textAlign="center" minWidth="36" width="36" paddingLeft="0" paddingRight="0">
<mx:itemRenderer>
<mx:Component>
<mx:CheckBox width="18" click="{data.selected = !data.selected}" label="" paddingLeft="0" paddingRight="0"/>
</mx:Component>
</mx:itemRenderer>
</mx:AdvancedDataGridColumn>
<mx:AdvancedDataGridColumn headerText="Column A" minWidth="240" dataField="colA"/>
</mp:columns>
</mp:Table>
</mx:HBox>
<mx:HBox width="100%">
<mx:Spacer width="85%" />
<mx:Button label="OK" click="onClickOK(null)" enabled="true"/>
<mx:Button label="Cancel" click="closeDialog(null)"/>
</mx:HBox>
</mx:VBox>
Try removing the event parameters from methods, since you don't use them. Anyway, the onclick handler should accept MouseEvent or just Event, not CloseEvent.
private function closeDialog() : void {
PopUpManager.removePopUp(this); // close this dialog
}
private function onClickOK () : void {
...
closeDialog();
}
MXML:
<mx:Button label="OK" click="onClickOK()" enabled="true"/>
<mx:Button label="Cancel" click="closeDialog()"/>
Note: parameterless event handlers are possible with MXML, since if you try it with AS, you'll get warnings.

Flex datagrid printing issue with page size

I need to print the following datagrid in A4 size page. It is not fitting with with page size and dataprovider is not working for the printdatagrid.Pleasecorrect me.
The current output is:
My data grid :
<mx:DataGrid id="dashboardList" width="100%" height="95%"
alternatingItemColors="[0x373737, 0x373737]"
borderColor="#FFFFFF" borderStyle="inset"
chromeColor="#295A7D" contentBackgroundColor="#373737"
dataProvider="{allTrancList}" fontWeight="normal"
horizontalGridLineColor="#858585" click="productDatagrid_clickHandler(event)"
horizontalGridLines="true" variableRowHeight="true"
wordWrap="true">
<mx:columns>
<mx:DataGridColumn width="60" headerText="S.No"
labelFunction="serialNoLabelFunc2"/>
<mx:DataGridColumn width="60" dataField="trancCode"
headerText="Order ID"/>
<mx:DataGridColumn dataField="date" headerText=" Date"
labelFunction="getDateLabel"/>
<mx:DataGridColumn dataField="clientName"
headerText="Client name"/>
<mx:DataGridColumn width="90" dataField="clientCode"
headerText="Client code"/>
<mx:DataGridColumn dataField="itemType"
headerText="Work/Product"/>
<mx:DataGridColumn width="60" dataField="itemNumbers"
headerText="Count"/>
<mx:DataGridColumn dataField="cost" headerText="Cost"/>
<mx:DataGridColumn dataField="discountAmount"
headerText="Discount"/>
<mx:DataGridColumn dataField="tax" headerText="Tax"/>
<mx:DataGridColumn dataField="total" headerText="Total"/>
<mx:DataGridColumn dataField="paymondmode"
headerText="Payment mode"/>
</mx:columns>
</mx:DataGrid>
My printData grid:
<mx:PrintDataGrid id="myDataGrid" width="99%" height="100%">
<mx:columns>
<mx:DataGridColumn width="60" dataField="trancCode"
headerText="Order ID"/>
<mx:DataGridColumn dataField="clientName"
headerText="Client"/>
<mx:DataGridColumn width="90" dataField="clientCode"
headerText="Client code"/>
<mx:DataGridColumn dataField="itemType"
headerText="Type"/>
<mx:DataGridColumn width="60" dataField="itemNumbers"
headerText="Count"/>
<mx:DataGridColumn dataField="cost" headerText="Cost"/>
<mx:DataGridColumn dataField="discountAmount"
headerText="Discount"/>
<mx:DataGridColumn dataField="tax" headerText="Tax"/>
<mx:DataGridColumn dataField="total" headerText="Total"/>
<mx:DataGridColumn dataField="paymondmode"
headerText="Payment mode"/>
</mx:columns>
</mx:PrintDataGrid>
My code for print:
var thePrintView:FormPrintView = new FormPrintView();
addElement(thePrintView);
// Set the print view properties.
thePrintView.width=printJob.pageWidth;
thePrintView.height=printJob.pageHeight;
thePrintView.prodTotal = prodTotal;
// Set the data provider of the FormPrintView
// component's DataGrid to be the data provider of
// the displayed DataGrid.
// thePrintView.myDataGrid=PrintDataGrid(dashboardList);
thePrintView.myDataGrid.dataProvider =allTrancList;
You can look for AlivePDF or PurePDF, Both options will provide you more space to spread your wings with lots of possibilities and can cater ever changing requirements.
Please find code below (this code is just an insight about the possibility in respect to your requirement, and you can find whole lib of test files from purePDF site [linked above])-
package
{
import flash.events.Event;
import org.purepdf.colors.RGBColor;
import org.purepdf.elements.Paragraph;
import org.purepdf.elements.RectangleElement;
import org.purepdf.pdf.PdfPCell;
import org.purepdf.pdf.PdfPTable;
public class PdfPTableColors extends DefaultBasicExample
{
public function PdfPTableColors(d_list:Array=null)
{
super(["Customize border and background color","of table cells"]);
}
override protected function execute(event:Event=null):void
{
super.execute();
createDocument();
document.open();
registerDefaultFont();
var table: PdfPTable = new PdfPTable(4);
table.widthPercentage = 100;
var cell: PdfPCell;
cell = PdfPCell.fromPhrase(new Paragraph("test colors:"));
table.addCell(cell);
cell = PdfPCell.fromPhrase(new Paragraph("red / no borders"));
cell.border = RectangleElement.NO_BORDER;
cell.backgroundColor = RGBColor.RED;
table.addCell(cell);
cell = PdfPCell.fromPhrase(new Paragraph("green / magenta bottom border"));
cell.border = RectangleElement.BOTTOM;
cell.borderColorBottom = RGBColor.MAGENTA;
cell.borderWidthBottom = 10;
cell.backgroundColor = RGBColor.GREEN;
table.addCell(cell);
cell = PdfPCell.fromPhrase(new Paragraph("blue / cyan top border + padding"));
cell.border = RectangleElement.TOP;
cell.useBorderPadding = true;
cell.borderWidthTop = 5;
cell.borderColorTop = RGBColor.CYAN;
cell.backgroundColor = RGBColor.BLUE;
table.addCell(cell);
cell = PdfPCell.fromPhrase(new Paragraph("test GrayFill:"));
table.addCell(cell);
cell = PdfPCell.fromPhrase(new Paragraph("0.25"));
cell.border = RectangleElement.NO_BORDER;
cell.grayFill = 0.25;
table.addCell(cell);
cell = PdfPCell.fromPhrase(new Paragraph("0.5"));
cell.border = RectangleElement.NO_BORDER;
cell.grayFill = 0.5;
table.addCell(cell);
cell = PdfPCell.fromPhrase(new Paragraph("0.75"));
cell.border = RectangleElement.NO_BORDER;
cell.grayFill = 0.75;
table.addCell(cell);
cell = PdfPCell.fromPhrase(new Paragraph("test bordercolors:"));
table.addCell(cell);
cell = PdfPCell.fromPhrase(new Paragraph("different borders"));
cell.borderWidthLeft = 6;
cell.borderWidthBottom = 5;
cell.borderWidthRight = 4;
cell.borderWidthTop = 2;
cell.borderColorLeft = RGBColor.RED;
cell.borderColorBottom = RGBColor.ORANGE;
cell.borderColorRight = RGBColor.YELLOW;
cell.borderColorTop = RGBColor.GREEN;
table.addCell(cell);
cell = PdfPCell.fromPhrase(new Paragraph("with correct padding"));
cell.useBorderPadding = true;
cell.borderWidthLeft = 6;
cell.borderWidthBottom = 5;
cell.borderWidthRight = 4;
cell.borderWidthTop = 2;
cell.borderColorLeft = RGBColor.RED;
cell.borderColorBottom = RGBColor.ORANGE;
cell.borderColorRight = RGBColor.YELLOW;
cell.borderColorTop = RGBColor.GREEN;
table.addCell(cell);
cell = PdfPCell.fromPhrase(new Paragraph("orange border"));
cell.borderWidth = 6;
cell.borderColor = RGBColor.ORANGE;
table.addCell(cell);
document.add(table);
document.close();
save();
}
}
}

mx:TileList : Why drag doesn't works if allowMultipleSelection is activate

I work with TileList to display image like a gallery.
At start, I activate only drag option.
<mx:TileList xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
columnWidth="120"
rowHeight="150"
paddingLeft="2"
paddingRight="2"
paddingTop="2"
paddingBottom="2"
itemRenderer="fr.ui.display._43Imagerie.TileUnit2"
doubleClickEnabled="true"
dragEnabled="true"
dropEnabled="true"
dragMoveEnabled="true"
verticalScrollPolicy="on"
>
Now I try to add multiple selection possibility.
ItemRenderer is :
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"
verticalScrollPolicy="off"
horizontalScrollPolicy="off"
width="120"
height="150"
borderVisible="false"
xmlns:s="library://ns.adobe.com/flex/spark"
creationComplete="onEvent()"
>
<mx:Script>
<![CDATA[
import fr.util.imageTransform;
import mx.controls.Image;
import mx.core.UIComponent;
import mx.events.DragEvent;
import mx.managers.DragManager;
import org.osmf.utils.URL;
import spark.effects.Rotate;
[Bindable]
[Embed(source="icon/imagerie/rotate.png")]
private var rotationArrowClass:Class;
private var _file:File;
private var _selected:Boolean;
private var _sauvBMD:BitmapData;
public var wasScaled:Boolean = false;
public var deleted:Boolean = false;
private var bgCenterX:Number;
private var bgCenterY:Number;
private var _dragDownPt:Point;
[Bindable]
public var angle:int = 0;
private var dragBitmapData : BitmapData;
private function onEvent():void
{
// iconCanvas.addEventListener(MouseEvent.DOUBLE_CLICK, onDoubleClick);
// double click gere ds wPlanchePhoto3
}
private function rotationImage(e:MouseEvent):void
{
var rot:Rotate = new Rotate();
rot.angleBy = 90;
rot.duration = 1000;
rot.autoCenterTransform = true;
rot.target = iconCanvas;
rot.play();
}
private function radiansToDegrees(radians:Number):Number {
var degrees:Number = radians * (180 / Math.PI);
return degrees;
}
private function degreesToRadians(degrees:Number):Number {
var radians:Number = degrees * (Math.PI / 180);
return radians;
}
public function set image(im:BitmapData):void
{
this._sauvBMD=im;
}
public function get image() :BitmapData
{
return this._sauvBMD;
}
protected function iconCanvas_mouseDownHandler(event:MouseEvent):void
{
// on enregistre la point de départ
_dragDownPt = new Point(mouseX,mouseY);
// puis on écoute l'éventuel déplacement de la souris
this.addEventListener(MouseEvent.MOUSE_MOVE,_onMouseMoveDuringDrag);
}
private function _onMouseMoveDuringDrag(evt:MouseEvent):void {
// astuce pour s'assurer que la souris a vraiment bougee volontairement
if(Math.abs(_dragDownPt.x - mouseX) <= 2 && Math.abs(_dragDownPt.y - mouseY) <= 2)
return;
else{
dragBitmapData = new BitmapData(iconCanvas.width, iconCanvas.height,true, 1);
dragBitmapData.draw(iconCanvas);
var transfert:Clipboard = new Clipboard();
transfert.setData(ClipboardFormats.BITMAP_FORMAT,Bitmap(iconCanvas.content).bitmapData);
// only allow the file to be copied
var dragOptions:NativeDragOptions = new NativeDragOptions();
dragOptions.allowMove=false;
dragOptions.allowCopy = true;
dragOptions.allowLink = false;
// begin the drag
NativeDragManager.doDrag(this, transfert, dragBitmapData, null, dragOptions);
}
// dispatch de l'event depuis le parent pour pouvoir écouter cet event dans l'application
}
]]>
</mx:Script>
<s:BorderContainer
id="bcImage"
width="120"
height="99%"
borderVisible="true"
borderColor="#FFFFFF"
borderWeight="1"
cornerRadius="6"
backgroundAlpha=".4"
backgroundColor="#5f5f5f"
>
<mx:Canvas id="cvsImage" width="100%">
<mx:SWFLoader id="rotationArrow" source="{rotationArrowClass}" height="18" width="18" x="3" y="3" visible="true" click="rotationImage(event);" alpha=".5"/>
<s:Label x="23" y="3" width="82" fontSize="11" fontWeight="normal" text="{data.imDate}"
textAlign="right" color="#000000"/>
<mx:Image id="iconCanvas" x="10" y="20" width="99" height="99" horizontalAlign="center"
maintainAspectRatio="true" scaleContent="true"
source="{data.imURL}"
verticalAlign="middle" mouseDown="iconCanvas_mouseDownHandler(event)"
>
</mx:Image>
</mx:Canvas>
<s:VGroup width="100%" y="124" height="25" bottom="1" left="3" right="3" paddingBottom="0" paddingTop="4" gap="0">
<s:Label text="{data.imType}" height="50%" fontSize="10" paddingBottom="1"
fontWeight="normal" width="99%" textAlign="center" color="#000000"/>
<s:Label text="{data.imStade}" fontSize="10" textAlign="center" paddingTop="1"
fontWeight="normal" width="99%" color="#000000"/>
</s:VGroup>
</s:BorderContainer>
If this option is true (allowMultipleSelection), drag stop to work, do you know why?
Thanks for helping.
Adding allowMultipleSelection="true" worked just fine for me. I am running on a Mac with latest version of Flash Player. It seemed a bit flaky at first but after refreshing the page it worked just fine. Only thing I didn't have in my project was your data provider and item renderer. I really doubt your item renderer would cause an issue unless you are doing something crazy in there. Check to see if you have the latest Flash Player.