1 Reply Latest reply on Feb 1, 2007 3:38 PM by peterent

    Newbie; Sample code problem

    Level 1
      Hi,

      I'm attempting to learn Flex and I can't get the example in "Adobe Flex
      2 Help" to work.

      The greeting.as file:-
      -----------------------------------------------------------------------
      package
      {
      public class Greeter
      {
      public function sayHello(name:String):String
      {
      var greeting:String = "Hello " + name + "!";
      return greeting;
      }
      }
      }

      The HelloWorld.mxml file:
      -----------------------------------------------------------------------
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" xmlns="*"
      layout="vertical"
      creationComplete = "initApp()" >

      <mx:Script>
      <![CDATA[
      public function initApp():void
      {
      // says hello at the start, and asks for the user's name
      mainTxt.text = Greeter.sayHello();
      }
      ]]>
      </mx:Script>

      <mx:TextArea id = "mainTxt" width="400" />

      </mx:Application>

      But where does this bit go? It just doesn't tell you in the example!
      ------------------------------------------------------------------
      var myGreeter:Greeter = new Greeter();
      mainText.text = myGreeter.sayHello("Bob");

      Any help appreciated, thanks.

      Paul