Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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...
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
copy and paste the code related to your loader.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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);
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
use the code i suggested.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
what exactly is not working?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now