topical media & game development

talk show tell print

flex-component-dispatcher.mx

flex-component-dispatcher.mx [swf] flex


  <?xml version="1.0" encoding="utf-8"?>
  <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundGradientColors="[#ffffff, #ffffff]" width="400" height="200">
  
          <mx:Script>
                  <![CDATA[
                          import mx.controls.Alert;
                          import flx.external.FlashInterface;
          
                          private var count:Number = 0;
                          
                          [Embed(source="local/flex/assets/images/flex_icon.png")]
                          [Bindable]
                          public var logo:Class;
                          
                          private var messages:XML = 
                                  <messages>
                                          <item>Hey! you were supposed to type something!</item>
                                          <item>I guess you have nothing to say...too bad.</item>
                                          <item>FlashInterface rocks!</item>
                                          <item>You like pushing my buttons, don't you?</item>
                                          <item>Ummmm...okay, this is a little awkward, what was I supposed to send?</item>
                                          <item>Don't be shy, just type anything. You will feel better. I promise!</item>
                                          <item>Well if you aren't going to talk to me, I'm outta here! Later.</item>
                                  </messages>
                          
                          private function dispatch():void
                          {
                                  var str:String = !txtInput.text ? messages.item[count++ % messages.item.length()] : txtInput.text;
                                  FlashInterface.dispatchEvent({type:'talkToFlash', data:str});
                                  txtInput.text = "";
                          }
                  ]]>
          </mx:Script>
          <mx:Canvas cornerRadius="8" borderStyle="solid" left="5" top="5" right="5" bottom="5">
                  <mx:Label x="14" y="6" text="Flash 9 - Dispatcher" fontWeight="bold" fontStyle="italic" fontSize="16" fontFamily="Arial" color="#cc0000"/>
                  <mx:Label x="14" y="33" text="FlashInterface.dispatch" fontWeight="bold" fontSize="12"/>
                  <mx:Text x="14" y="61" fontSize="11" text="Type message to send to subscriber."/>
                  <mx:Button label="Send" click="dispatch()" right="10" bottom="10"/>
                  <mx:Image x="330" y="10" width="48" height="48" source="{logo}" scaleContent="false"/>
                  <mx:TextArea x="10" y="82" width="368" height="66" id="txtInput"/>
          </mx:Canvas>
  </mx:Application>
  


(C) Æliens 27/08/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.