A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Dataprovider / Array problem...

  1. #1
    Join Date
    May 2006

    Dataprovider / Array problem...

    Here's the issue I'm having. I am entering some info into a dataprovider based on some radio buttons.

    When I trace the contents of the dataprovider, everything shows up fine (3 items with the values I want to show). However when I try to add the contents of the dataprovider into a textbox, it only shows the last item.

    There is a bunch of code in the project, so I just copied out what is being used for this part.

    I don't have much experience with dataproviders, so if anyone can point me in the right direction it would be much appreciated.

    var dpataProvider = new DataProvider();
    dp.addItem(event.currentTarget.value+" "+event.currentTarget.label);

    mysubmit.addEventListener(MouseEvent.CLICK, sendForm);
    function sendForm(evt:MouseEvent):void {


  2. #2
    a.k.a gltovar deadlock32's Avatar
    Join Date
    May 2001
    while you can trace arrays and see all the data (providing they are not objects) I wonder how the like: testbox.text = dp.toArray(); even worked... because it threw an error that the value being assigned to testbox.text wasn't a string.

    A few simple ways to convert an array to a string:
    testbox.text = dp.toArray().toString();  // will output with commas seperating the values
    testbox.text = dp.toArray().join('~~'); // will output one string with the dilimeter in the join param
    and other ways as well, like going though each value and appending it to a string for example.

    the code I tested with:
    PHP Code:
    var arr:Array = ['hi''hello''sup'];
    trace(arr); // hi,hellow,sup

    textbox.text arr// throws error

    textbox.text arr.toString(); // outputs the same as the trace

    textbox.text arr.join('.-*-.'// outputs with goofy delimiter 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width

HTML5 Development Center