Revision: 24446
Updated Code
at March 1, 2010 20:19 by alvincrespo
Updated Code
/* Author: Alvin Crespo Date: 3/1/2010 TemplateButton is a template class for buttons. */ package acrespo.classes.templates{ //display import flash.display.MovieClip; //events import flash.events.Event; import flash.events.MouseEvent; public class TemplateButton extends MovieClip{ private var cButtonArea:MovieClip; public function Button(){ } //Constructor protected function setClickArea(pButtonArea:MovieClip):void{ initiateClickArea(pButtonArea); } private function initiateClickArea(pButtonArea:MovieClip):void{ cButtonArea = pButtonArea; cButtonArea.buttonMode = true; cButtonArea.addEventListener(MouseEvent.MOUSE_DOWN, buttonDown); cButtonArea.addEventListener(MouseEvent.MOUSE_UP, buttonUp); cButtonArea.addEventListener(MouseEvent.MOUSE_OVER, buttonOver); cButtonArea.addEventListener(MouseEvent.MOUSE_OUT, buttonOut); } private function buttonDown(e:MouseEvent):void { stage.addEventListener(MouseEvent.MOUSE_UP, buttonUp); gotoAndStop('down'); } private function buttonUp(e:MouseEvent):void { stage.removeEventListener(MouseEvent.MOUSE_UP, buttonUp); if (e.currentTarget != cButtonArea) {//onreleaseoutside gotoAndStop('normal'); } else {//onrelease buttonUpAction(); } } protected function buttonUpAction():void{ } private function buttonOver(e:MouseEvent):void { if (e.buttonDown) {//ondragover } else {//onrollover } gotoAndStop('over'); } private function buttonOut(e:MouseEvent):void { //The user is dragging something from the target object if (e.buttonDown) {//ondragout gotoAndStop('down'); } else {//onrollout gotoAndStop('normal'); } } }//end of class }//end of package /* The Following is how you would extend that class */ package acrespo.classes.buttons{ //classes import acrespo.classes.templates.TemplateButton; import acrespo.classes.MainDocument; public class UploadFileButton extends TemplateButton{ public function UploadFileButton():void{ setClickArea(buttonarea); //function of parent class TemplateButton } override protected function buttonUpAction():void{ MainDocument(parent)._FileManager.uploadFiles(); }//end of buttonUpAction }//end of class }//end of package
Revision: 24445
Updated Code
at March 1, 2010 20:18 by alvincrespo
Updated Code
/* Author: Alvin Crespo Date: 3/1/2010 TemplateButton is a template class for buttons. */ package acrespo.classes.templates{ //display import flash.display.MovieClip; //events import flash.events.Event; import flash.events.MouseEvent; public class TemplateButton extends MovieClip{ private var cButtonArea:MovieClip; public function Button(){ } //Constructor protected function setClickArea(pButtonArea:MovieClip):void{ initiateClickArea(pButtonArea); } private function initiateClickArea(pButtonArea:MovieClip):void{ cButtonArea = pButtonArea; cButtonArea.buttonMode = true; cButtonArea.addEventListener(MouseEvent.MOUSE_DOWN, buttonDown); cButtonArea.addEventListener(MouseEvent.MOUSE_UP, buttonUp); cButtonArea.addEventListener(MouseEvent.MOUSE_OVER, buttonOver); cButtonArea.addEventListener(MouseEvent.MOUSE_OUT, buttonOut); } private function buttonDown(e:MouseEvent):void { stage.addEventListener(MouseEvent.MOUSE_UP, buttonUp); gotoAndStop('down'); } private function buttonUp(e:MouseEvent):void { stage.removeEventListener(MouseEvent.MOUSE_UP, buttonUp); if (e.currentTarget != cButtonArea) {//onreleaseoutside gotoAndStop('normal'); } else {//onrelease buttonUpAction(); } } protected function buttonUpAction():void{ } private function buttonOver(e:MouseEvent):void { if (e.buttonDown) {//ondragover } else {//onrollover } gotoAndStop('over'); } private function buttonOut(e:MouseEvent):void { //The user is dragging something from the target object if (e.buttonDown) {//ondragout gotoAndStop('down'); } else {//onrollout gotoAndStop('normal'); } } }//end of class }//end of package
Revision: 24444
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at March 1, 2010 20:17 by alvincrespo
Initial Code
/* Author: Alvin Crespo Date: 3/1/2010 TemplateButton is a template class for buttons used in the Music Management program. */ package acrespo.classes.templates{ //display import flash.display.MovieClip; //events import flash.events.Event; import flash.events.MouseEvent; public class TemplateButton extends MovieClip{ private var cButtonArea:MovieClip; public function Button(){ } //Constructor protected function setClickArea(pButtonArea:MovieClip):void{ initiateClickArea(pButtonArea); } private function initiateClickArea(pButtonArea:MovieClip):void{ cButtonArea = pButtonArea; cButtonArea.buttonMode = true; cButtonArea.addEventListener(MouseEvent.MOUSE_DOWN, buttonDown); cButtonArea.addEventListener(MouseEvent.MOUSE_UP, buttonUp); cButtonArea.addEventListener(MouseEvent.MOUSE_OVER, buttonOver); cButtonArea.addEventListener(MouseEvent.MOUSE_OUT, buttonOut); } private function buttonDown(e:MouseEvent):void { stage.addEventListener(MouseEvent.MOUSE_UP, buttonUp); gotoAndStop('down'); } private function buttonUp(e:MouseEvent):void { stage.removeEventListener(MouseEvent.MOUSE_UP, buttonUp); if (e.currentTarget != cButtonArea) {//onreleaseoutside gotoAndStop('normal'); } else {//onrelease buttonUpAction(); } } protected function buttonUpAction():void{ } private function buttonOver(e:MouseEvent):void { if (e.buttonDown) {//ondragover } else {//onrollover } gotoAndStop('over'); } private function buttonOut(e:MouseEvent):void { //The user is dragging something from the target object if (e.buttonDown) {//ondragout gotoAndStop('down'); } else {//onrollout gotoAndStop('normal'); } } }//end of class }//end of package
Initial URL
Initial Description
Here is a template button class, ive been using for my projects. Cheers!
Initial Title
Button Template Class in AS3
Initial Tags
class, template, button
Initial Language
ActionScript 3