Hi i am designing a site where i will be loading content into an empty movieclip, the content wil consist of a few movieclip that are moveable and they will each contain buttons within them. Now i want the buttons to control what is displayed within the main timelines empty movieclip, however i am having trouble in making the buttons effect the empty movieclip, i thought the code below should have worked but it doesnt:
[AS]homeBttn.addEventListener(MouseEvent.CLICK, loadWeb);
function loadWeb(evt:Event):void {
var pageLoader:Loader = new Loader();
var pageURLReq:URLRequest = new URLRequest ( “pages/AS3 Portfolio Main.swf”);
var swf:MovieClip;
pageLoader.load(pageURLReq);
pageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
function imageLoaded(evt:Event):void {
holder.addChildAt(pageLoader.content, 1 );
holder.removeChildAt(2);
swf = evt.target.content;
var button:MovieClip = swf.paper2.websiteBttn;
button.addEventListener(MouseEvent.CLICK, openWeb);
}
function openWeb(e:Event):void {
var pageLoader:Loader = new Loader();
var pageURLReq:URLRequest = new URLRequest ( "pages/AS3 Portfolio Web.swf");
pageLoader.load(pageURLReq);
pageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
function imageLoaded(evt:Event):void {
holder.addChildAt(pageLoader.content, 1 );
holder.removeChildAt(2);
}
}
}[/AS]
As you can see once the main button is clicked the main content is loaded in “AS3 Portfolio Main.swf”, and then it checks for a completion of that load and adds it to the stage. Then i created a variable (swf) to look for the button within the loaded movieclip on completion of the load, once that was done i wanted the program to look for the click event of that button and then run the click function by changing the content in the empty movieclip to the appropraite content. But all that i get is the error below:
[AS]TypeError: Error #1009: Cannot access a property or method of a null object reference.
at MethodInfo-8()[/AS]
is there any1 who can help me with this please thanks??