hpnotiqtymes
05-02-2009, 04:16 PM
Hi All,
Im creating a multiple file upload system and so far it works perfect accept for one thing..im trying to implement a itemRenderer for each object in the form of a progress bar but every time i try to bind the data.obj to the progress column of the datagrid i made to display the info i get this error:
warning: unable to bind to property 'object' on class 'Object' (class is not an IEventDispatcher)
ive tried using ObjectProxy, creating a seperate class that extends EventDispatcher and Object to hold the variables that are going to be bound and yet i still get the error here is my mxml:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="600" height="500">
<mx:Script>
<![CDATA[
import mx.utils.ObjectProxy;
import mx.events.CollectionEvent;
import mx.collections.ArrayCollection;
import flash.net.FileReferenceList;
private var imageTypes:FileFilter = new FileFilter ( "Images (*.jpg)", "*.jpg");
private var allTypes:Array = new Array ( imageTypes );
private var fileRef:FileReferenceList = new FileReferenceList();
private var imageSelected:Boolean;
[Bindable] private var arrayCollection:ArrayCollection = new ArrayCollection();
[Bindable] private var tf:ObjectProxy;
private function addImages (event:MouseEvent):void
{
//arrayCollection.removeAll();
//arrayCollection.refresh();
fileRef.addEventListener ( Event.SELECT, selectHandler );
fileRef.browse ( allTypes );
}
private function selectHandler ( e:Event ):void
{
var fileList:Array = fileRef.fileList;
for ( var i:Number = 0; i < fileList.length; i++ )
{
var file:FileReference = FileReference ( fileList[i] );
var tf:TheFile = new TheFile();
tf.name = file.name;
tf.size = file.size;
tf.obj = file;
arrayCollection.addItem ( tf );
}
}
private function uploadImages (event:MouseEvent):void
{
var fileList:Array = fileRef.fileList;
for ( var i:Number = 0; i < fileList.length; i++ )
{
var urlRequest:URLRequest = new URLRequest ( "upload.php" );
var file:FileReference = FileReference ( fileList[i] );
file.upload ( urlRequest );
}
arrayCollection.removeAll();
arrayCollection.refresh();
}
]]>
</mx:Script>
<mx:Style source="styles.css"/>
<mx:Panel layout="absolute" title="IMAGE QUEUE" width="523" horizontalAlign="center" horizontalCenter="-9" height="412" verticalCenter="2">
<mx:Button id="upload" click="uploadImages(event)" y="339" label="UPLOAD" height="31" width="245" fontWeight="bold" fontFamily="Arial" horizontalCenter="129"/>
<mx:Button id="browse" click="addImages(event)" y="339" label="BROWSE" height="31" width="245" fontWeight="bold" fontFamily="Arial" horizontalCenter="-128"/>
<mx:DataGrid id="dataGrid" dataProvider="{arrayCollection}" y="15" width="500" horizontalCenter="0" height="312">
<mx:columns>
<mx:DataGridColumn headerText="Name" dataField="name" width="100"/>
<mx:DataGridColumn headerText="Size" dataField="size" width="30"/>
<mx:DataGridColumn headerText="Progress" dataField="obj" width="150" paddingLeft="2">
<mx:itemRenderer>
<mx:Component>
<mx:HBox verticalAlign="middle">
<mx:ProgressBar label="" height="6" source="{data.obj}"/>
</mx:HBox>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
</mx:Panel>
</mx:Application>
any help would be appreciated thanks in advanced..
Im creating a multiple file upload system and so far it works perfect accept for one thing..im trying to implement a itemRenderer for each object in the form of a progress bar but every time i try to bind the data.obj to the progress column of the datagrid i made to display the info i get this error:
warning: unable to bind to property 'object' on class 'Object' (class is not an IEventDispatcher)
ive tried using ObjectProxy, creating a seperate class that extends EventDispatcher and Object to hold the variables that are going to be bound and yet i still get the error here is my mxml:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="600" height="500">
<mx:Script>
<![CDATA[
import mx.utils.ObjectProxy;
import mx.events.CollectionEvent;
import mx.collections.ArrayCollection;
import flash.net.FileReferenceList;
private var imageTypes:FileFilter = new FileFilter ( "Images (*.jpg)", "*.jpg");
private var allTypes:Array = new Array ( imageTypes );
private var fileRef:FileReferenceList = new FileReferenceList();
private var imageSelected:Boolean;
[Bindable] private var arrayCollection:ArrayCollection = new ArrayCollection();
[Bindable] private var tf:ObjectProxy;
private function addImages (event:MouseEvent):void
{
//arrayCollection.removeAll();
//arrayCollection.refresh();
fileRef.addEventListener ( Event.SELECT, selectHandler );
fileRef.browse ( allTypes );
}
private function selectHandler ( e:Event ):void
{
var fileList:Array = fileRef.fileList;
for ( var i:Number = 0; i < fileList.length; i++ )
{
var file:FileReference = FileReference ( fileList[i] );
var tf:TheFile = new TheFile();
tf.name = file.name;
tf.size = file.size;
tf.obj = file;
arrayCollection.addItem ( tf );
}
}
private function uploadImages (event:MouseEvent):void
{
var fileList:Array = fileRef.fileList;
for ( var i:Number = 0; i < fileList.length; i++ )
{
var urlRequest:URLRequest = new URLRequest ( "upload.php" );
var file:FileReference = FileReference ( fileList[i] );
file.upload ( urlRequest );
}
arrayCollection.removeAll();
arrayCollection.refresh();
}
]]>
</mx:Script>
<mx:Style source="styles.css"/>
<mx:Panel layout="absolute" title="IMAGE QUEUE" width="523" horizontalAlign="center" horizontalCenter="-9" height="412" verticalCenter="2">
<mx:Button id="upload" click="uploadImages(event)" y="339" label="UPLOAD" height="31" width="245" fontWeight="bold" fontFamily="Arial" horizontalCenter="129"/>
<mx:Button id="browse" click="addImages(event)" y="339" label="BROWSE" height="31" width="245" fontWeight="bold" fontFamily="Arial" horizontalCenter="-128"/>
<mx:DataGrid id="dataGrid" dataProvider="{arrayCollection}" y="15" width="500" horizontalCenter="0" height="312">
<mx:columns>
<mx:DataGridColumn headerText="Name" dataField="name" width="100"/>
<mx:DataGridColumn headerText="Size" dataField="size" width="30"/>
<mx:DataGridColumn headerText="Progress" dataField="obj" width="150" paddingLeft="2">
<mx:itemRenderer>
<mx:Component>
<mx:HBox verticalAlign="middle">
<mx:ProgressBar label="" height="6" source="{data.obj}"/>
</mx:HBox>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
</mx:Panel>
</mx:Application>
any help would be appreciated thanks in advanced..