actionscript 3 - Action Script: Call corresponding functions on button click -



actionscript 3 - Action Script: Call corresponding functions on button click -

i have been trying add together buttons dynamically , assign event listeners them. code is,

var i=0; var step=50; each (var child:xml in coursexml.footer.tray.elements()) { var thumbclip:thumb = new thumb(); //set name thumbclip.name = "mc_thumb" + (i + 1); trace("thumbclipname:: "+thumbclip.name); //set x , y values thumbclip.x = 620 + (i * step); thumbclip.y = 560; //attach newly created instance container addchild(thumbclip); trace("thumbclip:: "+thumbclip); //attach icon image xml path thumbclip.thumbloader.source = child.icon; trace("thumbclip.thumbloader.source: "+thumbclip.thumbloader.source); //add listeners trace("node name "+ child.localname()); if(child.localname().tolowercase() == "feedback"); { trace("gotofeedback.."); thumbclip.addeventlistener(mouseevent.click, gotofeedback); } if(child.localname().tolowercase() == "resources"); { trace("gotoresources.."); thumbclip.addeventlistener(mouseevent.click, gotoresources); } if(child.localname().tolowercase() == "glossary"); { trace("gotoglossary.."); thumbclip.addeventlistener(mouseevent.click, gotoglossary); } if(child.localname().tolowercase() == "discussion"); { trace("gotodiscussion.."); thumbclip.addeventlistener(mouseevent.click, gotodiscussion); } thumbclip.buttonmode = true; i++; }

so, 4 buttons displayed on stage , when click on button 4 functions gotofeedback, gotoresources, gotoglossary, gotodiscussion called. how phone call corresponding functions on button click? thanks!

the 4 functions are: function gotofeedback(e: mouseevent):void { trace("gotofeedback fn called.."); } function gotoresources(e: mouseevent):void { trace("gotoresources fn called.."); } function gotoglossary(e: mouseevent):void { trace("gotoglossary fn called.."); } function gotodiscussion(e: mouseevent):void { trace("gotodiscussion fn called.."); }

you need add together event listeners kid buttons, rather thumbclip. way have code now, whenever mouse clicked anywhere within thumbclip the listeners called (which seeing).

actionscript-3 actionscript

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -