Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6973363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:05:56+00:00 2026-05-27T17:05:56+00:00

I have a component A in my flex project where people can vote for

  • 0

I have a component A in my flex project where people can vote for their favourite artist. Someone “likes” an artist, it get’s updated in my database. There is also a component B that shows a chart of the most liked artists. I call the data from the database on creationcomplete in Flex. The problem is that when a person first votes on an artist, it will not be visible in the datagrid untill the user reloads the main page (?) or reopens the entire application. So i was wondering how i can update the datagrid everytime someone adds a vote to my database. I’m now using an update button, but that’s not very user friendly of course. Any help is welcome!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T17:05:56+00:00Added an answer on May 27, 2026 at 5:05 pm

    Using an arrayCollection, you just make it bindable all the way through all components

    <fx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            import mx.events.FlexEvent;
    
            [Bindable]
            public var artistData:ArrayCollection = new ArrayCollection([
                {artistName : "Paula", artistLikes : "0"},
                {artistName : "Bob", artistLikes : "0"},
                {artistName : "Arthur", artistLikes : "0"}
            ]);
    
        ]]>
    </fx:Script>
    
    <s:layout>
        <s:VerticalLayout/>
    </s:layout>
    
    <s:DataGrid id="artists" dataProvider="{artistData}" width="100%" height="150">
        <s:columns>
            <s:ArrayList>
                <s:GridColumn dataField="artistName" headerText="Artist Name"/>
                <s:GridColumn dataField="artistLikes" headerText="Artist Likes"/>
            </s:ArrayList>
        </s:columns>
    </s:DataGrid>
    
    <components:CompA artistDataInCompA="{artistData}" height="100"/>
    
    <components:CompB artistDataInCompB="{artistData}" height="100"/>
    

    Let’s say you increment your likes in comp A (Don’t forget to call the refresh() on the arrayCollection)

    <fx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
    
            [Bindable]
            public var artistDataInCompA:ArrayCollection;
    
            protected function button_clickHandler(name:String):void
            {
                var index:Number = getItemIndexByProperty(artistDataInCompA, "artistName", name);
                var numLikes:Number = artistDataInCompA[index].artistLikes;
                // Here you update your PHP
                // HTTPService...
    
                // and the ArrayCollection that is binded all the way through all components
                artistDataInCompA[index].artistLikes = numLikes + 1;
                artistDataInCompA.refresh();
            }
    
            protected function getItemIndexByProperty(array:ArrayCollection, property:String, value:String):Number
            {
                for (var i:Number = 0; i < array.length; i++)
                {
                    var obj:Object = Object(array[i])
                    if (obj[property] == value)
                        return i;
                }
                return -1;
            }
    
        ]]>
    </fx:Script>
    
    <s:layout>
        <s:VerticalLayout/>
    </s:layout>
    
    <s:Button label="Add a like to Paula" click="button_clickHandler('Paula')"/>
    
    <s:Button label="Add a like to Bob" click="button_clickHandler('Bob')"/>
    
    <s:Button label="Add a like to Arthur" click="button_clickHandler('Arthur')"/>
    

    And now do what you have to do in your comp B

    <fx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
    
            [Bindable]
            public var artistDataInCompB:ArrayCollection;
    
        ]]>
    </fx:Script>
    
    <s:layout>
        <s:VerticalLayout/>
    </s:layout>
    
    <s:Label text="Paula has {artistDataInCompB.getItemAt(0).artistLikes} like(s)"/>
    
    <s:Label text="Bob has {artistDataInCompB.getItemAt(1).artistLikes} like(s)"/>
    
    <s:Label text="Arthur has {artistDataInCompB.getItemAt(2).artistLikes} like(s)"/>
    

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've just imported a Flex component into my project. I have a theory question
I just took over a clients flex project and I can't get the app
In a current Flex project, i have an issue where a certain child component
I'm creating a new Flex component (Flex 3). I'd like it to have a
I have a requirement to be able to provide a flex component in English
So I have a flex tree component with a xmllistcollection as it's data provider.
So I have a module in flex in which I add a custom component.
I have: @Component class MyDecorator{ private Cache cache; /* some wrapped methods like get
is it possible to move a flex mxml project into flash? i have the
I have a project that was compiled with the Flex 3.2 SDK. One of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.