PDA

View Full Version : errors with stageWidth/stageHeight in package



bmilesp
March 17th, 2008, 01:39 AM
hello everyone, I'm trying to make a class that will scale a clip when the stage resizes. I have the Stage resize set to NO_SCALE so the majority of clips on the stage will not scale, however i want to make an exception. So i wrote the package below. However, when i try to run the movie, it throws this error:

1119: Access of possibly undefined property stageWidth through a reference with static type Class.

Obviously i'm missing something and need some help. Thanks in advance.

package bmilesp.display.LayoutTools {

import flash.display.Stage;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.display.MovieClip;

public class LayoutTools {

private var _stageOriginalWidth:Number = Stage.stageWidth;
private var _stageOriginalHeight:Number = Stage.stageHeight;

public function scaleWithStage(my_clip:MovieClip):void{
var scaleChangeWidth:Number = Stage.stageWidth/_stageOriginalWidth;
var scaleChangeHeight:Number = Stage.stageHeight/_stageOriginalHeight;
my_clip.width = my_clip.width * scaleChangeWidth;
my_clip.height = my_clip.height * scaleChangeHeight;
}
}

}

Felixz
March 17th, 2008, 04:04 PM
use lower case 'stage' word

bmilesp
March 19th, 2008, 05:38 AM
Thanks- That was part of the problem. But the main problem was that i didn't instantiate the class.

also, if you call the package the same name at the class, as i obliviously did above- the import will not recognize it. The total solution including code and example site is here:
http://fornicode.com/2008/03/18/flash-as3-liquid-layouts-and-scalable-movieclips/ (http://fornicode.com/2008/03/18/flash-as3-liquid-layouts-and-scalable-movieclips/)

Also, thak you Felixz for your two cents!