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 6609961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:46:48+00:00 2026-05-25T19:46:48+00:00

I’m probably misusing bindable variables here, so please bear with me here while I

  • 0

I’m probably misusing bindable variables here, so please bear with me here while I try and explain what I’m trying to to.

I have a simple spark list where I allow people to select a background by clicking on one of the items. When a background is selected, I then save it to the SharedObject in order to use it when the user loads the application again later.

This list is populated by an ArrayCollection (binded variable) created as follows:

[Bindable] private var arrBG:ArrayCollection = new ArrayCollection();

This then gets populated the following way:

var objImage:Object;
var strSharedObjImage:String = sharedObj.sharedBackground.data.backgroundIndex;
// Background
objImage = new Object();
objImage.icon = ICONS_PATH + objImage.label;
objImage.label = "Titanium";
objImage.selected = (strSharedObjImage == objImage.fileName) ? true : false;
arrBG.addItem(objImage);

objImage = new Object();
objImage.icon = ICONS_PATH + objImage.fileName;
objImage.label = "Iron";
objImage.selected = (strSharedObjImage == objImage.label) ? true : false;
arrBG.addItem(objImage);

I then use it as the dataProvider on my spark list.

If you notice above, on my object I have a property called selected, which will get set to true, if the value of my shared object is the same as the value on the “label” property.

On the item renderer for my spark list, I have the following:

<s:ItemRenderer name="HorizontalListSkin"
                xmlns:fx="http://ns.adobe.com/mxml/2009"
                xmlns:s="library://ns.adobe.com/flex/spark"
                autoDrawBackground="false" 
                creationComplete="initMenuSkin(event)"
                >

    <fx:Script>
        <![CDATA[
        protected function initMenuSkin(event:Event):void
        {

            iconImage.source = data.icon;
            iconText.text = data.label;

            // Check to see if the item we're displying is selected. If it is make it stand out
            if(data.selected){
                iconText.setStyle("color", "Green")
            }
        }

        ]]>
    </fx:Script>

    <s:VGroup x="10" y="10" width="50" height="50" buttonMode="true" horizontalAlign="center">
        <s:Image id="iconImage" horizontalCenter="0"/>
        <s:Label id="iconText" fontFamily="Verdana" fontSize="11" fontWeight="bold" horizontalCenter="0" showTruncationTip="false"/>
    </s:VGroup> 

</s:ItemRenderer>

So as you can see, I’m simply changing the colour of the font on my selected item.

When I load it up, I can see that the item I have previously selected is marked in green, and if I select a new item, I would like it to now be marked as green instead.

Obviously there’s a big gap in here, since nowhere in my explanation above I mention updating my bindable variable so in theory it wold propagate to my spark list (being it a bindable variable I would of thought it would simultaneously update the item on my list(?)).

Well, I have tried doing it in a few different ways, and the debugger does “say” my array has been updated, however, my list isn’t being updated at all, and will only bring another item marked in green if I close the screen and open again (when it all gets reloaded)

The whole logic described above to create a new background is contained within a function, so whenever I select an item from my list of backgrounds I was triggering my “loadBackgrounds” method again, which would apply all the logic to know which is the selected background, and because the variable is binded with my spark list I’d have hoped would update the list. Thing is, it doesn’t.

What am I doing wrong here? Am I going totally bonkers and there’s a much easier way of doing this but only I can’t see it?

Any help here would be appreciated.

Thanks in advance

  • 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-25T19:46:49+00:00Added an answer on May 25, 2026 at 7:46 pm

    After you set the data ion the collection you need to refresh it.

    arrBG.refresh();
    

    [EDIT]
    Ok I re-read your question.
    I think I misunderstood what you were asking.
    You want to know how to update the list so the item renderer will re-render the new list after you made changes to the data provider?

    function newSelection( val:String ):void{
      for each( var item:Object in arrBG ){
        if( item.label == val ){
          item.selected = true;
        }else{
          item.selected = false;
        }
      }
      arrBG.refresh();
    }
    

    // use the commit properties on your renderer not the init
    // commit properties will trigger whenever there is a dataprovider update/change

    <s:ItemRenderer name="HorizontalListSkin"
                    xmlns:fx="http://ns.adobe.com/mxml/2009"
                    xmlns:s="library://ns.adobe.com/flex/spark"
                    autoDrawBackground="false" 
                    >
    
        <fx:Script>
            <![CDATA[
            override protected function commitProperties():void{
                super.commitProperties();
                iconImage.source = data.icon;
                iconText.text = data.label;
    
                // Check to see if the item we're displying is selected. If it is make it stand out
                if(data.selected){
                    iconText.setStyle("color", "Green")
                }
            }
    
            ]]>
        </fx:Script>
    
        <s:VGroup x="10" y="10" width="50" height="50" buttonMode="true" horizontalAlign="center">
            <s:Image id="iconImage" horizontalCenter="0"/>
            <s:Label id="iconText" fontFamily="Verdana" fontSize="11" fontWeight="bold" horizontalCenter="0" showTruncationTip="false"/>
        </s:VGroup> 
    
    </s:ItemRenderer>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I am trying to loop through a bunch of documents I have to put
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into

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.