This is a translated page. The original can be found here: http://www.designscripting.com/2008/11/passing-arguments-to-event-handler-as3/
Home » ActionScript 3.0 Avaleht » ActionScript 3,0

Passing Arguments to Event Handler AS3: Lähituled Argumendid sündmus AS3:

25 November 2008 25. november 2008 4 Comments 4 Comments

In AS2 we use Delegate class to pass arguments to event handlers and scoping event handlers. In AS2 me kasutame Delegaat klassi edasi argumendid korral käitlejate ja kindlaksmääramisest korral käitleja. But there is no Delegate class in AS3. Aga ei ole Delegaat klassi AS3.

Still sending extra argument to event handlers is not a big deal. Ikka saates extra argumendi korral käitleja ei ole suur asi.

We are going to use one way of sending extra parameters to event handlers in actionscript 3.0, Me ei kavatse kasutada üks võimalus saata ekstra parameetreid juhul laskmise ActionScript 3.0

code: kood:

button.addEventListener(MouseEvent.CLICK, function(e:MouseEvent){handleClickEvent(e,"Home")}); button.addEventListener (MouseEvent.CLICK, funktsioon (e: MouseEvent) (handleClickEvent (e, "Kodu ")});
function handleClickEvent(e:MouseEvent,str:String) { funktsiooni handleClickEvent (e: MouseEvent, str: string) (
	trace("Argument :"+str,"- Event target :"+e.target.name); jälgede ("Argument:" + str "- Ürituse eesmärk:" + e.target.name);
} )

output: toodang:
Argument :Home – Event target :button Argument: Home - Ürituse eesmärk: nupp

Here note, Siin teadmiseks

We are adding event handler for button symbol. Lisame sündmus jaoks nupp sümbol. On click we call an inline function where inturn we are passing the MouseEvent and a parameter. Kliki kutsume inline funktsioon, kus inturn oleme lähi MouseEvent ja parameeter.

Simple is'nt it. Antud is'nt ta.

Cheers Terviseks :)

VN:F [1.7.7_1013] VN: F [1.7.7_1013]
Rating: 10.0/ 10 (4 votes cast) Reiting: 10.0 / 10 (4 häältest)
VN:F [1.7.7_1013] VN: F [1.7.7_1013]
Rating: +1 (from 3 votes) Reiting: +1 (alates 3 häält)
Passing Arguments to Event Handler AS3: 10.0 10 4 Lähituled Argumendid sündmus AS3: 10.0 10 4
Translate this post Tõlgi see postitus




4 Comments » 4 Comments »

  • Palash said: Palash ütles:

    Hi Tere
    This really helped me.I can pass arguments on panel onclick in flex 3 actionscript . See tõesti aitas me.I mahuksid argumente paneelmaja onclick aastal Flex 3 ActionScript.
    Thanks Aitäh
    Palash Palash

    UN:F [1.7.7_1013] ÜRO: F [1.7.7_1013]
    Rating: 5.0/ 5 (1 vote cast) Rating: 5.0 / 5 (1 vote häältest)
    UN:F [1.7.7_1013] ÜRO: F [1.7.7_1013]
    Rating: 0 (from 0 votes) Hinnang: 0 (0 häält)
  • David said: Taavet ütles:

    Hmm. Hmm. but how do you remove the eventListener again? Aga kuidas eemaldada eventListener jälle?

    UN:F [1.7.7_1013] ÜRO: F [1.7.7_1013]
    Rating: 0.0/ 5 (0 votes cast) Reiting: 0.0 / 5 (0 hääli)
    UN:F [1.7.7_1013] ÜRO: F [1.7.7_1013]
    Rating: 0 (from 0 votes) Hinnang: 0 (0 häält)
  • Ricardo said: Ricardo ütles:

    Now, this is genius!! Nüüd on see geenius!

    UN:F [1.7.7_1013] ÜRO: F [1.7.7_1013]
    Rating: 0.0/ 5 (0 votes cast) Reiting: 0.0 / 5 (0 hääli)
    UN:F [1.7.7_1013] ÜRO: F [1.7.7_1013]
    Rating: +1 (from 1 vote) Reiting: +1 (alates 1. hääletus)
  • DreadSquirrel said: DreadSquirrel ütles:

    Thanks mate! Tänu vennas! I actually knew that… i just forgot how to make inline functions in AS3 (and forgot they were called “inline”)… LOL! Ma tegelikult teadsin, et ... ma lihtsalt unustanud, kuidas inline funktsioone AS3 (ja unustan need nn "inline") ... LOL!

    Passing arguments to event handlers this way is so much better for small apps, than making a custom Event class or dynamic class or any other similar overkill (which googling shows first as a way of dealing with the problem, sadly). Lähituled argumendid korral käitlejate Sel viisil on nii palju parem väikeste apps, kui tegemist custom Sündmus klassi või dünaamilise klassi või muu sarnase overkill (mis googling näitab kõigepealt viis probleemiga tegelemiseks, kahjuks).

    UN:F [1.7.7_1013] ÜRO: F [1.7.7_1013]
    Rating: 0.0/ 5 (0 votes cast) Reiting: 0.0 / 5 (0 hääli)
    UN:F [1.7.7_1013] ÜRO: F [1.7.7_1013]
    Rating: 0 (from 0 votes) Hinnang: 0 (0 häält)

Leave your response! Jäta vastus!

Add your comment below, or trackback from your own site. Lisa oma kommentaar allpool või Trackback alates oma veebilehel. You can also subscribe to these comments via RSS. Te saate ka tellida neid märkusi via RSS.

Be nice. Ole kena. Keep it clean. Hoidke see puhas. Stay on topic. Püsi teema. No spam. Nr rämpsposti.

You can use these tags: Võid kasutada neid tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. See on Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar . Et saada oma ülemaailmselt tunnustatud-avatari, palun registreerida Gravatar .

CAPTCHA Image
Värskenda Pilt