Arrays to List component

I am fairly new AS3 coder now using Flash Builder and I can't work out how to display my data (a collection of actionscript arrays returned by a AS3 function) in a List component as a list of labels and images. My arrays look like this:
var aNames:Array = new Array("John", "Ringo", "Paul");
var aImages:Array = new Array("http://myserver.com/image1.jpg", "http://myserver.com/image2.jpg", "http://myserver.com/image3.jpg");
Now I want to display them in a list component, each list item has the image on the left and then the name on the right.
Can anyone provide an example please, I think I need to use an arraycollection and a custom item renderer inside the list and then have the lists dataprovider set to the arraycollection but have not been able to construct the code.
Many thanks.

You'll get better responses on the Flex general discussion forum for non-Flash Builder queries.
-Anirudh

Similar Messages

  • Adding Images to the List component

    Adding Images to the List component while using the FLV
    PLayback
    All, ( i can send you my source files if it would help)
    I'm using the FLV Playback component and loading videos into
    it from an external xml file. I also have a list component tied to
    the FLV playback that when you click on one of the elements in the
    list, it plays that movie.
    QUESTION:
    My question is how do I add an image to the list component?
    Below is the xml file and the actionscript. I've added the image
    attribute to the XML file as img="time_square.jpg" and added the
    element of the array when calling/creating the list. Did I do this
    right?
    Any direction would be very much appreciated.

    Adding Images to the List component while using the FLV
    PLayback
    All, ( i can send you my source files if it would help)
    I'm using the FLV Playback component and loading videos into
    it from an external xml file. I also have a list component tied to
    the FLV playback that when you click on one of the elements in the
    list, it plays that movie.
    QUESTION:
    My question is how do I add an image to the list component?
    Below is the xml file and the actionscript. I've added the image
    attribute to the XML file as img="time_square.jpg" and added the
    element of the array when calling/creating the list. Did I do this
    right?
    Any direction would be very much appreciated.

  • Video, XML and List Component

    Hello all,
    I have this code that is suposed to take my simple little XML
    file and populate it into a List component which in turn when an
    item is click it will play the video assigned to it. I have a
    custom player built and it works perfectly when I just load in one
    movie by hard coding its path into my AS, however when I load the
    XML in it only will play the first movie in the list, and will not
    load in any other movie when selected.
    My code is below. anyone that can help it would be greatly
    appreciated. The XML code is at the bottom.

    funkysoul,
    First thanks for taking a look at what I have. To answer your
    question yes I have changed the start up movie in the Array (i.e.
    from 0 to 1 or 2 or 3) and it does play that movie first, but again
    when I click to load in another movie it does not play anything
    else.

  • Remove duplicate entry in list component

    I have a list component which loads xml into it. I have
    multiple entries in the list that are the same and i want to remove
    the duplicates. if anyone has an idea or hint it would be
    appreciated.
    Thanks

    "Rain1522" <[email protected]> wrote in
    message
    news:ebamrt$s5h$[email protected]..
    >I have a list component which loads xml into it. I have
    multiple entries in
    >the
    > list that are the same and i want to remove the
    duplicates. if anyone has
    > an
    > idea or hint it would be appreciated.
    >
    > Thanks
    >
    > function loadGulf(){
    > import mx.xpath.XPathAPI;
    > var cityXml:XML = new XML();
    > cityXml.ignoreWhite = true;
    > cityXml.onLoad = function(success:Boolean) {
    > trace("onload...");
    > if (success) {
    > trace("success...");
    > // Retrieve all Cities notes within /document/City.
    > var thePath_str:String = "/document/City"; // path of
    nodes
    > var plan_array:Array =
    XPathAPI.selectNodeList(this.firstChild,
    > thePath_str);
    > for (var i:Number = 0; i < plan_array.length; i++) {
    > var planArray = plan_array
    .firstChild.nodeValue;
    >
    > function checkMatch(compare:String) {
    > for(j=0;j<myList.length;j++){
    > if (myList.getItemAt(j).label==compare){
    > return true;
    > }
    > }
    > }
    >
    if(checkMatch(plan_array.firstChild.nodeValue)!=true){
    > myList.addItem(plan_array
    .firstChild.nodeValue);
    > }
    >
    > }
    > } else {
    > trace("error loading XML");
    > }
    > };
    > cityXml.load("new.xml");
    > }
    > loadGulf();
    >
    I have a book with a function for quick searching arrays, but
    it is at work.
    If not answered by tomorrow morning then I will try to
    remember to post a
    solution.

  • List Component - Multi-select retrieve data

    Hey there,
    I'm having trouble retrieving the value of a multi-select
    list component. It always traces the last value selected, but I
    need to trace all values to parse the data.
    I've been using trace(myList.value);
    thanks!
    Billy

    Hi
    "selectedItems" will give you the items selected.
    var data_array:Array = new Array({data:1, label:"yaho"},
    {data:2, label:"proper"}, {data:3, label:"myname"}, {data:4,
    label:"thatfigure"}, {data:5, label:"fulltight"}, {data:6,
    label:"mythigsare"}, {data:7, label:"thatis"}, {data:8,
    label:"thisda"});
    lst.dataProvider = data_array;
    lst.addEventListener("change", mx.utils.Delegate.create(this,
    mySelection));
    function mySelection(evt) {
    var _items = evt.target.selectedItems;
    for (var i = 0; i<_items.length; i++) {
    trace(_items
    .label);
    trace("----------------");

  • Why doesn't  list component identify grid component

    Hi,
    I have couple of doubts.
    1. I put <grid> component inside of <List>
    component . Surprise! The <List> component is not identifying
    the <Grid> component. Is this bug of Flex Or it's property of
    Flex <List> component.
    What I have to do to make <Grid> visible even I put
    inside of <List> component.
    2. what is an equilanat of <Table> in Flex. Ofcourse it
    may be DataGrid. Suppose If I use DataGrid I have lot of
    restrictions.
    These are the problems I am facing with <DataGrid>
    ( i ) Is this possible to put radio button / link bar as one
    of column in a row. I mean how to put radio button / link bar as
    row in array
    ( ii ) Is it possible to make columns in a row as variable
    sizes i.e. suppose if DataGrid header has size=100. Is it possible
    to make column of next row size as 200.
    anybody help me in this regard. I am eagarly waiting for
    reply.Because I have been strugling to solve this problem for last
    4 days.
    Regards,
    Siva Kumar

    A custom itemRenderer will be the solution to several of your
    issues(1,i).
    For 2., there is no exact equivalent of an html table. Look
    at Grid, TileList, or consider making your own component.
    for ii), no, all cells in a columns must be the same size.
    Tracy

  • Change Event dispatched 2 times in List Component

    Hi,
        Thanks for taking the time to read about my problem. I have a List component which has a simlpe array of strings as a dataprovider. I'm using the change event to call a method and I don't know why this method gets called 2 times.
    ¿Someone knows why this keeps happening?
    Thanks for your help.
    Sebastián Toro

    If an s:List, you put a IndexChangeEvent listener the event, and in that event, cast a filterFunction to the dataProvider of that List ...
    You will have to validate inside that function through property IndexChangeEvent newIndex of greater than or equal to ZERO.
    Because interestingly, the dataProvider of the List filter is invoked IndexChangeEvent again, but now the newIndex, give a value of "-1", leading with it the entire event, from null and associated with this throw this:
    Error # 1009: Can not access a property or method of a null object reference.
    When referring to the event ... :/

  • Displaying Text in List Component

    I am using AS3 to load data from an XML document into an Array and use the Array as a dataProvider for a List Component. If I addChild the list to the main timeline, everything works fine. All 38 elements show up in the list with readable text. When I addChild the list into a MovieClip, all 38 rows of the list get created, but no text shows up. What the hell is going on? Does anyone know what the fix for this is and why in the world this is happening?
    Here's my code:
    TOCList = new List();
    TOCList.dataProvider= new DataProvider(TOCArray);
    TOCList.labelField="theLabel";
    TOCList.y=75;
    TOCList.width=250;
    TOCList.height=350;
    addChild(TOCList);
    When I change the addChild(TOCList) to navBar.sceneMenu.addChild(TOCList) the list shows up formatted correctly, just no text.

    I figured it out with help from another web site's forum and the problem was that the MovieClip that I was loading into was masked, so the font needed to be embedded and my code...
         var myFormat:TextFormat = new TextFormat();
        myFormat.font="Tahoma";
        TOCList.setStyle("embedFonts", true);
        TOCList.setStyle("textFormat", myFormat);
    ...wasn't working, but I didn't know, because the text wasn't showing.
    The fix was actually to use the StyleManager...
    StyleManager.setStyle( "textFormat", new TextFormat("Arial") );
    StyleManager.setStyle( "embedFonts", true );
    ...to force all components to this style.
    I have no idea why the above code doesn't work. If anybody knows, please tell me!!!

  • Help using list component

    My goal is to have a flash projector file that displays a
    list, and when you click on an item, it runs the corresponding .exe
    file. I am using Flash CS4, and I don't have much experience when
    it comes to using components. How do you populate the list? Can I
    use an XML file? How do you assign a function to each item in the
    list?
    Thanks,
    gambrker

    There are a number of ways to populate a List component, but
    from what I can see they all boil down to feeding in label/data
    sets.
    You can find various approaches in the Flash documentation...
    search in the AS3 Components section for Using the List. You should
    find all you need to know from those examples.
    You can use an XML file to fill up an array (or two), so long
    as you capture the data from it as label and data entities. Then
    you loop thru the array(s) using the List.addItem() method to
    populate the List. If you used a single array holding {label: ...,
    data:...} objects, you could use List.dataProvider to load up the
    List.
    To assign functions based on selections, my approach would be
    to use the change handler function, maybe with some form of switch
    coding in it to designate an associated external function gets
    called based on the selection made.
    Even if you're able to get something working from what I
    offered, come back and check for other responses. Someone more
    knowledgeable than me may provide some good info that saves you
    some coding.

  • Animate List component

    hello everyone,
    I've been working with Flex 3 for over a year and really want
    to get into customizing components the best way possible, so i've
    been digging into the classes. my first task is to create a smooth
    tween when scrolling a List component instead of the default
    "jumping" motion. So i decided to extend the list and do some
    function overriding:
    override protected function moveRowVertically(i:int,
    numCols:int, moveBlockDistance:Number):void
    var r:IListItemRenderer;
    trace(String(listItems
    [j]));
    for (var j:int = 0; j < numCols; j++)
    r = listItems[j];
    prev_y
    = r.y + moveBlockDistance;
    //trace(r.y +" "+(r.y+ moveBlockDistance)+" "+prev_y);
    TweenMax.to(r,0.5,{y:(r.y +
    moveBlockDistance),ease:Sine.easeOut});
    //r.move(r.x, r.y + moveBlockDistance);
    rowInfo
    .y += moveBlockDistance;
    I've found moveRowVertically to be the method that actually
    does the vertical row movement (called from the scrollVertically
    method in the ListBase class). As you can see, i've added the
    TweenMax where the object's move method was. This works
    normally when the tween time is set to 0 sec, the List scroll
    effect is the same as the stock component. But when TweenMax.to is
    changed to 0.5 sec, the animation behaves strangely. I believe this
    is partly because when a new object appears in the list it is
    immediately added to the list, so the method that controls the
    addChild needs to have the TweenMax animation also applied to. But
    also, there is another problem, when you click the scroll arrow
    before the TweenMax animation is complete, this function uses the
    current y poisition (in the middle of the animation) as opposed to
    the end y position- when the animation is complete. This is why the
    TweenMax positions the items correctly when the TweenMax duration
    is set to 0.
    I
    have an example here.
    When you click the scroll arrow and wait for the animation to
    complete, it works as the code expects. But when you click too fast
    or scroll the scrollbar thumb, you can see the unexpected behavior.
    SO what I believe needs to be added to the code is an array
    that stores the end y coordinate and have the class use that
    instead of the current y coordinate. I believe the best way to do
    this is to store the end y coordinate in the listItems
    [j] array so that i could call: TweenMax.to(r.end_y +
    moveBlockDistance),ease:Sine.easeOut}); and all would be fine (for
    the objects in the display, hopefully). But i cannot find the
    original as file where the listItems property is (aka:
    listContent.listItems as defined in the listItems get and set
    methods in ListBase.as). Here i could extend this and define a
    custom property. But a more important question is this: is it
    possible to define a custom property on the fly, so i wouldn't have
    to extend the listContent object (therefore, extending ListBase,
    then List... on down the line)?
    thank you all for your help!

    Ok I found out that it works fine in IE but not in FirefoX
    HOWEVER it does work fine in Firefox from another computer! I tried
    clearing out the cache but NOTHING...chan ANYONE PLEASE HELP
    ME???

  • How can I select an item from a list component with a seperate button

    This is a repost, I decided it'd probably be better here than
    in the general discussion board. I will try to delete the other
    one.
    Hello Everyone,
    This is my first post here. I am trying to figure out how to
    select an item within a list component with a button. This button
    is calling a function. I have searched for the past 3 hours online
    and I can't find anything about it. I thought perhaps I could set
    the selectedItem parameter, but that is read only, and I believe it
    returns an object reference rather than something like a number so
    even if i could set it, it would be pointless. I also found a get
    focus button, thought that may lead me somewhere, but I think that
    is for setting which component has focus currently as far as typing
    in and things like that. I am lost.
    Basically I am looking for a way to type this
    myList.setSelected(5); where 5 is the 5th item in the list.
    Any help would be much appreciated.

    Never mind found it. It is the property called selectedIndex
    and it is writable

  • How to populate list component via xml file?

    There is a TextArea component that should show the name and
    the description of the item selected in the list component. But I
    dont know how to populate list with external XML and what should be
    the coding in flash as well as what should be written in the XML.
    Please help.

    Here's an xml file listing a couple of brother comedy teams:
    <?xml version="1.0" encoding="UTF-8"?>
    <team>
    <brothers>
    <Marx>
    <name>Groucho</name>
    <name>Chico</name>
    <name>Harpo</name>
    <name>Zeppo</name>
    <name>Gummo</name>
    </Marx>
    <Howard>
    <name>Moe</name>
    <name>Curly</name>
    <name>Shemp</name>
    </Howard>
    </brothers>
    </team>
    Open a new .fla and save it in the same folder as the .xml
    file. Place a List Component on the Stage and name it (in this
    case, "comicTeams_list"). In the first frame write the following
    ActionScript:
    //create XML object and load external xml file
    var broList:XML = new XML();
    broList.ignoreWhite = true;
    broList.onLoad = processList; // this is a function that will
    be written below
    broList.load("populateList.xml");
    function processList(success:Boolean):Void{
    if(success){
    loadList();
    }else{
    trace("Load failure");
    function loadList():Void{
    var broName:String;
    var listEntries =
    broList.firstChild.childNodes[0].childNodes[0].childNodes.length;
    for(var i:Number = 0;i<listEntries;i++){
    broName =
    broList.firstChild.childNodes[0].childNodes[0].childNodes
    .childNodes[0].nodeValue;
    trace(broName);
    comicTeams_list.addItem(broName);
    //to make something happen when you click on a name in the
    List, create a Listener and function
    var broListListener:Object = new Object();
    broListListener.change = someAction; //"someAction" is a
    function to be written shortly
    //add the Listener to the List
    comicTeams_list.addEventListener("change", broListListener);
    function someAction(evtObj:Object):Void{
    var pickedBrother:String = evtObj.target.selectedItem.label;
    //write actions here, referencing pickedBrother variable
    The names of the Marx Brothers will appear in the box.
    This is written in AS2. When you post a question, it's a good
    idea include which version of ActionScript you're using.

  • Count the rows in a list-component

    Hi,
    How can I count the rows with a value in a list component?
    I thought it would be RowCount but as I figured out that shows the number of shown rows, not the number of rows with a value.

    Hi,
    Try list.dataProvider.length

  • List component row manipulation

    I have two questions regarding as3 list component:
    - I'd like to highlight and keep selected the item a user last selected from my list component. I've combed the live reference as well as google and must be typing the wrong search words. I can tell what label and index an item was that was selected but am not finding a way to highlight and keep highlighted the user's choice in the list component.
    - Also, I'm exploring the notion of inline buttons within a list's rows. If a user hovers their mouse over a row, a set of small buttons come up the user can click on for further functionality. This may be more of a make your own component answer but I'm exploring it nonetheless. Any thoughts or comments on this?
    Thanks!

    no something else is going on. Or perhaps you didn't explain your problem clearly.
    After servlet b calls getList() you have two servlets each having a reference to the same list
    A------\
    List
    B------/

  • Using a List Component to create a photo gallery.

    This feels like a lot to be asking but i'm gonna go ahead and
    ask to see what happens.
    I'm trying to figure out how to use a list component to
    select 6 items from a large list, display the words to the 6
    selected items (in a text field), then finally (by pressing a
    button) I would like to load the 6 corresponding pictures for the
    selected items into a seperate frame. If there is anyone that could
    point me in the right direction it would be greatly appreciated. I
    have been trying to find information online about programming the
    List Component but haven't had any luck. Is there a book that
    anyone recommends that could help me? I've been doing simple
    animations and websites in flash but i'm now looking to learn some
    actionscripting as well. Thanks.

    Hi PinkPowerRanger,
    Per my understanding that you have two fields in the table "Date and Time picker" which is Date/time type and another is "Item ID", you need to get the Month from the Date field to display in the X-axis and count(Item ID) related to each
    month to display in the Y-Axis, right?
    I have tested on my local environment and can do this by create two calculated fields to get the month and year values from the Date/Time field.
    Details information below for your reference:
    Right click the main dataset to select the "Add Calculated field", specify an name of the new calculated field and add the expression in the field source as below:
    Year:    =Year(Fields!Date.Value)
    Month:  =MonthName(Month(Fields!Date.Value))
    Add the three field in the Chart as below and remember in the Value area you have got the Count(ItemID) but not SUM(ItemID):
    Preview you will got the chart like below:
    If you still have any problem, please feel free to ask.
    Regards
    Vicky Liu
    Vicky Liu
    TechNet Community Support

Maybe you are looking for