3 Replies Latest reply on Jun 24, 2011 1:51 PM by Flex harUI

    Class instantiation through mxml - setting properties




      I'm trying to create a reusable component with an actionscript class.


      I'd like to be able to set a handful of the class' properties withmxml attributes. So far, I've had no success doing so.


      I've subset my problem into a separate, simplied project in an attempt to rule out any of the other parts of the real application interfering with what I'm attempting to accomplish. Unfortunately, my simplified project produces the same result.


      In my example, I'm just trying to set value of the property "myValue."  Can anyone tell me what I'm doing wrong? What am I missing?


      Thanks in advance for any help!


      Main application (TestProj.mxml)

      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                        minWidth="955" minHeight="600" 
                <!-- Place non-visual elements (e.g., services, value objects) here -->
           <pkg:TestClass myvalue="some value" />



      Actionscript class (pkg\TestClass.as)

      package pkg
           import mx.controls.Alert;
           import mx.core.UIComponent;
           public class TestClass extends UIComponent
                private var _myvalue:String;
                public function TestClass()
                     Alert.show("myvalue=" + this._myvalue);     
                public function get myvalue():String
                     return _myvalue;
                public function set myvalue(value:String):void
                     _myvalue = value;