All I have on my stage is one MovieClip, instance-named “box_mc”.
On Frame 1 (which is the only frame out there), I have this code:
[AS]
import com.placement.LiquidLayout;
var newAligner:LiquidLayout = new LiquidLayout(box_mc, 300, 300);
addChild(newAligner);[/AS]
And in my class file (which is based on the StageManager class by noponies.com) I have this code:
[AS]
package com.placement {
import flash.display.*;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
public class LiquidLayout extends Sprite {
//declaring the variables
private var managedObject:InteractiveObject;
private var xAxis:Number;
private var yAxis:Number;
//building the constructor
public function LiquidLayout(target:InteractiveObject, xpos:Number, ypos:Number) {
//getting local variables
managedObject = target;
xAxis = xpos;
yAxis = ypos;
//executing the actions
setLayout();
stage.addEventListener(Event.RESIZE, resizeListener);
}
private function resizeListener() {
setLayout();
}
private function setLayout() {
managedObject.x = xAxis;
managedObject.y = yAxis;
}
}
}[/AS]
And when I test my movie, everything works correctly, though I get this in the Output window:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.placement::LiquidLayout$iinit()
at test_fla::MainTimeline/test_fla::frame1()
Can anyone explain, why this happens, and how I should fix the class file to have no such warnings in the future.
Thanks in advance, Here are the source files: