Passing Arguments to Event Handler AS3: Argumentele pentru a trece Handler Eveniment AS3:
In AS2 we use Delegate class to pass arguments to event handlers and scoping event handlers. În AS2 vom folosi clasa Delegat pentru a trece la argumentele care operează eveniment şi ţeluri, care operează eveniment. But there is no Delegate class in AS3. Dar nu există nici clasa Delegat în AS3.
Still sending extra argument to event handlers is not a big deal. Totusi trimiterea argument suplimentar pentru a mîner eveniment nu este o afacere mare.
We are going to use one way of sending extra parameters to event handlers in actionscript 3.0, Vom utiliza o modalitate de a trimite în plus pentru a parametrilor de supervizare eveniment in ActionScript 3.0,
code: cod:
button.addEventListener(MouseEvent.CLICK, function(e:MouseEvent){handleClickEvent(e,"Home")}); button.addEventListener (MouseEvent.CLICK, funcţie (e: MouseEvent) (handleClickEvent (e, "Acasă ")}); function handleClickEvent(e:MouseEvent,str:String) { handleClickEvent funcţie (e: MouseEvent, str.: String) ( trace("Argument :"+str,"- Event target :"+e.target.name); urme ("Argument:" + str, "- ţintă Eveniment:" e.target.name +); } )
output: ieşire:
Argument :Home – Event target :button Argument: Home - Eveniment ţintă: buton
Here note, Aici notă,
We are adding event handler for button symbol. Suntem adăugând handler eveniment pentru simbolul buton. On click we call an inline function where inturn we are passing the MouseEvent and a parameter. Faceţi clic pe numim o funcţie de linie în cazul în care inturn suntem trece MouseEvent şi un parametru.
Simple is'nt it. is'nt simpla.
Cheers Noroc ![]()











































Hi Hi
This really helped me.I can pass arguments on panel onclick in flex 3 actionscript . Acest fapt a ajutat me.I pot trece argumentele pe panoul de onclick în Flex 3 ActionScript.
Thanks Mulţumiri
Palash Palash
Hmm. Hmm. but how do you remove the eventListener again? dar cum a face tu remove eventListener din nou?
Now, this is genius!! Acum, acest lucru este geniu!
Thanks mate! Multumesc amice! I actually knew that… i just forgot how to make inline functions in AS3 (and forgot they were called “inline”)… LOL! De fapt, am ştiut că ... am uitat cum să facă funcţii inline în AS3 (şi am uitat de ele au fost numite "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). Transmiterea argumentelor eveniment la care operează în acest mod este mult mai bine pentru aplicatii mici, decât a face o clasa Eveniment personalizat sau clasa dinamice sau orice alte nejustificată similare (care googling arată mai întâi ca o modalitate de a aborda această problemă, din pacate).
Leave your response! Lăsaţi-vă de răspuns!
Blog Rating Blog Rating
Average blog rating: Blog-ul mediu evaluare:
7.3 7.3
61 votes cast for 30 posts 61 voturi exprimate pentru 30 de posturi
Recent Posts Recent Posts
Categories Categorii
Recent Comments Comentarii recente
Archives Arhive
Blogroll Blogroll
Pages Pagini
Search Me Cercetează-mă
Archives Arhive
Most Commented Cele mai comentate
Tags Tag-uri
UserOnline UserOnline