dcsimg
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: dataGrid.dataProvider = _root.Array = Not possible??

  1. #1
    Has Returned
    Join Date
    Mar 2001
    Posts
    269

    dataGrid.dataProvider = _root.Array = Not possible??

    Hi guys,

    Sorry but i have another problem.

    If i call my array locally in a SWF for example:
    PHP Code:
    myArray = new Array() 
    then populate it, with a new object:
    PHP Code:
    myArray.push({Player:txtNameScore:score}); 
    then databind it:
    PHP Code:
    dataGrid.dataProvider myArray 
    This works fine.

    The problem i am having is that i am loading in my swf and referencing this using _root (I am of course now declaring myArray in the root). When doing this the dataGrid seems to be having problems using this.

    PHP Code:
    dataGrid.dataProvider _root.myArray 
    This is especially odd as i can still add items to the _root array:
    PHP Code:
    _root.myArray.push({Player:txtNameScore:score}); 
    but it seems that I am unable bind it from there.

    Any ideas?

    TIA,

    Turbs.

  2. #2
    Has Returned
    Join Date
    Mar 2001
    Posts
    269
    Looks like this is the problem i am getting, going to see if i can get round dynamically generating a MC.

    http://www.actionscript.org/forums/s...d.php3?t=72831


    EDIT _ UPDATE
    No joy, makes no difference. Seems to be dynamically generated MC's or imported SWF's cause problems with the dataProvider
    Last edited by Turbs; 05-03-2008 at 04:57 PM.

  3. #3
    Has Returned
    Join Date
    Mar 2001
    Posts
    269
    What a pain in the ass, but i found a work around to what i can only see as a horrible hidden bug.

    I create a new array locally in the imported SWF, then duplicate my _root Array data into this. This works as i have no problem reading the _root. data, just using the dataProvider from it.

    Simply using newArray = _root.realArray did not work though, would cause the same problem. so i had to put it in a loop and and add the data myself.

    PHP Code:
        newscore = [];
        for (
    n=0n<_root.wormscore.lengthn++) {
            
    newscore.push({Player:_root.wormscore[n].PlayerScore:_root.wormscore[n].Score});
        } 
    Last edited by Turbs; 05-03-2008 at 05:56 PM.

  4. #4
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    rather than _root, try using _level0 to point to the array

    PHP Code:
    // a.swf -

    arr = [{Player:"Name1"Score:20}];
    //loadMovieNum("b.swf",1); // both load methods work
    mc.loadMovie("b.swf");

    // b.swf - datagrid - dg

    _level0.arr.push({Player:"Name2"Score:40});
    dg.dataProvider _level0.arr

  5. #5
    Has Returned
    Join Date
    Mar 2001
    Posts
    269
    I gave this a try in the hope it was me overcomplicating things, however im afraid that it did not work.

    It seems that the dataProvider just does not want to work with anything outside of it's own swf root. And this nasty workaround is the only solution.

    Thanks for having a look though.

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