I’ve got 2 files. Main.swf loads text.swf and then dispatches an event to text.swf to let it know what text to load in it’s textfield. After reading ton’s of tutorials and googling for hours I still can’t figure it out.
Main.swf:
var theText:String = "text1";
var loader:Loader = new Loader();
loader.load(new URLRequest("text.swf"));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, addme);
function addme(e:Event)
{
addChild(loader);
dispatchEvent(new Event("Changer", true));
}
text.swf
addEventListener("Changer", CreateTextfield);
function CreateTextfield(event:Event)
{
trace(event.target.theText)
}
I don’t get any errors, except if I mispell “Changer” or leave the quotes out. That makes me think the code is fine. If I put the dispatchevent in text.swf It works. It just wont work when I put it in main.swf
I don’t get it. Every tutorial I found starts talking about custom event classes, importing them and public this, private that. So I tried that aproach, by importing a custom event class in both files, put them all in 1 folder. I tried different custom event classes I found on the web. No success.
Do I approach this wrongly?