Highlighted

URLLoader is not working Air for IOS but working in computer

Participant ,
Oct 12, 2016

Copy link to clipboard

Copied

Dear Friends,

iam trying to download files from internet and store it in IPAD. I used the below code it was loading sometimes back now its not working. Actually in computer iam getting the msg its downloaded in local. But in IPAD (IOS) its not downloading.... pls help me how to solve this...

import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.net.*;
import flash.events.Event;
import flash.utils.ByteArray;

var req: URLRequest = new URLRequest("http://www.abc.com/test.swf");
var urlLoader: URLLoader = new URLLoader();
urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
urlLoader.load(req);

urlLoader.addEventListener(Event.COMPLETE, url_loaded);

function url_loaded(event: Event) {
txt.text = "file loaded";
var data:ByteArray = event.target.data;
txt.text = data.toString();
}

Thanks and Regards,

Syed Abdul Rahim

TOPICS
Development

Views

2.0K

Likes

Translate

Translate

Report

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

URLLoader is not working Air for IOS but working in computer

Participant ,
Oct 12, 2016

Copy link to clipboard

Copied

Dear Friends,

iam trying to download files from internet and store it in IPAD. I used the below code it was loading sometimes back now its not working. Actually in computer iam getting the msg its downloaded in local. But in IPAD (IOS) its not downloading.... pls help me how to solve this...

import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.net.*;
import flash.events.Event;
import flash.utils.ByteArray;

var req: URLRequest = new URLRequest("http://www.abc.com/test.swf");
var urlLoader: URLLoader = new URLLoader();
urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
urlLoader.load(req);

urlLoader.addEventListener(Event.COMPLETE, url_loaded);

function url_loaded(event: Event) {
txt.text = "file loaded";
var data:ByteArray = event.target.data;
txt.text = data.toString();
}

Thanks and Regards,

Syed Abdul Rahim

TOPICS
Development

Views

2.0K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Oct 12, 2016 0
Contributor ,
Oct 12, 2016

Copy link to clipboard

Copied

The connection to a remote server must now use https not http when using URLLoader

AIR 20.0.0.233 URLMonitor broken with iOS 9 ?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 12, 2016 0
Participant ,
Oct 12, 2016

Copy link to clipboard

Copied

hi yachts9999,

I tried with https, its not working...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 12, 2016 0
Contributor ,
Oct 12, 2016

Copy link to clipboard

Copied

Does the server you are trying to contact have a certificate installed?

Have you tried contacting the server using https in your browser as in

https://www.abc.com

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 12, 2016 0
Participant ,
Oct 12, 2016

Copy link to clipboard

Copied

Hi yachts,

Greetings! thks for the reply. I tried https: its not working. Then I tried other option by adding

<key>NSAppTransportSecurity</key>

  <dict>

    <key>NSAllowsArbitraryLoads</key>

    <true/>

  </dict>

in InfoAdditions, its working fine.. Thanks a lot..

Then iam loading the copied files from applicationstorage directory.. its loading fine.. but giving sand box error like below:

*** Security Sandbox Violation ***

SecurityDomain 'app-storage:/lessons/m1_les1/swf/test.swf' tried to access incompatible context 'app:/down_5.swf'

SecurityError: Error #2070: Security sandbox violation: caller app-storage:/lessons/m1_les1/swf/test.swf cannot access Stage owned by app:/down_5.swf.

at flash.display::Stage/requireOwnerPermissions()

at flash.display::Stage/addEventListener()

Pls help me to solve this...

Thanks and Regards,

Syed Abdul Rahim

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 12, 2016 0
Adobe Employee ,
Oct 12, 2016

Copy link to clipboard

Copied

Hi Syed,

Have you tried using security.allowDomain("*"); in your code?

Please try adding below lines:

import flash.system.Security;

Security.allowDomain("*");

If this works, you will want to change it from "*" to the specific domain of the swf you are loading.

Kindly let us know if it helps you.

Thanks,

Adobe AIR Team

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 12, 2016 0
Participant ,
Oct 13, 2016

Copy link to clipboard

Copied

HI deesharm,

Greetings! yes I have used Security.allowDomain...

its not working... still error:

please note that I have copied the files to ipad using fileStream.writeBytes...  will it create any problem? and loading the file using loader

my code is like below:

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();

}

loading is:

var ldr:loader = new loader();

var filePath = "assetstest.swf" + "?tt=" + Math.random();

  req = new URLRequest(filePath);

  req.cacheResponse = false;

  req.useCache = false;

  ldr.load(req, lc);

Thanks and Regards,

Syed Abdul Rahim

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 13, 2016 0
Adobe Employee ,
Oct 13, 2016

Copy link to clipboard

Copied

Hi Syed,

Could you please share a sample application with us.

I will look into it further at my end.

Thanks,

Adobe AIR Team

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 13, 2016 0
Participant ,
Oct 16, 2016

Copy link to clipboard

Copied

Hi deesharm,

Greetings, thks for the help, actually iam downloading files from internet (with the help of write byte array) and copying to storage directory of IPAD, and loading the same by using loader object.  pls check my codings below:

//---------------------------------Downloading files - Starts------------------------------------------------
var te: Number = 0;
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, menuXML.module.lesson.sfile[initFileNum].toString());
}

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();
initFileNum++;
down_data();
txt.text = initFileNum + " something copied... " + File.applicationStorageDirectory.resolvePath(path).exists + initFileNum;
}
//---------------------------------Downloading files - Ends------------------------------------------------

For Loading main frame
----------------------

var filePath = "assets/lmsframe.swf" + "?tt=" + Math.random();
req = new URLRequest(filePath);
req.cacheResponse = false;
req.useCache = false;
ldr.load(req, lc);
ldr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loading_ioerror);
ldr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loading_progress);
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, loading_finished);

Inside main frame loading the sub files:
----------------------------------------

loaders[loadedCount] = new Loader()
var lc3: LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
lc3.allowCodeImport = true;
var fn;
if (MovieClip(parent.parent.parent) != null) {
fn = main_mc.storagePath + main_mc.currentClickedModule + fileNames[loadedCount] + "?tt=" + Math.random(); //--new addition for ios.
} else {
fn = main_mc.mainPath + main_mc.currentClickedModule + fileNames[loadedCount]
}

loaders[loadedCount].load(new URLRequest(String(fn)), lc3);
loaders[loadedCount].contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadingFiles)
loaders[loadedCount].contentLoaderInfo.addEventListener(Event.COMPLETE, fileLoadComplete)
}

It is downloading (swf) and writing in application storage directory and loading fine when I loading, it is loading the swf fine in computer (image, animation and script). BUt in IPAD it is loading only image and animations in the swf script is not running. it is not even stopping keep running as loop.

pls help me.

Thanks and Regards,

Syed Abdul Rahim

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 16, 2016 0
Participant ,
Oct 17, 2016

Copy link to clipboard

Copied

Hi deesharm,

Greetings! I have checked with dummy swf files with script. when we use "URLLoaderDataFormat.BINARY" and "ByteArray" to download files from internet, IOS is not allowing to write AS3 script. its writing only picture and animations.. its not writing script.

please advice me is thee any other way to download files from internet using Air for IOS? pls

Thanks in advance,

Regards,

Syed Abdul Rahim

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 17, 2016 0
Participant ,
Oct 17, 2016

Copy link to clipboard

Copied

Hi deesharm,

Greetings!, sample app is 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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 17, 2016 0
Adobe Employee ,
Oct 18, 2016

Copy link to clipboard

Copied

Hi Syed,

I have modified your sample application and tried running it on iPhone 6 plus(iOS 9).

It's working fine at my end. Please find the code snippet below:

import flash.display.Loader;

import flash.net.URLLoader;

import flash.filesystem.*;

import flash.events.MouseEvent;

import flash.net.URLRequest;

import flash.system.LoaderContext;

import flash.system.*;

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

//---------------------------------Downloading files - Starts------------------------------------------------

functiondownloadFile(file_location): void {

varurlLoader: Loader = new Loader();

var context:LoaderContext = new LoaderContext();

var request:URLRequest = new URLRequest(file_location);

context.applicationDomain=ApplicationDomain.currentDomain;

urlLoader.addEventListener(Event.COMPLETE, download_completed);

//urlLoader.dataFormat = URLLoaderDataFormat.BINARY;

urlLoader.load(request,context);

}

function download_completed(event: Event): void {

var data: ByteArray = event.target.data;

copy_files(data, "test.swf");

}

function copy_files(data_val, path) {

varfileStream: 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) {

var req:URLRequest = new URLRequest();

varldr:Loader = new Loader();

varlc:LoaderContext = new LoaderContext();

lc.applicationDomain = ApplicationDomain.currentDomain

req.url = "app-storage:/test.swf";

ldr.load(req, lc);

  trace("loading complete");

//addChild(ldr);

}

Please specify exceptions to the default behavior by adding keys to InfoAdditions tag of application descriptor of your app.

Thanks,

Deepika

Adobe AIR Team

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 18, 2016 0
New Here ,
Apr 25, 2018

Copy link to clipboard

Copied

Hi all,

Syed was using the URLLoader class, and Deepika (from Adobe) modified the code snippet to use Loader instead.  Does this mean URLLoader is not supported for iOS developers?

Thanks!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 25, 2018 4
Participant ,
Oct 18, 2016

Copy link to clipboard

Copied

Dear M/s.Deepika,

Greeings! thks for the help. Its working fine.  Please read my previous post. Even I store in application storage directory its working. only problem is its not stopping, running continuously because its IOS is allowing to write only animations and images in swf. it is not writing action script even stop() command, so its keep running without stopping and other script is not working.

Pls check your swf, it has got only animation and sound, there is no script or any interaction. pls tell me the way to download or write the swf file with script.

Thanks and Regards,

Syed Abdul Rahim

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 18, 2016 0
Participant ,
Oct 18, 2016

Copy link to clipboard

Copied

hi deepika,

pls add a swf file which contains script (AS3) in it and see pls help me to solve this...

Thanks and Regards,

Syed Abdul Rahim

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 18, 2016 0