Thanks Glen ive added listener and seams to be ok! Need to test a live version now tho! ----- Original Message ----- From: Glen Pike To: Flash Coders List Sent: Tuesday, May 20, 2008 12:53 PM Subject: Re: [Flashcoders] AS3 - Upload image problem
Apologies, it is. You need to add listeners for all the events that FileReference dispatches. At a minimum you need to listen for the select event to begin uploading: file.addEventListener(Event.SELECT, selectHandler); Here is a link to the Flex 2 langref with an example that adds all the listeners - check the Flash one if you are using CS3, but the class should be the same, so you may be okay. http://livedocs.adobe.com/flex/201/langref/flash/net/FileReference.html#includeExamplesSummary HTH Glen SJM - Flash wrote: > Glen is that not for AS2? > ----- Original Message ----- > From: Glen Pike > To: Flash Coders List > Sent: Tuesday, May 20, 2008 12:30 PM > Subject: Re: [Flashcoders] AS3 - Upload image problem > > > http://www.tink.ws/blog/a-round-trip-with-filereference/ > > SJM - Flash wrote: > > Hi guys im having problems with uploading an image, i cant seam to get it to work! Most of the code is from the help files but still no joy! Any ideas... > > > > public function uploadImage( ev:MouseEvent ):void > > { > > uploadURL = new URLRequest(); > > uploadURL.url = _mainClass._imgUploadURL; > > file = new FileReference(); > > file.browse(getTypes()); > > trace("uploadImage: " + ev); > > } > > > > > > The above trace outouts this... > > > > uploadImage: [MouseEvent type="click" bubbles=true cancelable=false eventPhase=3 localX=16 localY=4 stageX=95.65 stageY=236.70000000000002 relatedObject=null ctrlKey=false altKey=false shiftKey=false delta=0]] > > > > As far as i can tell it does not go any further into the code below! > > > > private function getTypes():Array { > > var allTypes:Array = new Array(getImageTypeFilter()); > > return allTypes; > > } > > > > > > private function getImageTypeFilter():FileFilter { > > return new FileFilter("Images (*.jpg, *.jpeg)", "*.jpg;*.jpeg;"); > > } > > > > > > private function cancelHandler(ev:Event):void { > > trace("cancelHandler: " + ev); > > } > > > > private function completeHandler(ev:Event):void { > > trace("completeHandler: " + ev); > > } > > > > private function uploadCompleteDataHandler(ev:Event):void { > > trace("uploadCompleteData: " + ev); > > _xmlClass.xmlLoader("bannerInfo.xml"); > > _xmlClass.addEventListener(Event.COMPLETE, _mainClass.afterUploadXML); > > } > > > > private function httpStatusHandler(ev:HTTPStatusEvent):void { > > trace("httpStatusHandler: " + ev); > > } > > > > private function ioErrorHandler(ev:IOErrorEvent):void { > > trace("ioErrorHandler: " + ev); > > } > > > > private function openHandler(ev:Event):void { > > trace("openHandler: " + ev); > > } > > > > private function progressHandler(ev:ProgressEvent):void { > > var file:FileReference = FileReference(ev.target); > > trace("progressHandler name=" + file.name + " bytesLoaded=" + ev.bytesLoaded + " bytesTotal=" + ev.bytesTotal); > > } > > > > private function selectHandler(event:Event):void { > > var file:FileReference = FileReference(event.target); > > trace("selectHandler: name=" + file.name + " URL=" + uploadURL.url); > > file.upload(uploadURL); > > } > > _______________________________________________ > > Flashcoders mailing list > > [email protected] > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > > > > > > > -- > > Glen Pike > 01326 218440 > www.glenpike.co.uk <http://www.glenpike.co.uk> > > _______________________________________________ > Flashcoders mailing list > [email protected] > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > _______________________________________________ > Flashcoders mailing list > [email protected] > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > > -- Glen Pike 01326 218440 www.glenpike.co.uk <http://www.glenpike.co.uk> _______________________________________________ Flashcoders mailing list [email protected] http://chattyfig.figleaf.com/mailman/listinfo/flashcoders _______________________________________________ Flashcoders mailing list [email protected] http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

