actionscript 3 - Flash as3 - Create a variable from instance on click event -


i have whole bunch of buttons need have both mouse on effect toggle effect (on click) changes hue. have made functions each hue change , parts works quite well. sadly cant figure out how toggle function work how supposed to.

below code toggle button. works fine, except variable global instead of specific instance. therefor works if have 1 button. how can change use variable 1 button in focus?

thanks in advance!

var primary = false;  function clickon(e:mouseevent):void{      if (primary == false)     {             greenhue(e.target);             primary = true;     } else {             nohue(e.target);             primary = false;     } } 

the best thing extend class used buttons , add functions it, buttons derive have idependant behavior want.

class coloredbutton extends button {     var primary = false;        public function coloredbutton() {         this.addeventlistener(mouseevent.click, clickon);     }      private function clickon(e:mouseevent):void {            if (primary == false)     {               greenhue(e.target);               primary = true;           } else {               nohue(e.target);               primary = false;           }       }      ...   } 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -