Results 1 to 3 of 3

Thread: How could I inject Array object or ArrayCollection?

Hybrid View

  1. #1
    Join Date
    Feb 2009
    Posts
    2

    Default How could I inject Array object or ArrayCollection?

    Hi, I just got the latest version of spring actrionscript and trying to play around this news toy. One of the experiment is injecting array from application context into the application to generate a combo box.

    The result is, yes, it works! but I should have to declare the object in the right way. because the spring looks like inject the Array in array to the application for me.

    Did anyone try with this already?

    Config.xml
    HTML Code:
    <object id="userArray" class="Array">
        <constructor-arg>
          <array>
            <object class="com.teerasej.User">
              <property name="username" value="usernameAAA"/>
              <property name="password" value="mepass"/>
            </object>
            <object class="com.teerasej.User">
              <property name="username" value="usernameBBB"/>
              <property name="password" value="mepass"/>
            </object>
          </array>
        </constructor-arg>
      </object>
    and this is the code in MXML, _userArr variable has defined as bindable already.
    Code:
    protected function onACLoadComplete( event : Event ) : void
    {
    				
    	_userArr = ac.getObject("userArray");
    				
    }

    HTML Code:
    <mx:ComboBox x="313" y="375" dataProvider="{_userArr}" labelField="username"/>

  2. #2
    Join Date
    Oct 2008
    Location
    Belgium
    Posts
    160

    Default

    Hi,

    you can create an ArrayCollection like this:

    Code:
    <object id="users" class="mx.collections.ArrayCollection">
      <constructor-arg>
        <array>
          <object class="com.teerasej.User">
            <property name="username" value="usernameAAA"/>
            <property name="password" value="mepass"/>
          </object>
          <object class="com.teerasej.User">
            <property name="username" value="usernameBBB"/>
            <property name="password" value="mepass"/>
          </object>
        </array>
      </constructor-arg>
    </object>
    An array should be:

    Code:
    <object id="userArray" class="Array">
        <constructor-arg>
            <object class="com.teerasej.User">
              <property name="username" value="usernameAAA"/>
              <property name="password" value="mepass"/>
            </object>
        </constructor-arg>
        <constructor-arg>
            <object class="com.teerasej.User">
              <property name="username" value="usernameBBB"/>
              <property name="password" value="mepass"/>
            </object>
        </constructor-arg>
      </object>
    regards,
    Christophe
    Christophe Herreman
    Spring ActionScript Founder
    http://www.herrodius.com

  3. #3
    Join Date
    Feb 2009
    Posts
    2

    Default

    Thank you for your fast replied, Christophe.

    I have used Spring.net for a long time. So I think that make me doing wrong thing

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •