actionscript 3 - AS3 how to manipulate different instances of a class from the timeline -
i trying create menu using as3 , cant seem find way finish it. this got far
so wrote class attached movieclip , put several instances of on stage.
package { import flash.events.event; import flash.events.mouseevent; import fl.transitions.tween; import fl.transitions.tweenevent; import fl.transitions.easing.*; import flash.display.*; public class servicesbuttons extends movieclip { public function servicesbuttons() { shapemc.width = 0; this.addeventlistener(mouseevent.roll_over, mouseon); this.addeventlistener(mouseevent.roll_out, mouseoff); this.addeventlistener(mouseevent.click, clicked); function mouseon(e:event) { var shapegrow:tween = new tween(shapemc, "width", strong.easeout, 0, 200, .3, true); } function mouseoff(e:event) { var shapeshrink:tween = new tween(shapemc, "width", strong.easeout, shapemc.width, 0, .3, true); } function clicked(e:event){ removeeventlistener(mouseevent.roll_out, mouseoff); removeeventlistener(mouseevent.roll_over, mouseon); } } }
}
i wanted animation not roll once click on button , wanted animation go once click on different button.
my question is, how proceed here, searched online clues , understood set variables within class , change them on timeline , use event listeners catch changes. tried doing end redundant way gets me nowhere...
i have keep button has been clicked before :
public class servicesbuttons extends movieclip { private static var activebutton : servicesbuttons; public function servicesbuttons() { setlistener(); this.addeventlistener(mouseevent.click, clicked); } private function mouseon(e:event) { var shapegrow:tween = new tween(shapemc, "width", strong.easeout, 0, 200, .3, true); } private function mouseoff(e:event) { var shapeshrink:tween = new tween(shapemc, "width", strong.easeout, shapemc.width, 0, .3, true); } private function clicked(e:event){ if(activebutton != this) { if(activebutton) activebutton.setlistener(); setlistener(); activebutton = this; } } public function setlistener() : void{ if(haseventlistener(mouseevent.roll_out)) { removeeventlistener(mouseevent.roll_out, mouseoff); removeeventlistener(mouseevent.roll_over, mouseon); }else{ addeventlistener(mouseevent.roll_over, mouseon); addeventlistener(mouseevent.roll_out, mouseoff); mouseoff(null); } } }
Comments
Post a Comment