I believe you are missing:
loader.dataFormat = URLLoaderDataFormat.BINARY;
This is what causes the .data
property to return a ByteArray
.
Some more comments for your specific case:
- Be careful to remove the event listeners from loader or you'll get a memory leak. You should have loader be a class variable and remove those listeners in both the
imageLoaded
handler and theloadingError
handler. - For maximum quality / efficiency, there is a tool called PVRTexTool that can create better quality / smaller compressed textures than
png2atf
. I wrote about it some in the starling forums. - You're probably already aware, but you didn't mention target platform and there are different compressed GPU texture formats for each as outlined in the ATF introduction on adobe.com. You'll need to use the appropriate encoding per target platform. I found another answer where I elaborated the png2atf commands per platform.