Hello,
I’m trying to develop very simple image portfolio app for iOS using AS3.
I have difficulties to understand how to include image assets for my app.
Due to various resolutions of the devices, I have various files for every image, for example:
image_480.png
image_960.png
image_1024.png
image_1136.png
image_2048.png
Now, depending on the detected device resolution I want app to load appropriate image (“image_” + version + “.png”).
The problem is I don’t know how to include all the images within my app to access them.
My code:
package {
import flash.display.Bitmap;
import flash.display.Loader;
import flash.display.MovieClip;
import flash.events.Event;
import flash.net.URLRequest;
public class zeeto extends MovieClip {
private var image: Bitmap = new Bitmap;
private var loader: Loader;
private var stageW: int;
private var imageW: int;
public function zeeto() {
addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event):void {
removeEventListener(Event.ADDED_TO_STAGE, init);
// Stage test
stageW = stage.stageWidth;
if (stageW > 1136) imageW = 2048;
else if (stageW > 1024) imageW = 1136;
else if (stageW > 960) imageW = 1024;
else if (stageW > 480) imageW = 960;
else imageW = 480;
image.smoothing = true;
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, displayImage);
loader.load(new URLRequest("app:/Assets/image_" + imageW + ".png"));
}
private function displayImage(e:Event):void {
image = loader.content as Bitmap;
image.x = 0 - ((image.width - stage.stageWidth) / 2);
image.y = 0 - ((image.height - stage.stageHeight) / 2);
addChild(image);
}
}
}
Structure of the project files:
zeeto.ipa
zeeto.fla
com/zeeto/zeeto.as
Where do I put the “Assets” folder and how to tell the compiler to include it’s content within zeeto.ipa file?
Thank you