flash actionscript:
I am discovering the event dispatcher concept in flash and am trying to get it
working.
I have a site that is made of a main swf that will load multiple swf. The site
has 2 languages.
The ultimate goal, in my project, is when the user selects another language,
to dispatch a message,
heard by all the different swf files, that will then separately update their
own elements to the proper
language.
To start simple, I have the following:
- one main file, called test.fla. It has only one frame and nothing in it,
except this code :
stop();
_root.createEmptyMovieClip("dyntitle", this.getNextHighestDepth());
dyntitle._x = 0.0;
dyntitle._y = 0.0;
dyntitle.loadMovie("title.swf");
title.fla has also one frame only containing a button called "flag"
this frame has the following code;
stop();
flag.onRelease = function(){
var test:LangUpdater = new LangUpdater();
test.updateLang();
}
I also have a separate class file LangUpdater.as:
import mx.events.EventDispatcher
class LangUpdater{
function dispatchEvent() {};
function addEventListener() {};
function removeEventListener() {};
function LangUpdater(){
mx.events.EventDispatcher.initialize(this);
}
function updateLang(){
var eventObject: Object = {target:_root, type:'languageToUpdate'};
dispatchEvent(eventObject);
}
}
It does not work, meaning, i do not get the trace out. However, if I move the
2 lines
var test:LangUpdater = new LangUpdater();
test.updateLang();
in the test.fla file, then it works. What did i do wrong? Obviously, there is
something i did not caught.
Thanks in advance for your help that will be appreciated.