Hello Everybody
I am going in circles with loading an external swf into a movieclip on the timeline and need help urgently.
There is a hotspot movieclip which is linked to following class:
package {
import flash.display.MovieClip;
import flash.events.*;
import flash.net.URLRequest;
import flash.display.DisplayObject;
import flash.display.Loader;
import Picture_Container;
public class HotSpot1 extends MovieClip{
var reqName:String;
var target:DisplayObject;
function HotSpot1():void{
this.addEventListener(MouseEvent.CLICK, PictureCall);
this.buttonMode = true;
}
public function PictureCall(event:MouseEvent):void{
reqName = this.name + ".swf";
trace(reqName);
trace(this.parent.name);
target = this.parent.getChildByName("picture_container");
trace(target);
trace(target.name);
trace(this.parent.getChildIndex(target));
trace(target.parent.name);
var req:URLRequest = new URLRequest(reqName);
var loader:Loader = new Loader();
loader.load(req);
//this.parent.picture_container.addChild(loader);
}
}
}
the .addChild(loader) code is the problem, therefore commented out. All the traces work perfectly and when clicking on the instance Page_01 of the hotspot movieclip I get following output:
Page_01.swf
Gallery_Background
[object Picture_Container]
picture_container
103
Gallery_Background
However, if I activate the addChild line it throws following error:
1119: Access of possibly undefined property picture_container through a reference with static type flash.display:DisplayObjectContainer.
The movieclip which should load the swf is linked to the class:
package {
import flash.display.MovieClip;
import HotSpot1;
public class Picture_Container extends MovieClip{
function Picture_Container():void{
trace(this.parent.name);
trace(this.name);
}
}
}
the traces work and the output shows:
Gallery_Background
picture_container
Thanks to all of you for giving it your thoughts