actionscript-book-IntrovertIM_HTML-IntrovertIMApp.mx [swf] [flash] flex
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" paddingTop="10" paddingBottom="10" paddingLeft="10" paddingRight="10" creationComplete="initApp()"> <mx:Script> <![CDATA[ //import com.example.programmingas3.introvertIM.IMStatus; //import com.example.programmingas3.introvertIM.IMManager; //import com.example.programmingas3.introvertIM.IMMessageEvent; private var _manager:actionscript_book_IntrovertIM_HTML_com_example_programmingas3_introvertIM_IMManager; private function initApp():void { status.dataProvider = actionscript_book_IntrovertIM_HTML_com_example_programmingas3_introvertIM_IMStatus.allStatuses; status.selectedIndex = 0; _manager = new actionscript_book_IntrovertIM_HTML_com_example_programmingas3_introvertIM_IMManager(actionscript_book_IntrovertIM_HTML_com_example_programmingas3_introvertIM_IMStatus(status.selectedItem)); _manager.addEventListener(actionscript_book_IntrovertIM_HTML_com_example_programmingas3_introvertIM_IMMessageEvent.NEW_MESSAGE, newMessageHandler); } // ------- Event Handling ------- private function newMessageHandler(event:actionscript_book_IntrovertIM_HTML_com_example_programmingas3_introvertIM_IMMessageEvent):void { transcript.text += "The Other Person: " + event.message + "\n"; } private function sendMessage():void { transcript.text += "You: " + messageText.text + "\n"; _manager.sendMessage(messageText.text); messageText.text = ""; } private function changeStatus():void { _manager.status = actionscript_book_IntrovertIM_HTML_com_example_programmingas3_introvertIM_IMStatus(status.selectedItem); } ]]> </mx:Script> <mx:Label id="title" text="Introvert IM Example" fontSize="24" fontStyle="bold"/> <mx:Label id="subtitle" text="From Programming ActionScript 3.0, Chapter 25: Using the external API" fontSize="12"/> <mx:HBox width="100%" height="100%"> <mx:VBox width="100%" height="100%"> <mx:TextArea id="transcript" width="100%" height="100%" editable="false"/> <mx:HBox width="100%"> <mx:TextInput id="messageText" width="100%"/> <mx:Button label="Send" click="sendMessage()"/> </mx:HBox> </mx:VBox> <mx:VBox> <mx:Label text="Your status:"/> <mx:ComboBox id="status" change="changeStatus()"> </mx:ComboBox> </mx:VBox> </mx:HBox> </mx:Application>
(C) Æliens 04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.