Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Developer
Posts: 71
Registered: ‎04-27-2011
My Device: Bold 9700 and Playbook 64
My Carrier: Rogers
Accepted Solution

How to reference files or make URLRequest's to files

I have a class that stores all of the relative paths of .jpgs in an array as strings. (that works)

 

it ends up giving me the below info stored in an array called 'files'

 

/accounts/1000/appdata/appname/shared/downloads/one.jpg
/accounts/1000/appdata/appname/shared/downloads/two.jpg
/accounts/1000/appdata/appname/shared/downloads/three.jpg etc....

 

I am then trying to make a URLRequest with the above strings like so:
var request:URLRequest = new URLRequest(files[1]);
_loader.load(request);

then

_bitmapData.draw(_loader, new Matrix()); //to draw the bitmap to screen

 

this is simplified for the example, but you get the idea... I hope.

 

On debug, I get the error:
SecurityError: Error 2000: No Active security context.
I have run into this before if the path or filename is not correct.
Is this the wrong path to point to when trying to load a file?
what string would I have to type to request one of these files?
e.g.
var request:URLRequest = new URLRequest("What do I type here?");

 

TIA,
dave

 

 

Developer
Posts: 71
Registered: ‎04-27-2011
My Device: Bold 9700 and Playbook 64
My Carrier: Rogers

Re: How to reference files or make URLRequest's to files

Added: In case your wondering I also have the <action>access_shared</action> tags in my blackberry-tablet.xml file
Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: How to reference files or make URLRequest's to files

Try pre-pending 'file://' or 'file:///" to the path.
Contributor
Posts: 15
Registered: ‎04-04-2011
My Device: None
My Carrier: Verzion

Re: How to reference files or make URLRequest's to files

Also if your using an flash.display.Loader there is no need to redraw your data. Accessing loader.content will give you an instance of the loaded Bitmap. One last note, not sure if your are addressing this or not, but you must wait until Event.COMPLETE or Event.INIT ( i always go with the latter) before drawing/accessing the loader.content or drawing onto a bitmap as you have in your example.
Playbook Applications : ArrangeIt File Manager
Developer
Posts: 71
Registered: ‎04-27-2011
My Device: Bold 9700 and Playbook 64
My Carrier: Rogers

Re: How to reference files or make URLRequest's to files

As soon as if saw file:// I smacked my head... of course, why would it assume... we have to put http:// for net requests.

 

thanks,

 

I am loading the bitmap on the Event.COMPLETE

 

_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoad);

 

I'll change it to Event.INIT, thanks for the advice.

 

I was using the _bitmapData container to transform the bitmap before displaying it while retaining the original in the loader. Not that I know this is the right way to do it, Its just the way I know. I will explore the flash .display.Loader packages. Always good to know of other ways that are more efficient. Thanks for your post.