zoukankan      html  css  js  c++  java
  • How to create a reusable toggle button in AS3?

    Let me show you ,

    How to create a reusable toggle button in AS3?

    This is quite Simple. Create a new generic button class, and add all of your event listeners within. For each new button you want to create, just extend your generic button and fill in the required code within the event listeners.:

    classGenericToggleButtonextendsButton{publicGenericToggleButton(){this.addEventListener(MouseEvent.MOUSE_OVER, rolloverToggle);this.addEventListener(MouseEvent.MOUSE_OUT, rolloutToggle);this.addEventListener(MouseEvent.MOUSE_CLICK, toggleClick);}protectedfunction rolloverToggle(event:MouseEvent):void{this.gotoAndStop(this.buttonState+" over");}protectedfunction rolloutToggle(event:MouseEvent):void{this.gotoAndStop(this.buttonState);}protectedfunction toggleClick(event:MouseEvent):void{if(this.buttonState =="on"){this.buttonState ="off";this.gotoAndStop(1);}else{this.buttonState ="on";}}}

    Now just extend that class and add your functionality.

    classNewButtonextendsGenericToggleButton{publicNewButton(){super();}overrideprotectedfunction toggleClick(event:MouseEvent):void{super.toggleClick(event);// do magic for this button}// ETC}
  • 相关阅读:
    excel unixtime与北京时间互转
    vim的漫漫长征路
    const常量
    第一章:绪论
    2.4奇偶校验
    2.3数据校验的基本原理
    2.2定点与浮点数据表示
    2.1机器数及其特点
    1.2计算机系统性能评价
    冯诺依曼结构原理及层次分析
  • 原文地址:https://www.cnblogs.com/cnsoft/p/2853951.html
Copyright © 2011-2022 走看看