Title / Description
Code package ui { import flash.display.DisplayObjectContainer;//你好 import flash.events.Event; import ui.events.ButtonEvent; import ui.events.GenericPopupEvent; public class GenericPopup extends PopupDialog // PopupDialog is a class defined in a SWC file { // When the user calls "show" or "hide", this is the container this popup is added/removed to/from private var popupContainer:DisplayObjectContainer; public function GenericPopup( popupContainer:DisplayObjectContainer ) { super(); this.popupContainer = popupContainer; Button.makeIntoButton(leftButton); Button.makeIntoButton(rightButton); // "leftButton" and "rightButton" are the instance names of children found in the artwork leftButton.addEventListener(ButtonEvent.SELECTED, onLeftButtonSelected); rightButton.addEventListener(ButtonEvent.SELECTED, onRightButtonSelected); } protected function onRightButtonSelected(event:Event):void { dispatchEvent( new GenericPopupEvent( GenericPopupEvent.OPTION_SELECTED, rightButton.label.text ) ); } protected function onLeftButtonSelected(event:Event):void { dispatchEvent( new GenericPopupEvent( GenericPopupEvent.OPTION_SELECTED, leftButton.label.text ) ); } public function show( displayText:String, option1:String, option2:String ):void{ popupContainer.addChild( this ); // "message" is the instance name of a text-field found in the artwork message.text = displayText; // "leftButton" and "rightButton" are instances of the "ButtonArtwork" class // the "ButtonArtwork" class has a text-field with instance name: "label" leftButton.label.text = option1; rightButton.label.text = option2; } public function hide():void{ popupContainer.removeChild(this); } } }
Author
Highlight as C C++ CSS Clojure Delphi ERb Groovy (beta) HAML HTML JSON Java JavaScript PHP Plain text Python Ruby SQL XML YAML diff code