So I've been having some trouble getting something to work. The problem is much bigger than what I'm showing you but I've located the source of the problem. I'm getting strange results when trying to override a function here is the code for the two classes in question:
package
{
public class ScaleableObject extends GameObject
{
public var percentX:Number;
public var percentY:Number;
public var percentWidth:Number;
public var percentHeight:Number;
public function ScaleableObject($percentX:Number, $percentY:Number, $percentWidth:Number, $percentHeight:Number)
{
super();
percentX = $percentX;
percentY = $percentY;
percentWidth = $percentWidth;
percentHeight = $percentHeight;
}
public function screenChange($width:Number, $height:Number):void
{
x = percentX*$width;
y = percentY*$height;
width = percentWidth*$width;
height = percentHeight*$height;
trace("----->",$width+"*"+percentWidth+"="+width,$height+"*"+percentHeight+"="+height);
}
}
}
package ui
{
public class MainMenu extends ScaleableObject
{
public function MainMenu($percentX:Number, $percentY:Number, $percentWidth:Number, $percentHeight:Number)
{
super($percentX, $percentY, $percentWidth, $percentHeight);
}
override public function screenChange($width:Number, $height:Number):void
{
trace($width+"*"+percentWidth+"="+width,$height+"*"+percentHeight+"="+height);
super.screenChange($width,$height);
trace($width+"*"+percentWidth+"="+width,$height+"*"+percentHeight+"="+height);
}
}
}
The only other thing that happens is that a mainMenu object is created and then everytime there is a resize event it calls screenChange()
Here are the results of the traces
320*1=0 480*1=0
-----> 320*1=0 480*1=0
320*1=0 480*1=0
The the first one is called before the super.screenChange() the second is inside the super classes method and the third is after the call.
The second one is what blows my mind. Look at the results and then look at where the trace came from. I just printed the two inputs and the output and apparently it doesn't know how to multiply properly? I have no idea whats going on, any help would be fantastic. Also if anyone needs any clarification just ask.