Hey this is my as code
package
{
import flash.display.MovieClip;
import flash.display.Stage;
import flash.text.TextField;
public class thumbNail extends MovieClip
{
import flash.net.*;
import flash.events.Event;
public var loader:URLLoader;
public var xml:XML;
public var xmlList:XMLList;
public var ontr:int;
public var thumbText:TextField;
public var thumbCont:MovieClip;
private static var stageRef:Stage;
public function thumbNail(ont:int):void
{
ontr = ont;
loader = new URLLoader();
loader.load((new URLRequest("xml/thumbNail"+ontr+".xml")));
loader.addEventListener(Event.COMPLETE, xmlLoaded);
stageRef = this.stage;
}
private function xmlLoaded(event:Event):void
{
var count:int = 0;
xml = new XML(event.target.data);
xmlList = new XMLList(xml.children());
for(var i:int=0; i<xmlList.length(); i++)
{
thumbCont = new MovieClip();
thumbText = new TextField();
thumbText.text = xmlList*.attribute("title");
//trace(thumbText.text);
stageRef.addChild(thumbCont);
thumbCont.addChild(thumbText);
thumbText.textColor = 0x666666;
thumbCont.x = -100;
thumbCont.y = count;
thumbCont.buttonMode = true;
count += 8;
}
}
}
}
I call this as file from my flash movie on a mouse over instant like this
var thumbs:thumbNail = new thumbNail(1);
The problem is that the moiveclips thumbCont are not getting added to stage. Instead I get this error -
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at thumbNail/xmlLoaded()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
out
The culprit is this line of code from what I figure out - stageRef.addChild(thumbCont);
Am I not referring to the stage of the flash movie (the one that is calling this action script) properly. What am I doing wrong? Please Help.