Skip to main content
Inspiring
October 3, 2016
Question

copy from internet and loading in IPAD.

  • October 3, 2016
  • 3 replies
  • 526 views

Dear Friends,

iam using the following code to copy from internet and loading in IPAD.

import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.filesystem.File;
import flash.filesystem.FileMode;
import flash.filesystem.FileStream;
import flash.net.FileReference;
import flash.net.URLLoader;
import flash.net.URLLoaderDataFormat;
import flash.net.URLRequest;
import flash.utils.ByteArray;
import flash.display.Loader;
import flash.system.LoaderContext;
import flash.system.ApplicationDomain;

var file_url: String = "";
var lc: LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
var ldr: Loader = new Loader();

DownloadFileMobileAS3();
function DownloadFileMobileAS3() {
// support autoOrients
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
createLoader();
}
function createLoader(): void {
// TODO Auto-generated method stub
var urlLoader: URLLoader = new URLLoader();
urlLoader.addEventListener(Event.COMPLETE, complete_handler);
urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
urlLoader.load(new URLRequest("http://www.abc.com/test.swf"));
}

function complete_handler(event: Event): void {
var data: ByteArray = event.target.data;
var fileStream: FileStream = new FileStream();
fileStream.addEventListener(Event.CLOSE, fileWritten);
trace("something copied...");
txt.text = "something copied...";
fileStream.open(new File(File.documentsDirectory.nativePath + "\\test.swf"), FileMode.WRITE);

file_url = File.documentsDirectory.nativePath +"\\test.swf";

fileStream.writeBytes(data, 0, data.length);
fileStream.close();
load_file();
}

function fileWritten(e: Event): void {
trace("File Saved to Desktop");
}

function load_file() {
ldr = new Loader();
var req: URLRequest = new URLRequest(file_url);
ldr.load(req, lc);
//ldr.load(req);
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, loading_finished);
}

function loading_finished(event: Event) {
trace("loading finished");
addChild(ldr);
}

All are working fine in computers, when I install in IPAD its not working. pls check and answere me if iam missing some....

Thanks and Regards,

Syed Abdul Rahim

This topic has been closed for replies.

3 replies

rahimhajiAuthor
Inspiring
October 5, 2016

HI Ankit,

Thanks a lot... sure I wil try this and tell u...

Thanks and Regards,

Syed Abdul Rahim

rahimhajiAuthor
Inspiring
October 4, 2016

HI Ankit,

Thanks for your reply. I tried it, but not working same I cannot copy files to my ipad. Is there any way to copy files from internet to ipad and use as asset for our app?

Thanks and Regards,

Syed Abdul Rahim

Anki_AG_
Adobe Employee
Adobe Employee
October 5, 2016

Hi Syed,

Our team is following up  with you via forum thread Re: Download assests from internet in Air for IOS .

Thanks,

Adobe AIR Team

Anki_AG_
Adobe Employee
Adobe Employee
October 3, 2016

Hi Syed,


Request you to please go through Flash Player Help | Release Notes | Flash Player® 20 AIR® 20  and check under iOS SDK upgrade section. Please let us know if modifying your code as per instructions mentioned in release notes works for you.

Thanks,

Ankit

Adobe AIR Team