Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Methods to download assets from Internet in Air for IOS

Participant ,
Oct 18, 2016 Oct 18, 2016

Dear Friends,

Greetings! kindly advice me the ways and methods to download assets (swf files) from internet when running the app first time in IPAD.

I tried to write files in to IPAD using write bytes (byte array). iam opening filestream in write mode.

i.e.

fileStream.writeBytes(data_val, 0, data_val.length);

it is not allowing the script (AS3) to copy in to IPAD. Pls suggest me what are all other methods to download assets(swf files) from internet.

Thanks in advance,

Thanks and Regards,

Syed Abdul Rahim

TOPICS
ActionScript
767
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 19, 2016 Oct 19, 2016

use the loader class to load swfs.

if there's actionscript in the loaded swf, use a loadercontext, http://blogs.adobe.com/airodynamics/2012/11/09/packaging-and-loading-multiple-swfs-in-air-apps-on-io...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 19, 2016 Oct 19, 2016

Dear Mr.Kglad,

Greetings! thks for the reply. Already iam using loader class with loadercontext, pls check my previous post...

URLLoader is not working Air for IOS but working in computer

its is working with computer not working with IPAD. when I down load files from internet its is not allowing script for secondary swf files.. My logic is download swf assests (which contains AS script, animation & sound) from internet to reduce my app size, in IPAD it is downloading and saving in application storage directory, it is downloading only animation and sound not script.. it keep moving without even stop..

pls help me to solve this.

Thanks in advance,

Syed Abdul Rahim

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 20, 2016 Oct 20, 2016

copy and paste the code related to your loader.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 21, 2016 Oct 21, 2016

Hi Kglad,

Greetings!, code is available below:

import flash.display.Loader;
import flash.net.URLLoader;
import flash.filesystem.*;
import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.system.LoaderContext;

downloadFile("http://www.examplesite.com/test.swf");

//---------------------------------Downloading files - Starts------------------------------------------------
function downloadFile(file_location): void {
var urlLoader: URLLoader = new URLLoader();
urlLoader.addEventListener(Event.COMPLETE, download_completed);
urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
urlLoader.load(new URLRequest(file_location));
}

function download_completed(event: Event): void {
var data: ByteArray = event.target.data;
copy_files(data, "test.swf");
}

function copy_files(data_val, path) {
var fileStream: FileStream = new FileStream();
txt.text = "something copied...";
fileStream.open(File.applicationStorageDirectory.resolvePath(path), FileMode.WRITE);
fileStream.writeBytes(data_val, 0, data_val.length);
fileStream.close();
down_data();
txt.text =" something copied... " + File.applicationStorageDirectory.resolvePath(path).exists;
//---------------------------------Downloading files - Ends------------------------------------------------
menu1_les1.addEventListener(MouseEvent.CLICK, m1click);
function m1click(event: MouseEvent) {
req.url = "app-storage:/test.swf";
ldr.load(req, lc);
addChild(ldr);
}

Just create a new Air for IOS copy paste this, create one button(menu1_les1) and one text box (txt) on the state. it will work.  For ur info, I can download and load the same file in windows. But in IOS tab I can down load and load the files, but loaded files are swf with only image and animation script is not working. I have a doubt may be writing as binary is may be the issue. pls help me to solve this.

Thanks and Regards,

Syed Abdul Rahim

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 21, 2016 Oct 21, 2016

that code wouldn't even compile because ldr isn't defined.

use:

var ldr:Loader=new Loader();

var req:URLRequest=new URLRequest("http://www.examplesite.com/test.swf");

var lc:LoaderContext=new LoaderContext(false,ApplicationDomain.currentDomain,null);

ldr.load(req,lc);

addChild(ldr);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 21, 2016 Oct 21, 2016

Mr.kglad,

Greetings! i sent u only downloading and loading portion... i have already added ldr and lc..:) i thought that are all u will add... still it is not running in IPAD.. only in windows computer it is not working.. pls help me

Thanks and Regards,

Syed Abdul Rahim

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 21, 2016 Oct 21, 2016

use the code i suggested.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 23, 2016 Oct 23, 2016

Mr.kglad,

I tried, it is not working, I don't want to load a swf and attach in app, I want to download the swf file with action script to IPAd and load the same file when ever I want.

Thanks and Regards,

Syed Abdul Rahim

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 24, 2016 Oct 24, 2016
LATEST

what exactly is not working?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines