ArrayCollection

I have an arraycollection, Called myPrices. I just want to
display the Product number from the arraycollection. I dont know
the syntax.
This gets me [Object.object]
<mx:Text text="{myPrices}"/>
If I make a datagrid and make one column be PWDL01 I get the
record I want.
How can I show the PWDL01 in the text?
There is only one record in the array but a bunch of fields
Thanks
George

hi George,
you are getting object object, because it is returning an
object.
to get a specific item from the object within the datagrid
mydata.selectedItem.mydatacolumn - id of my datagrid is
mydata and the column information I want to display is
mydataColumn.
Now you can say this too.
mydata.getItemAt(0).mydatacolumn - this will return the item
in the 0 position of the data grid. remember that arrays are 0 or
zero based, meaning they start at 0 instead of one.
now if I wanted to get this from my array Collection I would
call:
myarrayCollection.getItemAt(0).mydatacolumn

Similar Messages

  • Whats the difference between arrayCollection = null and arrayCollection.removeAll()?

    Whats the difference between arrayCollection = null and
    arrayCollection.removeAll()?

    In arrayCollection = null; statement you're setting this
    reference to null and potentially making it available for garbage
    collection. I say 'this reference' and potentially because, as you
    may know, there might be other references to this array collection
    object that won't be affected by this statement and hence it won't
    be GC'ed.
    arrayCollection.removeAll() says that I want to empty this
    array collection for all the reference that we pointing to it. That
    is, remove all the objects from the collection -- and of course
    make them 'potentially' available for the GC -- the size of the
    array collection would be reduced down to zero and all the
    references would be pointing to a valid but empty collection.
    Hope this helps.
    ATTA

  • Getting values from a datagrid to an ArrayCollection

    Hi, I have a drag and dropable datagrid. I fill it with rows of data from another datagrid. Finally, my application demands savings the data from the datagrid into an array collection along with the index of each row. How do i get values from a datagrid into an arrayCollection variable? Please help me..!

    Whatever is dropped into the DataGrid automatically goes into its dataProvider property, typically an ArrayCollection. Just access the data grid's dataProvider property to see the values.

  • Problem updating a SOAP Web Service with ArrayCollection

    Hello,
    I am having issues POST'ing an ArrayCollection to a C# Web
    Method. Here's how I have my application set up:
    I have a DataGrid in my application and set the dataProvider
    to be the result object of a Web Service operation. I set the
    DataGrid's editable property to "true" and would like to be able to
    edit the data and send off the DataGrid's dataProvider as the
    parameter for the Web Method. If I edit the first row of the
    DataGrid and trigger the operation, it gets saved just fine. If I
    try to edit any other row this way, it keeps sending the same
    packet (as verified by a packet sniffer) not allowing me to update
    any other row. It seems the Web Service is sending the first 255
    characters of the serialized ArrayCollection.
    My questions are: why is this happening?
    and
    How can I fix this?
    Here is the request of my Web Service operation:
    <mx:request xmlns="">
    <GlossaryTerms>
    {GlossaryArrayCollection}
    </GlossaryTerms>
    </mx:request>
    This is the definition of GlossaryArrayCollection:
    [Bindable]
    public var GlossaryArrayCollection:ArrayCollection = new
    ArrayCollection();
    Here is the SOAP packet that the C# Web Method is expecting:
    <?xml version="1.0" encoding="utf-8"?>
    <soap12:Envelope xmlns:xsi="
    http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="
    http://www.w3.org/2001/XMLSchema"
    xmlns:soap12="
    http://www.w3.org/2003/05/soap-envelope">
    <soap12:Body>
    <GlossaryUpdate xmlns="">
    <GlossaryTerms>
    <Glossary cID="int" cDeleted="boolean" cTerm="string"
    cDefinition="string" cURL="string" cPublic="boolean"
    cRowVersion="string"/>
    <Glossary cID="int" cDeleted="boolean" cTerm="string"
    cDefinition="string" cURL="string" cPublic="boolean"
    cRowVersion="string" />
    </GlossaryTerms>
    </GlossaryUpdate>
    </soap12:Body>
    </soap12:Envelope>
    Thanks to anyone for their help.
    Brian Cary

    Where exactly you are seeing this error? possible for you share the screenshot?
    Execution failed: These policy alternatives can not be satisfied:
    {http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}SupportingTokens

  • How do you add multiple filters with checkboxes to an arrayCollection?

    hey guys... so i have three checkboxes and when i click one of them i need to filter out my array collection according to which ones are clicked
    I have the filter function working partially, but when i select multiple checkboxes i dont see anything in the arraycollection.
    the code i have is
    <s:VGroup x="-100" y="400">
         <mx:HRule />
         <s:CheckBox label="Approved Stories" color="#333333" selected="@{_approved}" change="filterChanged()" />
         <s:CheckBox label="Rejected Stories" color="#0184C7" selected="@{_rejected}" change="filterChanged()" />
         <s:CheckBox label="Pending Stories" color="#50C8E8" selected="@{_pending}" change="filterChanged()" />
    </s:VGroup>
    <s:DataGroup width="100%" height="100%" clipAndEnableScrolling="true" dataProvider="{filteredStoryDataArr}" click="itemClicked();">
    </s:DataGroup>
    private function returnesAllStories(event:ResultEvent):void{
         for each(var item:Object in event.result){
              storyDataArr.addItem(item);
         filteredStoryDataArr = new ArrayCollection(storyDataArr.source);
         filteredStoryDataArr.filterFunction = storyFilter;
    public function storyFilter(item:Object):Boolean
         return    (!_approved || ((item.ApprovedBy > 0) && (item.DateApproved != ""))) &&
                (!_pending || ((item.ApprovedBy == -1) && (item.DateApproved == ""))) &&
                (!_rejected || ((item.ApprovedBy == 0) || (isNaN(item.ApprovedBy))));
    public function filterChanged():void{
         filteredStoryDataArr.refresh();
    right now if i click approved i see all the approved stories, or if i check pending, i see all the pending stories.... but if i check pending and rejected, i dont see anythign in the list... any ideas how to fix that???

    there is no built-in way to do this. the only way i know is by using Mail Scripts
    http://homepage.mac.com/aamann/Mail_Scripts.html
    it has a script "Add addresses" that does just what you want.

  • How do you add multiple filters to an arrayCollection?

    hey guys... so i have three checkboxes and when i click one of them i need to filter out my array collection according to which ones are clicked
    I have the filter function working partially, but when i select multiple checkboxes i dont see anything in the arraycollection.
    the code i have is
    <s:VGroup x="-100" y="400">
         <mx:HRule />
         <s:CheckBox label="Approved Stories" color="#333333" selected="@{_approved}" change="filterChanged()" />
         <s:CheckBox label="Rejected Stories" color="#0184C7" selected="@{_rejected}" change="filterChanged()" />
         <s:CheckBox label="Pending Stories" color="#50C8E8" selected="@{_pending}" change="filterChanged()" />
    </s:VGroup>
    <s:DataGroup width="100%" height="100%" clipAndEnableScrolling="true" dataProvider="{filteredStoryDataArr}" click="itemClicked();">
    </s:DataGroup>
    private function returnesAllStories(event:ResultEvent):void{
         for each(var item:Object in event.result){
              storyDataArr.addItem(item);
         filteredStoryDataArr = new ArrayCollection(storyDataArr.source);
         filteredStoryDataArr.filterFunction = storyFilter;
    public function storyFilter(item:Object):Boolean
         return    (!_approved || ((item.ApprovedBy > 0) && (item.DateApproved != ""))) &&
                (!_pending || ((item.ApprovedBy == -1) && (item.DateApproved == ""))) &&
                (!_rejected || ((item.ApprovedBy == 0) || (isNaN(item.ApprovedBy))));
    public function filterChanged():void{
         filteredStoryDataArr.refresh();
    right now if i click approved i see all the approved stories, or if i check pending, i see all the pending stories.... but if i check pending and rejected, i dont see anythign in the list... any ideas how to fix that???

    Jer&Renee,
    welcome to Apple Discussions.
    It depends where you want them in your presentation.
    Open the Media inspector and choose a playlist. In the list of entries, mark those you want to add to Keynote (use command-click to mark multiple titles not in one block).
    Then drag the marked titles either on a slide or on the small Audio field (looks like a frame) in Document inspector. When you then hover the cursor at the Audio "frame", you'll see the quick info "Multiple Files". You cannot change the order or remove one of the files, but only all of them.

  • How can we enter the data dynamically from datagrid to an arraycollection?

    Hi All
                        How can we make datagrid fields editable when it is in empty position i mean the datagrid doesn't have any data to display.. and it must accept the data and update the arraycollection dynamically..
                 Now in my Application the datagrid is empty and it is not accepting any values and it still remain ideal..  i am unable to edit the datagrid fields in the datagrid .....
      Please some one tell me how can i achieve this...

    Here is a very basic example.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="onCreationComplete()">
    <mx:Script>
      <![CDATA[
       import mx.collections.ArrayCollection;
       [Bindable] private var _dataProvider:ArrayCollection;
       private function onCreationComplete():void {
        _dataProvider = new ArrayCollection();
        for(var i:int = 1; i <= 100; ++i)
         _dataProvider.addItem({ROW:i,A:"",B:"",C:"",D:"",E:"",F:"",G:"",H:"",I:"",J:"",K:"",L:"", M:"",N:"",O:"",P:""});
      ]]>
    </mx:Script>
    <mx:Panel title="Editable DataGrid Example" height="472" width="584" horizontalCenter="0" verticalCenter="0">
      <mx:DataGrid id="dg" width="100%" height="100%" rowCount="5" dataProvider="{_dataProvider}" editable="true" horizontalScrollPolicy="on" sortableColumns="false" draggableColumns="false">
       <mx:columns>
        <mx:DataGridColumn dataField="ROW" headerText="" width="30" sortable="false" draggable="false" editable="false" paddingLeft="0" paddingRight="0" textAlign="right"/>
        <mx:DataGridColumn dataField="A" headerText="A" width="100"/>
        <mx:DataGridColumn dataField="B" headerText="B" width="100"/>
        <mx:DataGridColumn dataField="C" headerText="C" width="100"/>
        <mx:DataGridColumn dataField="D" headerText="D" width="100"/>
        <mx:DataGridColumn dataField="E" headerText="E" width="100"/>
        <mx:DataGridColumn dataField="F" headerText="F" width="100"/>
        <mx:DataGridColumn dataField="G" headerText="G" width="100"/>
        <mx:DataGridColumn dataField="H" headerText="H" width="100"/>
        <mx:DataGridColumn dataField="I" headerText="I" width="100"/>
        <mx:DataGridColumn dataField="J" headerText="J" width="100"/>
        <mx:DataGridColumn dataField="K" headerText="K" width="100"/>
        <mx:DataGridColumn dataField="L" headerText="L" width="100"/>
        <mx:DataGridColumn dataField="M" headerText="M" width="100"/>
        <mx:DataGridColumn dataField="N" headerText="N" width="100"/>
        <mx:DataGridColumn dataField="O" headerText="O" width="100"/>
        <mx:DataGridColumn dataField="P" headerText="P" width="100"/>
       </mx:columns>
      </mx:DataGrid>
    </mx:Panel>
    </mx:Application>
    Hope this helps

  • How can i convert a arraycollection to an XmlList to put as a dataprovider for ADG

    I have a arraycollection which i'm getting from backend.I need to convert it into XMLList with nodes, because i have to show the data like branches in ADG.
    now I'm using  grouping but getting lot of sorting issues. so i want to convert it into XmlList to show the data as it is.
    is there any way to handle this issue??
    Sample example can be appreciated.

    Hello,
    I am looking for some further information about this.
    I have an array collection of about 8 fields worth wide and say 200 rows deep and is dynamic.
    I need to take this cf query result and populate a tree control with the data.
    As I understand the above post, it will loop over only the first column in the query result set.
    How can I go about creating the children or level 2, level 3 etc
    Data structure would be something like this:
    caldate, Division, Batalion, Shift, Station, actCat, actionbyname, asstocode,
    The first is a datetime, while all others are char.
    Grouping should occur left to right in this order.
    Thanks
    Jim

  • How to tell if ObjectProxy contains ArrayCollection or single object?

    When I get data back from a web service, the list contains an
    ArrayCollection. Within each ArrayCollection, the item may be
    either a single object, or an ArrayCollection of theser objects. It
    appears FLEX supplies what it thinks is the correct type of
    ObjectProxy object based on the number of children under the parent
    node.
    If the ObjectProxy refers to an ArrayCollection, I want to
    iterate over it, but if it refres to a single object, I want to
    pull off some of it's properties.
    How can I tell at run time if an ObjectProxy refers to an
    ArrayCollection, or a single object? Thanks very much in
    advance!

    Found an answer here:
    http://www.theruntime.com/blogs/be-sharp/archive/2008/02/26/web-services-and-arraycollecti ons-in-adobe-flex-2-how-to-successfully-read-any-number-of-xml-nodes.aspx
    which provides an answer if there are NO child nodes, if
    there is exactly one child node, or if there are multiple child
    nodes...

  • Search for an instance of an arraycollection to show in TextInput

    So I have a simple class to store instances from an httpservice. This is configuraton information in a key:value pair. This is read in and placed in an arrayCollection. The array collection can be from of a length of 0-100 records depdning on whats going in, and the keys are autogenerated from the device I'm talking to. (So I may not know the exact key names).
    package
    public class Cfgdb
           public var key:String = '';
           public var value:String = '';
           public function Cfgdb(akey:String, avalue:String)
                 this.key = akey;
                 this.value = avalue;
    IN the Flex application I have a FormItem i want to populate with the class instance .value If I've read in a certain key previously. (So if an instance of a key called 'system_domain_name' exists in the arrayCollection, I want the value). How do I do this? The below clearly doesn't work,
    <mx:FormItem label="System Domain Name:">
    <mx:TextInput id="system_domain_name"
    text="{ configResults.getItemAt(configResults.getItemIndex( {key: 'system_domain_name'} )).value }"
    change="xmlEditValue('uc', '', 'system_domain_name', system_domain_name.text);"
      />
    </mx:FormItem>

    Check out this tutorial:
    http://www.oracle.com/technology/obe/JavaEE_tutorial_10131/index.htm

  • Error while Adding Elements in a ArrayCollection .

    Hi ,
    I have created a ArrayCollection and trying to add elements to it using ArrayCollection.addItem("NewElement");
    In the response it is giving me a compile error showing
    "Variable 'NewElement' is not defined "
    var myArrayCollection:ArrayCollection = new ArrayCollection();
    myArrayCollection.addItem("NewElement");
    Can anybody please let me know how to resolve this ??
    Thanks in advance .

    It should not give any error...
    The error "Variable 'NewElement' is not defined " will only come if you used the 'NewElement'  without any quotes...
    If you use
    var myArrayCollection:ArrayCollection = new ArrayCollection();
    myArrayCollection.addItem(NewElement);
    then only it will show the error "Variable 'NewElement' is not defined " but if you give as below it doesn;t show any error..
    var myArrayCollection:ArrayCollection = new ArrayCollection();
    myArrayCollection.addItem("NewElement");
    Check whether you have used quotes around the word NewElement or not.
    Thanks,
    Bhasker Chari

  • Is this a bug: ModelLocator.ArrayCollection.length

    ModelLocator.ArrayCollection.length that equals to 4 starting
    from index 0 (zero)
    I see:
    going into the objects using for each item i see correctly:
    item:[object Object]
    item:[object Object]
    item:[object Object]
    item:[object Object]
    going into the objects using for loop with
    ModelLocator.ArrayCollection.length, it is not counting the full
    length:
    0 --this is page:springgraph16.UIComponent0.template1 with
    index:0 and pageid:1
    1 --this is page:springgraph16.UIComponent0.template2 with
    index:1 and pageid:2
    2 --this is page:springgraph16.UIComponent0.template3 with
    index:2 and pageid:3
    If I index into ModelLocator.ArrayCollection[3] in the for
    loop I get errors.
    example:
    checked the length with:
    trace("---lenbefore:" + __modelLocator.siteRef.length); //
    displays a trace, ---lenbefore:3
    __modelLocator.siteRef.addItem(templatesAllData);
    trace("---lenafter:" + __modelLocator.siteRef.length) //
    displays a trace, ---lenafter:4
    THIS WORKS AND DISPLAYS 4 ITEMS:
    for each (var item:* in __modelLocator.siteRef){
    trace("item:" + item);
    trace result is:
    item:[object Object]
    item:[object Object]
    item:[object Object]
    item:[object Object]
    THIS DOES NOT WORK:
    for(s =0 ; s < __modelLocator.siteRef.length; s++){
    trace(s +" --this is page:" +
    __modelLocator.siteRef[s]['template']);
    trace("CHECK:" +__modelLocator.siteRef[3]['template']); //
    this thoughts up an error below:
    ERROR: RangeError: Index '3' specified is out of bounds.
    which is why these do not work in the for loop:
    for(s =0 ; s <= __modelLocator.siteRef.length; s++)
    for(s =0 ; s < __modelLocator.siteRef.length+1;
    s++)

    If you use the debugger and step through the ArrayCollection
    as it does each loop - what does the watch variables panel show?
    This shouldn't make a difference, but out of curiosity -
    after the AC has all it's day, if you make a copy of it and then
    loop over it... what happens...? E.g.:
    __modelLocator.siteRef.addItem(templatesAllData);
    var newAC : ArrayCollection =
    ObjectUtil.copy(__modelLocator.siteRef);
    for(s =0 ; s < newAC.length; s++)
    Or another idea... instead of accessing the AC via index
    (e.g. siteRef[s]), what if in the loop you do a getItemAt(s)?

  • Issue Putting Data from ArrayCollection into List

    I'm having trouble getting data that has been pulled from a textArea and put into an ArrayCollection to be displayed in a List.  The data is being saved and then read as a file from local storage.  When I run the application, nothing appears in the created list even though I get no compile-time errors.
    Here is my List code:
    <fx:Script>
    <![CDATA[
    import dh.DataHandling;
    import mx.collections.ArrayCollection;
    import mx.collections.ArrayList;
    import mx.events.FlexEvent;
    import spark.effects.SlideViewTransition;
    [Bindable]
    private var dataR:DataHandling = new DataHandling();
    protected function button1_clickHandler(event:MouseEvent):void  // pushed home button
    var svt:SlideViewTransition = new SlideViewTransition(300, SlideViewTransition.SLIDE_RIGHT);
    navigator.pushView(views.HomePage, event.relatedObject, svt);
    ]]>
    </fx:Script>
    <fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:actionContent>
    <s:Button label="Delete"/>
    <s:Button label="Home" click="button1_clickHandler(event)" skinClass="skins.homeButtonSkin"/>
    </s:actionContent>
    <s:Image x="0" y="-80" height="603" source="mainapp1.jpg"/>
    <s:List  id="myCardsList" x="10" y="10" width="1004" height="500" top="0" bottom="0" left="0" right="0"
      dataProvider="{dataR.cards as ArrayCollection}">
    <s:itemRenderer>
    <fx:Component>
    <s:MobileIconItemRenderer label="{data.textTitle}"/>
    </fx:Component>
    </s:itemRenderer>
    </s:List>
    Here's the "saving/reading the file" class used in creating the ArrayCollection:  ( DataHandling.as )
    package dh
    public class DataHandling
    import flash.events.IOErrorEvent;
    import flash.filesystem.File;
    import flash.filesystem.FileMode;
    import flash.filesystem.FileStream;
    import mx.collections.ArrayCollection;
    [Bindable]
    public var cards:ArrayCollection = new ArrayCollection();
    public var file:File;
    public var fileStream:FileStream;
    public var fileName:String = "Initial String";
    public var directory:String = "SimpleSaveFromAIR";
    public var textTitle:String;
    public function DataHandling()
    public function add():void
    // new object
    var card:Object = new Object();
    card.tcard = textTitle;
    //card.mtext1 = mtext1.text;
    ///card.mtext2 = mtext2.text;
    cards.addItem(card);
    public function save():void
    // create file object (resolve user's directory, add own directory)
    file = File.documentsDirectory.resolvePath(directory + "\\" + fileName);
    // FileStream for writing the file
    fileStream = new FileStream();
    // open the file in write mode
    fileStream.open(file, FileMode.WRITE);
    // Write the ArrayCollection object of cards to the file
    fileStream.writeObject(cards);
    // close stream
    fileStream.close();
    public function read():void
    // get correct path
    file = File.documentsDirectory.resolvePath(directory + "\\" + fileName);
    // read if exists
    if(file.exists)
    // FileStream for reading the file
    fileStream = new FileStream();
    // open the file in read mode
    fileStream.open(file, FileMode.READ);
    // Read the ArrayCollection object of cards from the file
    cards = fileStream.readObject() as ArrayCollection;
    //close Stream
    fileStream.close();
    else
    // some sample data + save if file does not exist
    cards = new ArrayCollection();
    var card:Object = new Object();
    card.tcard = "Sample Title";
    card.mtext1 = "Sample Text";
    cards.addItem(card);
    save();

    Off topic: I noticed you are binding the label value of the renderer to the data.  It's recommended that you use the labelField property on the List instead for better performance on mobile, for example:
    <s:List  id="myCardsList" labelField="textTitle" ...>
      <s:itemRenderer>
        <fx:Component>
          <s:MobileIconItemRenderer />
        </fx:Component>
      </s:itemRenderer>
    </s:List>

  • Help needed in  converting ArrayList to ArrayCollection

    I am converting an ArrayList (Java) to ArrayCollection of Flex .
    Please help me in this , i dont know whether this is correct approach or not
    I have a Created a User VO ActionScript class  on flex with two properties as uname , pass .
    [Bindable]       
            var result:ArrayCollection
    private function displayDetails(event:ResultEvent):void
    result = event.result as ArrayCollection;
    <mx:DataGrid  dataProvider="{result}">
                    <mx:columns>
                        <mx:DataGridColumn headerText="UserName" dataField="uname"/>
                        <mx:DataGridColumn headerText="Password" dataField="pass"/>
                    </mx:columns>
                </mx:DataGrid>
    This is from my Java DAO File :
                ResultSet rs = stmt.executeQuery("select NAME , PASS from Users");
                list = new ArrayList();
                while (rs.next()) {
                    User user = new User();
                    user.setUname(rs.getString(1));
                    user.setPass(rs.getString(2));
                    list.add(user);
            return list;
    With the below code ,the displayed DataGrid is empty with no data , please help me where i am doung wrong
    Do i need to do anything more ?? The data is coming well on to the lcds server console .
    Please help .

    Hi Kiran,
    Debugging solves most of the problems that you encounter ......you need to use a lot of debuggung so that you will come to know exactly what's
    happening indeed...
    So just put a break point at your displayDetails(event:ResultEvent):void  function and try to watch the event variable and check the event.result
    What is the datatype of the event.result ...Are you getting any data or is it null..???
    Please make these observations and let me know...
    Thanks,
    Bhasker

  • Can anyone solve this simple MVC problem with ArrayCollection

    I have very simple application trying to understand how to apply MVC without any framework. There are quite a few exemples on the net but most do not deal with complex data.
    here is my application with 4 files: MVCtest.mxml, MyController.as, MyModel.as and MyComponent.as
    first the Model MyModel.as
    package model
    import flash.events.Event;
    import flash.events.EventDispatcher;
    import flash.events.IEventDispatcher;
    import mx.collections.ArrayCollection;
    [Event(name="ArrayColChanged", type="flash.events.Event")]
    [Bindable]
    public class MyModel extends EventDispatcher
      private static var instance:MyModel;
      public static const ARRAYCOL_CHANGED:String = "ArrayColChanged";
      private var _myArrayCol:ArrayCollection;
      public function MyModel(target:IEventDispatcher=null)
       super(target);
       instance = this;
      public static function getInstance():MyModel
       if(instance == null)
        instance = new MyModel();
       return instance;
      public function get myArrayCol():ArrayCollection
       return _myArrayCol;
      public function set myArrayCol(value:ArrayCollection):void
       _myArrayCol = new ArrayCollection(value.source);
       dispatchEvent(new Event(ARRAYCOL_CHANGED));
    then the controller: MyController.as
    package controller
    import components.MyComponent;
    import flash.events.Event;
    import flash.events.EventDispatcher;
    import flash.events.IEventDispatcher;
    import model.MyModel;
    import mx.collections.ArrayCollection;
    import mx.controls.Alert;
    import mx.rpc.events.FaultEvent;
    import mx.rpc.events.ResultEvent;
    import mx.rpc.remoting.RemoteObject;
    public class MyController extends EventDispatcher
      [Bindable]
      public var view:MVCtest;
      [Bindable]
      public var componentView:MyComponent;
      private var _model:MyModel = MyModel.getInstance();
      public function MyController(target:IEventDispatcher=null)
       super(target);
       _model.addEventListener("ArrayColChanged", onArrayColChange);
      public function initialise(event:Event):void
       getData();
      public function getData():void
       var dataRO:RemoteObject = new RemoteObject;
       dataRO.endpoint = "gateway.php";
       dataRO.source = "MytestdbService";
       dataRO.destination = "MytestdbService";
       dataRO.addEventListener(ResultEvent.RESULT, dataROResultHandler);
       dataRO.addEventListener(FaultEvent.FAULT, dataROFaultHandler);
       dataRO.getAllMytestdb();   
      public function dataROResultHandler(event:ResultEvent):void
       _model.myArrayCol = new ArrayCollection((event.result).source);
      public function dataROFaultHandler(event:FaultEvent):void
       Alert.show(event.fault.toString());
      public function onArrayColChange(event:Event):void
       componentView.myDataGrid.dataProvider = _model.myArrayCol;
    This is the main application: MVCtest.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
          xmlns:s="library://ns.adobe.com/flex/spark"
          xmlns:mx="library://ns.adobe.com/flex/mx"
          xmlns:controller="controller.*"
          xmlns:components="components.*"
          width="600" height="600"
          creationComplete="control.initialise(event)">
    <fx:Declarations>
      <controller:MyController id="control" view = "{this}"/>
    </fx:Declarations>
    <fx:Script>
      <![CDATA[
       import model.MyModel;
       import valueObjects.MyVOorDTO;
       [Bindable]
       private var _model:MyModel = MyModel.getInstance();
      ]]>
    </fx:Script>
    <s:VGroup paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10">
      <s:Label fontSize="20" fontWeight="bold" text="MVC Test with components"
         verticalAlign="middle"/>
      <components:MyComponent/>
    </s:VGroup>
    </s:Application>
    And this is the component: MyComponent.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
       xmlns:s="library://ns.adobe.com/flex/spark"
       xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300">
    <s:layout>
      <s:VerticalLayout paddingBottom="10" paddingLeft="10" paddingRight="10" paddingTop="10"/>
    </s:layout>
    <fx:Declarations>
      <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:Label fontSize="16" fontWeight="bold" text="My Component " verticalAlign="bottom"/>
    <s:DataGrid id="myDataGrid" width="100%" height="100%" requestedRowCount="4">
      <s:columns>
       <s:ArrayList>
        <s:GridColumn dataField="mystring" headerText="String"></s:GridColumn>
        <s:GridColumn dataField="myinteger" headerText="Integer"></s:GridColumn>
        <s:GridColumn dataField="myreal" headerText="Real"></s:GridColumn>
        <s:GridColumn dataField="mydate" headerText="Date"></s:GridColumn>
       </s:ArrayList>
      </s:columns>
    </s:DataGrid>
    </s:Group>
    Here is the code to generate the database:
    CREATE DATABASE mytest;
    CREATE TABLE myTestDB
          myid INT UNSIGNED NOT NULL AUTO_INCREMENT,
          mystring CHAR(15) NOT NULL,
          myinteger INT NOT NULL,
          myreal DECIMAL(6,2) NOT NULL,
          mydate DATE NOT NULL,
          PRIMARY KEY(myid)
    ) ENGINE = InnoDB;
    INSERT INTO myTestDB (mystring, myinteger, myreal, mydate) VALUES ('Test', 123, 45.67, '2012-01-01'), ('Practice', 890, 12.34, '2012-02-01'), ('Assay', 567, 78.90, '2011-10-01'), ('Trial', 111, 22.22, '2009-09-09'), ('Experiment', 333, 44.44, '1999-04-15'), ('Challenge', 555, 66.66, '2012-12-21');
    And finally here is the PHP script.
    <?php
    class myVOorDTO
      var $_explicitType = "valueObjects.myVOorDTO";
      public $myid;
      public $mystring;
      public $myinteger;
      public $myreal;
      public $mydate;
      public function __construct()
        $this->myid = 0;
        $this->mystring = "";
        $this->myinteger = 0;
        $this->myreal = 0.0;
        $this->mydate = date("c");
    class MytestdbService
      var $username = "yourusername";
      var $password = "yourpassword";
      var $server = "yourserver";
      var $port = "yourport";
      var $databasename = "mytest";
      var $tablename = "mytestdb";
      var $connection;
      public function __construct()
        $this->connection = mysqli_connect(
        $this->server, $this->username, $this->password, $this->databasename, $this->port);
    * Returns all the rows from the table.
    * @return myVOorDTO
      public function getAllMytestdb()
        $query = "SELECT * from $this->tablename";
        $result = mysqli_query($this->connection, $query);
        $results = array();
        while ($obj = mysqli_fetch_assoc($result))
          $row = new myVOorDTO();
          $row->myid = $obj['myid'] + 0;
          $row->mystring = $obj['mystring'];
          $row->myinteger = $obj['myinteger'] + 0;
          $row->myreal = $obj['myreal'] + 0.0;
          $row->mydate = new Datetime($obj['mydate']);
          array_push($results, $row);
        return $results;
    ?>
    My understanding as to what is going on is: (1) on creation complete the application launch the initialise() function of the controller (2) this function starts the remoteObject which get the data (3) once the results arrive the resultHandler store the data into the ArrayCollection of the model ***this does not work*** (4) even if part 3 did not work, the setter of the ArrayCollection in the model send an event that it has been changed (5) the controller receive this event and assigns the ArrayCollection of the model as the dataprovider for the datagrid in the compoent.
    Of course, since the ArrayCollection is null, the application gives an error as the dataProvider for the datagrid is null.
    What is missing in this application to make it work properly? I believe this is an example that could help a lot of people.
    Even if I change the setter in the model to _myArrayCol = ObjectUtil.copy(value) as ArrayCollection; it still does not work.
    Also, it seems that the remoteObject does not return a typed object (i.e. myVOorDTO) but rather generic objects. I am usually able to make this works but in this particular application I have not managed to do it. Again what's missing?
    Thanks for any help with this!

    Calendar c = GregorianCalendar.getInstance();
    c.set(Calendar.YEAR,2000);
    System.out.println(c.getActualMaximum(Calendar.WEEK_OF_YEAR));
    c.set(Calendar.YEAR,2001);
    System.out.println(c.getActualMaximum(Calendar.WEEK_OF_YEAR));But it says that 2000 has 53 weeks and 2001 has 52.

  • How to update ArrayCollection at runtime?

    Am facing some problem with arraycollection..
    am having an arraycolelction like this...
    var dpHierarchy:ArrayCollection = new ArrayCollection([
    {Region:"Demand1"},
    {Region:"Demand2"},
    {Region:"Demand3"},
    {Region:"Demand4"}]
    now what am looking for is.. how to update this
    arraycollection at runtime using actions script?
    i need to update this array colelction something like this...
    var dpHierarchy:ArrayCollection = new ArrayCollection([
    {Region:"Demand1", Year:"2008"},
    {Region:"Demand2", Year:"2008"},
    {Region:"Demand3", Year:"2008"},
    {Region:"Demand4", Year:"2008"}]
    How to add Year field in to existing arraycollection like
    shown in about example..
    thanks in advance
    Pratap

    There are two ways you can do this. One would be setting it
    straight like this.
    private function updateDP():void {
    dpHierarchy[0].Year = "2008";
    This will also make it so that every other item in your
    ArrayCollection has the Year identifier however nothing will be
    filled in for the values. The other way you could do this would be
    to user setItemAt which would look like this.
    dpHierarchy.setItemAt({Region:"Demand1", Year:"2008"}, 0);
    which essentially does the exact same thing except your
    setting all the properties of that item instead of just adding the
    identifier Year.

Maybe you are looking for

  • How do i get past IOS 8 activation without a Sim card

    I Bought this Iphone 5 off this dude. but i cant even use it because theres no sim card and the activation thing says i need one.. I have an iphone 4 with the same carrier which is verizon. but the sim card is bigger so it wont fit. i looked up ways

  • Facebook & Flickr Export Problems

    One of the new features of Aperture 3 I was excited about was the Facebook & Flickr integration. I had previously been using a free Flickr plug-in and exporting my Aperture images to iPhoto to make use of the Facebook integration. After preparing a p

  • Reg. File split in XI

    Hi,         How do we split a file in XI? I Know that we can split a file using BPM step Message split. But my scenario is like, I am getting a flat file from a customer and as soon as it picked up by the File adaptor, it should be split into two par

  • Hello,I have problem with restore Iphone

    Hello i have error 1,when i fix this problem pleas

  • How to remove duplicates that appear on my Library?

    How to remove duplicates that appear on my library?