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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:37:00+00:00 2026-05-28T19:37:00+00:00

I have a list that uses a itemRendererFunction to get custom item renderers. Is

  • 0

I have a list that uses a itemRendererFunction to get custom item renderers. Is there a way to only reevaluate one item in the list and get different item renderer?

imagine code like this :

there are two item renderers ItemRendererOne.mxml and ItemRendererTwo.mxml

Data.as

package {

    public class Data {

        private var _data : Boolean = false;

        [Bindable]
        public function get data():Boolean {
            return _data;
        }

        public function set data(value:Boolean) : void {
            _data = value;
        }

        public function Data(value : Boolean) {
            _data = value;
        }
    }
}

and main app is

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                       xmlns:s="library://ns.adobe.com/flex/spark" 
                       xmlns:mx="library://ns.adobe.com/flex/mx" >
    <fx:Script>
        <![CDATA[
            import mx.collections.ArrayList;

            private var dataProvider : ArrayList = new ArrayList([new Data(true), new Data(false)]); 

            public function getItemRenderer(data : Object) : IFactory {
                if (data.data) {
                    return new ClassFactory(ItemRendererOne);
                } else {
                    return new ClassFactory(ItemRendererTwo);
                }
            }

            protected function button1_clickHandler(event : MouseEvent) : void {
                var data : Data = dataProvider.getItemAt(0) as Data;
                data.data = !data.data;
            }

        ]]>
    </fx:Script>

    <s:VGroup>
        <s:List dataProvider="{dataProvider}" itemRendererFunction="{getItemRenderer}" />

        <s:Button click="button1_clickHandler(event)" />
    </s:VGroup>

</s:WindowedApplication>

Basically when someone clicks on the button, I want getItemRenderer to be called again and the item in the list is updated with new item renderer.

  • 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-28T19:37:01+00:00Added an answer on May 28, 2026 at 7:37 pm

    Not sure about flex 4 as i mostly work in flex 3 but the set up should be close.
    Basically, let the render handle the rendering.

    Your list should look something like this.

    There are 3 very important overrides you can do that will control the way a renderer can react to data.
    1) set data is for when new data is assigned
    2) createChildren will allow you to dynamically create children. I believe this is the function you are looking for in conjunction with set data
    3) commitProperties this is where you do you assigning data to the children that are hard coded like my label example or the dynamically created children.

    What I have done in the past is similar.
    I test the data agains the current layout if it isn’t the correct layout I rebuild it.
    So in set data method I test if layout is wrong I call createChildren().
    I suppose you could test the data structure on the old data before calling super.data in set data, but I didn’t have good results like that.

    myRenderer.mxml

    <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" >
        <mx:Script>
          <![CDATA[
            override public function set data(val:Object):void{
              super.data = val;
              if( !val ){
                return;
              }
              // test data here if current layout is wrong rebuild it by calling createchildren
            }
            override protected function createChildren():void{
              super.createChildren()
              if( this.data == null ){
                return;
              }
              // create your data driven layout here
            }   
            override protected function commitProperties():void{
              super.commitProperties();
              if ( data == null ){
                return;
              }
            }
    
           ]]>
        </mx:Script>
        <mx:Label id="myLabel" text="{data.someLabelVar} />
    </mx:VBox>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a List that uses a custom ItemRenderer. Is there a way for
In my application, I have a List that uses an item renderer. The renderer
I have a list that uses a database to display some data. There are
I have a list view adapter that uses different types of view rows. Most
I have used a list view that uses a grid view in WPF. I
I have a small application that uses a SharePoint list as the data source.
I have a function that uses Pattern#compile and a Matcher to search a list
We have an ASP.Net page that uses a checkbox to toggle between a list
I have a method I'm writing that uses reflection to list a class's static
I have one list that I want to take a slice of, reverse that

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.