@ Cryzto "where's the practical difference between this solution and the
solution where I just tell the Buttons to do what I want"

There is nothing I could say that Muzak hasn't already said better and
repeatedly. With that, search this list on EventDispatcher, encapsulation,
and dirty ass code.

http://www.mail-archive.com/[email protected]/msg31071.html 
http://www.mail-archive.com/[email protected]/msg31112.html 

Hasta!


//
//      NO EVENTS
//


var main = this;
var array = [ 'de', 'fr', 'it', 'en' ];
for ( var i in array )
{
        var btn = this[array[i]];
        btn.onRelease =
function(){_root.lang_xml.load("conf_"+this.label.toLowerCase()+".xml");};
}


//
//      WITH EVENTS
//


var array = [ 'de', 'fr', 'it', 'en' ];
for ( var i in array )
{
        var btn = this[array[i]];
        mx.events.EventDispatcher.initialize( btn );
        btn.addEventListener( 'click', mx.utils.Delegate.create ( this,
loadLanguage ) );
        btn.onRelease = releaseHandler;
}

function releaseHandler ()
{
        this.dispatchEvent({type:'click',target:this,
lang:this.label.toLowerCase() });
}

function loadLanguage ( evt:Object ) 
{
        _root.lang_xml.load("conf_"+evt.lang+".xml");
}


_____________________________

Jesse Graupmann
www.jessegraupmann.com   
www.justgooddesign.com/blog/  
_____________________________




-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Cristo @
cryzto.ch
Sent: Tuesday, June 12, 2007 5:34 PM
To: [email protected]
Subject: AW: [Flashcoders] AS2: Multilanguage-Listener

@ eka: thanks but for the moment i just want to understand why my code
doesn't work... but I sure will take a look at your OpdenSource-project :-)

@ Jesse: Thanx fort he hint, I modified now my code to my needs... it works,
only: where's the practical difference between this solution and the
solution where I just tell the Buttons to do what I want
(= onRelease(
        lang_xml.load("XMLFile");
        updateTextfields();
))?

Here my code (it works):

this.de.onRelease = function() {
        this.dispatchEvent({type:'click',target:this});
        //trace("DE-Button was pressed");
}
this.fr.onRelease = function() {
        this.dispatchEvent({type:'click',target:this});
        //trace("FR-Button was pressed");
}
this.it.onRelease = function() {
        this.dispatchEvent({type:'click',target:this});
        //trace("IT-Button was pressed");
}
this.en.onRelease = function() {
        this.dispatchEvent({type:'click',target:this});
        //trace("EN-Button was pressed");
}
var langListener:Object = new Object();

langListener.click = function (EvtObj:Object){
        var str:String = EvtObj.target.label.toLowerCase();
        _root.lang_xml.load("conf_"+str+".xml");
}
for (var prop in this) {
        mx.events.EventDispatcher.initialize(this[prop]);
        this[prop].addEventListener("click", langListener);
        //trace(this[prop]);
}

stop();

-----Ursprüngliche Nachricht-----
Von: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Im Auftrag von Jesse
Graupmann
Gesendet: Dienstag, 12. Juni 2007 22:09
An: [email protected]
Betreff: RE: [Flashcoders] AS2: Multilanguage-Listener

You have to initialize the object before you can add listeners;


var listener:Object = new Object();

listener.click = function ( evt:Object)
{
            trace("it worked!");
};

var obj:Object = new Object();

mx.events.EventDispatcher.initialize ( obj );

obj.addEventListener( "click", listener );

obj.dispatchEvent ( {type:'click', target:obj } );


_____________________________

Jesse Graupmann
www.jessegraupmann.com 
www.justgooddesign.com/blog/ 
_____________________________



-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Cristo @
cryzto.ch
Sent: Tuesday, June 12, 2007 12:45 PM
To: [email protected]
Subject: [Flashcoders] AS2: Multilanguage-Listener

Hi everybody

 

I'm working on a multilanguage configurator and want to update every
textareas, labels etc. by clicking on one of the available lang-buttons
(english, german, spanish ect.).

 

My configurator consists of different movieclips/layers of course. Now I've
tried to reach this by creating an evenlistener on those buttons, but
without success.

 

Code (layer: _level0):

 

var langListener:Object = new Object();

langListener.click = function (EvtObj:Object){

            trace("it worked!");

};

// ie: english-button

_level0.langP_mc.en_btn.addEventListener("click", langListener);

 

 

Can anyone help?

 

Cryzto


No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.472 / Virus Database: 269.8.14/845 - Release Date: 12.06.2007
06:39
 
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.472 / Virus Database: 269.8.14/845 - Release Date: 12.06.2007
06:39
 

-- 
Ich verwende die kostenlose Version von SPAMfighter für private Anwender,
die bei mir bis jetzt 828 Spammails entfernt hat.
Bezahlende Anwender haben diesen Hinweis nicht in ihren E-Mails.
Laden Sie SPAMfighter kostenlos herunter: http://www.spamfighter.com/lde

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.472 / Virus Database: 269.8.14/845 - Release Date: 12.06.2007
06:39
 

_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to