Hello below is the code I am using for a project. My problem is when I trace the stageRef.width in the constructor and in the function both of them output different values. My stage is 980 x 700 pixels but whenever I trace something related to dimension such as x,y,width or height I got corrupt results.
Thanks
package com.gh {
import flash.display.MovieClip;
import flash.display.Stage;
import flash.events.Event;
import com.greensock.*;
import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.display.*;
public class index extends MovieClip {
private var thepreloader:contentpreloader;
public var stageRef:MovieClip = new MovieClip();
public function index() {
setStage(980,700);
thepreloader = new contentpreloader(this.loaderInfo);
stageRef.addChild(thepreloader);
trace(stageRef.width); // This outputs 1019.8
thepreloader.addEventListener("loadComplete", loadAssets);
thepreloader.addEventListener("preloaderFinished", showSponsors);
trace("Index init");
}
private function loadAssets(e:Event) : void
{
this.play();
}
private function showSponsors(e:Event) : void
{
stageRef.removeChild(thepreloader);
trace("show sponsors");
}
private function setStage(stageWidth:uint , stageHeight:uint)
{
stageRef.graphics.beginFill(0x0567f1, 1);
stageRef.graphics.drawRect(0,0,stageWidth, stageHeight);
stage.addChild(stageRef);
trace(stageRef.width); // This outputs normal
trace("Stage Set 980 x 700 pixels");
}
}
}
Is this something code related ?
thanks