I’m very new to Flash and OOP and trying to create a user customisable touch screen interface - in which people can include their own button styles (currently created as movie clips). I have a working XML file that names the style / external swf name for each button but I don’t seem to be able to then duplicate that movie clip for say use in 10 separate buttons. When I try this only the last one created is displayed. I can of course separately load the file 10 times but that is yuk.
I hope to be able to position the timeline through n states in each loaded clip independently and also have one click handler that can return me an identifier of which was clicked - I know how to loop/create dynamic instance names.
<edit> I can do this successfully from the library - just not as an external file load - where the MC won’t be in the library at all.
//Initialize variable to hold target data
var targetClip:MovieClip;
//********* Add a "MovieClip" variable that will reference the root of the loaded clip:**********
var targetRoot:MovieClip;
var originalClip:MovieClip = new MovieClip();
originalClip.x = 10;
originalClip.y = 10;
addChild(originalClip);
var ld:Loader = new Loader();
var swf:URLRequest = new URLRequest("test.swf");
ld.load(swf);
ld.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
function onComplete(e:Event):void {
//Set content target to "targetClip" variable
targetClip = e.currentTarget.content.test;
//********* Assign the reference of the root of the loaded clip to the "targetRoot" variable: *********
targetRoot = e.currentTarget.content;
originalClip.addChild(ld);
//If I remove these next five lines the original clip shows but with them in the original clip diisappears which is not what I want
var copyClip:MovieClip = new MovieClip();
copyClip = MovieClip(DisplayObject(originalClip));
copyClip.x=100;
copyClip.y=100
addChild(copyClip);
}