user1761777
user1761777

Reputation: 131

How do I access assets inside a APK file using ActionScript 3? (Adobe AIR)

I've made a program using Flash Pro CS6. Now, using Adobe AIR, I export it to "AIR for Android". In the settings, under "included files" I've added a folder "images" to be packaged inside the resulting APK file. This folder contains JPG images.

After export I've got the APK file. If I open it in WinRAR there is a folder "assets" there. Inside are main.swf (my program) and the folder "images" (that contains JPG imags).

My question is, how can I access these packaged JPG images via ActionScript 3 in my program?

For example the image "/assets/images/0001.jpg", I want to be able to display it at runtime in my swf (that is also packaged inside the APK file and is being run through AIR on Android).

I can't embed the JPG images inside the swf file directly because they are too many. And the images must be packaged inside the actual APK file.

Upvotes: 4

Views: 3127

Answers (1)

user1761777
user1761777

Reputation: 131

Figured it out myself, or rather realized it with some help, in my other question:

Reading JPG into BitmapData in ActionScript 3 (JPG is inside APK file)

loader.load(new URLRequest("app:/images/image.jpg"));

Just have to use the COMPLETE event and keep in mind that the VM is single-threded so I can't "sleep a thread" while the image loads.

Upvotes: 6

Related Questions