My goal at the moment is to simply add a bitmap to the display, and have it fit the entire screen width and resize it’s height proportionally… I have some coding done, but here’s where I’m stuck: Initially the bitmap does not display properly, but when using the same code in my resizeHandler() the image corrects itself and displays properly.
Here’s the code:
package {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.net.*;
import br.com.stimuli.loading.*;
import caurina.transitions.*;
import flash.net.URLRequest;
public class Photography extends MovieClip {
var loader : BulkLoader = new BulkLoader("main-site");
//Photos
var swings : Bitmap = new Bitmap;
public function Photography() {
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
this.stage.addEventListener(Event.RESIZE, resizeHandler);
loader.add("images/swings.jpg", {id:"01"});
loader.addEventListener(BulkLoader.COMPLETE, allLoaded);
loader.start();
}
public function allLoaded(event:Event): void {
swings = loader.getBitmap("01");
swings.width = stage.stageWidth;
swings.x = (stage.stageWidth / 2) - (swings.width / 2);
swings.y = (stage.stageHeight / 2) - (swings.height / 2);
var ratio : Number = swings.scaleX;
swings.scaleY = ratio;
addChild(swings);
}
public function resizeHandler(event:Event): void {
swings.width = stage.stageWidth;
swings.x = (stage.stageWidth / 2) - (swings.width / 2);
swings.y = (stage.stageHeight / 2) - (swings.height / 2);
var ratio : Number = swings.scaleX;
swings.scaleY = ratio;
}
}
}
I’m hoping I’m missing something small and simple, and any help is appreciated!