Skip to main content
avid_body16B8
Legend
May 21, 2019
Answered

icon in the list component AS3- Is it possible

  • May 21, 2019
  • 1 reply
  • 1678 views

I am wondering if there is a way to add icons in the list component.

    This topic has been closed for replies.
    Correct answer JoãoCésar17023019

    Hi, res.

    Something like this should do the trick.

    AS3 code:

    import fl.data.DataProvider;

    import fl.controls.List;

    var icons:Vector.<Class> = new <Class>

    [

         Square, // linkage name in the Library

         Circle,

         Triangle

    ];

    var i:int;

    var total:int;

    var totalNewItems:uint = 10;

    list.iconField = "iconSource";

    list1.iconField = "iconSource";

    // replace current items

    for (i = 0, total = list.dataProvider.length; i < total; i++)

         list.dataProvider.replaceItemAt({iconSource:icons[i % icons.length], label:"Item " + i}, i);

    // add new items

    for (i = 0; i < totalNewItems; i++)

         list1.dataProvider.addItemAt({iconSource:icons[i % icons.length], label:"Item " + i}, i);

    FLA download:

    animate_cc_as3_list_component.zip - Google Drive

    Regards,

    JC

    1 reply

    JoãoCésar17023019
    Community Expert
    JoãoCésar17023019Community ExpertCorrect answer
    Community Expert
    May 21, 2019

    Hi, res.

    Something like this should do the trick.

    AS3 code:

    import fl.data.DataProvider;

    import fl.controls.List;

    var icons:Vector.<Class> = new <Class>

    [

         Square, // linkage name in the Library

         Circle,

         Triangle

    ];

    var i:int;

    var total:int;

    var totalNewItems:uint = 10;

    list.iconField = "iconSource";

    list1.iconField = "iconSource";

    // replace current items

    for (i = 0, total = list.dataProvider.length; i < total; i++)

         list.dataProvider.replaceItemAt({iconSource:icons[i % icons.length], label:"Item " + i}, i);

    // add new items

    for (i = 0; i < totalNewItems; i++)

         list1.dataProvider.addItemAt({iconSource:icons[i % icons.length], label:"Item " + i}, i);

    FLA download:

    animate_cc_as3_list_component.zip - Google Drive

    Regards,

    JC

    avid_body16B8
    Legend
    May 21, 2019

    JC you are amazing! This is exactly what I was looking for.

    Muito obrigada.

    JoãoCésar17023019
    Community Expert
    Community Expert
    June 23, 2021

    JC,

    is it possible to retrive dynamically what icon("name") is added to the list component items?

    I would like to retrieve that information controls graphics appereance.


    Hi, MonoDev.

     

    Sorry I didn't answer you the other time.

     

    Do you want to retrieve the icone name? On click?