2 Replies Latest reply on Mar 16, 2007 5:58 PM by ntsiii

    Object/event issue

    cheftimo Level 2
      I initially posted this on Flex 2 General Discussion, but have had no bites. As the main issue here is the AS code, I’m posting here hoping ….. How about it, ntsiii?

      I am using Kyle Quevillon’s sample application as a aid to learn more about objects and events. Some of you may already be familiar with the sample app. Basically, here is my question:

      The following is the code from the original sample (of course, it works fine):

      public function handleStructResult(event:ResultEvent):void{
      oResult=event.result as Object;

      showBusyCursor="true" >
      <mx:method name="sayHelloStruct" result="handleStructResult(event)" fault="Alert.show(event.fault.message)"/>

      <!-- Form in original sample project -->
      <mx:Button label="get Struct Remote Object" click="myService.sayHelloStruct()"/>

      <mx:Form >
      <mx:FormHeading label="How do you say {oResult.ENGLISH} in Latin?"/>
      <mx:RadioButtonGroup id="language" />
      <mx:RadioButton groupName="language" id="lFrench" value="french"
      label="{oResult.FRENCH}" width="150" />
      <mx:RadioButton groupName="language" id="lSpanish" value="spanish"
      label="{oResult.SPANISH}" width="150" />
      <mx:RadioButton groupName="language" id="lLatin" value="latin"
      label="{oResult.LATIN}" width="150" />

      For various reasons, I need this to work like this (adding to the above code):

      public function getKeyText(key:String):String {
      return oResult.key;

      public function getLanguages():void{
      var e:Event = new Event("getLangs");

      <!-- New form. NOTE CHANGE IN THE BUTTON CLICK -->
      <mx:Button label="get Struct Remote Object" click="getLanguages()"/>

      <mx:Form >
      <mx:FormHeading label="How do you say {getKeyText('ENGLISH')} in Latin?"/>
      <mx:RadioButtonGroup id="language1" />
      <mx:RadioButton groupName="language" id="lFrench2" value="french"
      label="{getKeyText('FRENCH')}" width="150" />
      <mx:RadioButton groupName="language" id="lSpanish2" value="spanish"
      label="{getKeyText('SPANISH')}" width="150" />
      <mx:RadioButton groupName="language" id="lLatin2" value="latin"
      label="{getKeyText('LATIN')}" width="150" />

      This will not work – ‘{getKeyText('ENGLISH')}’ show up as ‘null’ and the labels don’t even appear.

      What am I missing here?

      For anyone who wishes to help figure this out and wants more detail, the project can be seen here:
      http://www.timos.com/HelloWorld_ro/flex/HelloWorld_ro_struct.html and View Source is enabled.

      I hope to hear from somebody. Best regards,