Skip navigation
Currently Being Moderated

adding a itemRenderer to a spark list using action script

Aug 4, 2011 2:28 PM

Hi guys,

Im adding a spark list using action script.

...IM a bit a new to flex, I want to add an image to an item within the list, Should I be using a ItemRenderer component for this?

If so, once created Im having trouble adding it with action script..

 

my code looks like this...

 

var list:List = new List();

list.dataProvider = collection;

 

I have tried...

list.itemRenderer = "views.ItemRend"

 

and...

list.itemRenderer = ItemRend

 

But I get the same error...

1067: Implicit coercion of a value of type String to an unrelated type mx.core:IFactory. InputBox.as /RegSpotter/src/com line 68 Flex Problem

 

or..

1067: Implicit coercion of a value of type Class to an unrelated type mx.core:IFactory. InputBox.as /RegSpotter/src/com line 68 Flex Problem

 

 

Thanks

  Aidan

 
Replies
  • Currently Being Moderated
    Aug 4, 2011 2:53 PM   in reply to home_aidan

    cant you just cast it...

     

    list.itemRenderer = ItemRend as IFactory;

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 4, 2011 9:37 PM   in reply to kokorito

    myList.itemRenderer = new ClassFactory(MyItemRenderer);

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 26, 2013 8:57 AM   in reply to home_aidan

    I don't get it running:

     

    var itemRend:ItemRenderer = new ItemRenderer();

    var iconItemRend:IconItemRenderer = new IconItemRenderer();

     

    var myAC:ArrayCollection = new ArrayCollection();

    myAC.addItem( {icon: _hungerShopIcon, highscoreName:"Ülkeler", highscoreNameDesc:"Dünyanin tüm ülkeler"} );

    myAC.addItem( {icon: _hungerShopIcon, highscoreName:"Hayvanlar", highscoreNameDesc:"Hayvan dünyasından Kelimeler"} );

    myAC.addItem( {icon: _hungerShopIcon, highscoreName:"Ünlüler", highscoreNameDesc:"Ünlülerin soyadı"} );

    myAC.addItem( {icon: _hungerShopIcon, highscoreName:"Markalar", highscoreNameDesc:"Ünlü marka isimleri"} );

    myAC.addItem( {icon: _hungerShopIcon, highscoreName:"Gida", highscoreNameDesc:"Yeme ve İçme"} );

    myAC.addItem( {icon: _hungerShopIcon, highscoreName:"Şehirler", highscoreNameDesc:"Ünlü Şehirler"} );

    var list:List = new List();

    list.dataProvider = myAC;

    list.itemRenderer = new ClassFactory(itemRend);

     

    Implicit coercion of a value of type spark.components.supportClasses:ItemRenderer to an unrelated type Class.

     

    Second question is how I could add the IconItemRenderer?

     

    Best

    omi

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 26, 2013 9:16 AM   in reply to grosssmutttr

    ClassFactory takes a class not an instance of that class.

     

    So instead of this:

     

    list.itemRenderer = new ClassFactory(itemRend);

     

    It should be:

     

    list.itemRenderer = new ClassFactory(IconItemRenderer);

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points