Jump to content
Search Community

LoaderMax on Air for iOS problem

Laertes test
Moderator Tag

Recommended Posts

Hi, I am having a problem with LoaderMax on Air for iOS. My solution works fine on air for android, but apple doesn't allow you to store downloaded files in the application folder, it has to go into ../Library/Caches instead.

 

i am downloading to this from the net to

 

 

savePath= new File(File.applicationDirectory.nativePath +"/\.\./Library/Caches/" + filename);

 

fileStream.open(savePath, FileMode.WRITE);

urlStream.load(new URLRequest(url));

..

..

 

urlStream.readBytes(fileData, 0, urlStream.bytesAvailable);

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

 

which works fine.

 

when i try to load the downloaded files with loadermax it bombs.

 

 

 

it works very well on android but i cant get LoaderMax fo find the files on iOS.

i get the following error when debugging on OSX:

 

i add a number of files with:

			   			   var queue:LoaderMax = new LoaderMax({name:"soundQueue", onComplete:loopSoundsCompleteHandler, onError:errorHandler});
					 						 fileName =  "Library/Caches/" + fileName;
									queue.append( new MP3Loader(fileName, {name:"name1", repeat:-1, autoPlay:false}) );
...
...

and then i load the queue with

queue.load();

 

and i reveice the following error:

 

Error on MP3Loader 'bpallah' (Library/Caches/resources/snd/bpall.mp3): Error #2032: Stream Error. URL: app:/Library/Caches/resources/snd/bpall.mp3

 

Does anyone have a clue how to do this?

 

regards,

/Lars

Link to comment
Share on other sites

That error means that the file isn't at that URL that you provided. Frankly I'm not familiar with the ins and outs of AIR apps on iOS or where you need to store/retrieve files, etc. If someone else can chime in here, that'd be great. But suffice it to say that the problem is definitely that the file isn't where you're telling LoaderMax to look, so maybe try some different URLs (relative paths, etc.)

Link to comment
Share on other sites

  • 1 month later...
  • 2 weeks later...
  • 1 month later...

Hi,

I have been digging a bit more into this problem.

 

if i use the following code:

 

 

var str:String = File.applicationDirectory.nativePath;

trace(str);

_pointModel.mainImage= LoaderMax.getContent(str+"/\.\./Library/Caches/resources/img/4/4_mamma.jpg");

trace(_pointModel.mainImage);

var file:File = new File(str +"/\.\./Library/Caches/resources/img/4/4_mamma.jpg");

 

if(file.exists) {

trace("exists");

}

 

the traces will show:

 

 

/Users/larshansson/Documents/src/ParkenMobile/bin-debug

null

exists

 

So the file seems to be in the right place, but the LoaderMax.getContent() method returns null.

 

if I try to load it explicitly with ImageLoader

 

 

var loader:ImageLoader = new ImageLoader(str +"/\.\./Library/Caches/resources/img/4/4_mamma.jpg", {name:"photo1", container:_pointModel.mainImage,scaleMode:"proportionalInside", centerRegistration:true, onComplete:onImageLoad, onError:onErrorCode});

 

 

I get the following error:

 

 

error:ImageLoader 'photo1' (/Users/larshansson/Documents/src/ParkenMobile/bin-debug/../Library/Caches/resources/img/4/4_mamma.jpg) > Error #2035: URL Not Found. URL: app:/Users/larshansson/Documents/src/ParkenMobile/Library/Caches/resources/img/4/4_mamma.jpg

 

if I change the path above to:

 

var loader:ImageLoader = new ImageLoader("app:/\.\./Library/Caches/resources/img/4/4_mamma.jpg", {name:"photo1", container:_pointModel.mainImage,scaleMode:"proportionalInside", centerRegistration:true, onComplete:onImageLoad, onError:onErrorCode});

 

i get

 

 

*** Sandbox error ***

Access tp app:/../Library/Caches/resources/img/4/4_mamma.jpg has been stopped - not allowed from app:/ParkenMobile.swf

 

 

regards,

/Lars

Link to comment
Share on other sites

1) it is a ContentDisplay

 

2) null

 

i am loading the data with this code from an external xml document:

 

var xmlFileName:String = "/resources/txt/punkt4.xml";

LoaderMax.activate([VideoLoader, ImageLoader, SWFLoader, DataLoader, MP3Loader]);

loader1= new XMLLoader(xmlFileName, {name:"xmlDoc",skipFailed:true, noCache:true, onComplete:handleXMLLoaded, onError:handleError});

loader1.load();

 

the file punkt4.xm l is allowed to be placed under app-storage as i compile it into to the swf.

 

the punkt4.xml file looks like this:

 

<?xml version="1.0" encoding="UTF-8"?>

...

<data>

<LoaderMax name="dynamicLoaderMax" load="true">

<ImageLoader name="4_mamma" url="app-storage:/resources/img/4/4_mamma.jpg" load="true"/>

<ImageLoader name="4_mhandtag" url="app-storage:/resources/img/4/cutout/4_mhandtag.jpg" load="true"/>

<ImageLoader name="4_mjorden" url="app-storage:/resources/img/4/cutout/4_mjorden.jpg" load="true"/>

<ImageLoader name="4_mdocka" url="app-storage:/resources/img/4/cutout/4_mdocka.jpg" load="true"/>

<ImageLoader name="4_mbrev" url="app-storage:/resources/img/4/cutout/4_mbrev.jpg" load="true"/>

<MP3Loader name="bs2" url="app-storage:/resources/snd/bs2.mp3" load="true" autoPlay="false" repeat="1"/>

</LoaderMax>

</data>

 

it works like charm on all other platforms, but then again on those platforms i can place the files were they are supposed to be. Not were apple forces me to put them.

 

I am getting to a point were i might just compile all the data into the .swf and be done with it.

 

/Lars

Link to comment
Share on other sites

Yeah, I'm not quite sure what to suggest here, especially since I'm not experienced with iOS and the idiosyncrasies of where it requires files, which actions trip security problems, etc. Your inclination to put things into an .swf file sounds pretty solid at this point.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...