Note that there are some explanatory texts on larger screens.

plurals
  1. POCan not able to download image from web in flex mobile app
    text
    copied!<p>I want to download an image from <code>URL</code> to my <code>Mobile</code> using <code>Flex Mobile</code>. I have found <a href="http://blog.flexexamples.com/2007/07/28/downloading-files-in-flex-using-the-filereference-class/" rel="nofollow">This</a> and tried this: </p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;s:View xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" title="HomeView"&gt; &lt;fx:Declarations&gt; &lt;!-- Place non-visual elements (e.g., services, value objects) here --&gt; &lt;fx:Model id="fileRefModel"&gt; &lt;file&gt; &lt;creationDate&gt;{""}&lt;/creationDate&gt; &lt;creator&gt;{""}&lt;/creator&gt; &lt;modificationDate&gt;{""}&lt;/modificationDate&gt; &lt;name&gt;{""}&lt;/name&gt; &lt;size&gt;{""}&lt;/size&gt; &lt;type&gt;{""}&lt;/type&gt; &lt;/file&gt; &lt;/fx:Model&gt; &lt;/fx:Declarations&gt; &lt;fx:Script&gt; &lt;![CDATA[ import mx.collections.ArrayCollection; import flash.net.FileReference; [Bindable] private var arrColl:ArrayCollection; // URL of the file to download. private const FILE_URL:String = "http://www.thebiblescholar.com/android_awesome.jpg"; private var fileRef:FileReference; private var urlReq:URLRequest; private function init():void { // Initialize the array collection to an empty collection. arrColl = new ArrayCollection(); // Set up the URL request to download the file specified by the FILE_URL variable urlReq = new URLRequest(FILE_URL); // Define file reference object and add a bunch of event listeners. fileRef = new FileReference(); fileRef.addEventListener(Event.CANCEL, doEvent); fileRef.addEventListener(Event.COMPLETE, doEvent); fileRef.addEventListener(Event.OPEN, doEvent); fileRef.addEventListener(Event.SELECT, doEvent); fileRef.addEventListener(HTTPStatusEvent.HTTP_STATUS, doEvent); fileRef.addEventListener(IOErrorEvent.IO_ERROR, doEvent); fileRef.addEventListener(ProgressEvent.PROGRESS, doEvent); fileRef.addEventListener(SecurityErrorEvent.SECURITY_ERROR, doEvent); } private function doEvent(evt:Event):void { // Create shortcut to the FileReference object. var fr:FileReference = evt.currentTarget as FileReference; // Add event order and type to the DataGrid control. arrColl.addItem({data:arrColl.length+1, type:evt.type, eventString:evt.toString()}); try { // Update the Model. fileRefModel.creationDate = fr.creationDate; fileRefModel.creator = fr.creator; fileRefModel.modificationDate = fr.modificationDate; fileRefModel.name = fr.name; fileRefModel.size = fr.size; fileRefModel.type = fr.type; // Display the Text control. //txt.visible = true; } catch (err:*) { // uh oh, an error of sorts. } } private function downloadSourceCodeZip():void { // Clear existing array collection. arrColl = new ArrayCollection(); fileRef.download(urlReq); // Here it gives me Exception &gt;&gt; (Suspended: TypeError: Error #1009: Cannot access a property or method of a null object reference.) } ]]&gt; &lt;/fx:Script&gt; &lt;s:Button label="Download" click="downloadSourceCodeZip()"/&gt; </code></pre> <p> but I'm getting <code>Suspended: TypeError: Error #1009: Cannot access a property or method of a null object reference.</code> how to make this code work for me></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload