PDA

View Full Version : [AS3] Datagrid not loading when parent swf added as child


melzee
07-02-2009, 08:32 AM
Hi,

I have a datagrid component that is working fine with external XML in a standalone swf.

However, when I try to load this swf into another parent swf all of the data disappears!

Does anyone know how to fix this / or why it is happening?

Thanks,

Melzee

vasu.kondapally
07-02-2009, 10:33 AM
Hi,
Put a (empty) datagrid component in parent file also.
In flash you need to put the same compoent whether its used or unused in the parent swf file to get displayed the child swf's components.

regards,
Suresh K.

melzee
07-03-2009, 12:15 AM
Hi,

Thanks for responding. I have tried your solution, however it didn't work.

I put a data grid component into the main time line, but still nothing is appearing the loaded swf's datagrid.

If I preview the swf separately the data is there, but as soon as it is loaded into the partent the data disappears.

Any other ideas?

Thanks...

Melzee

melzee
07-03-2009, 05:35 AM
I am able to get this datagrid to work in other scenarios (loaded into a parent swf), however in this scenario the problem seems to be related to the menu system I am using.

The menu is populated from another external XML and when a button is clicked it calls a function to load the swf containing the datagrid into the parent swf. The URL for the swf to be loaded is accessed from the menu.xml.


I have tried tracing the XML. And it is being read into the var my XML, but no luck getting it into the datagrid!


import fl.controls.dataGridClasses.DataGridColumn;
import fl.data.DataProvider;
import fl.containers.UILoader;
import fl.data.DataProvider;
import fl.events.*;
import flash.xml.*;


var myXML:XML;
var myList:XMLList;



function parseXML():void
{


var url:String = "content.xml"; // Your XML file name here
var urlRequest:URLRequest = new URLRequest(url);
var loader2:URLLoader = new URLLoader();
loader2.addEventListener("complete" , loadXML);
loader2.load(urlRequest);
}


parseXML();


function loadXML(evt:Event):void
{
myXML = new XML(evt.target.data);
trace (myXML)


myDP = new DataProvider(myXML);


myData.dataProvider = myDP;


// DataGrid Columns defined here
var dateCol:DataGridColumn = new DataGridColumn("columns");
dateCol.headerText = "COLUMNS";
dateCol.width = 65;


var codeCol:DataGridColumn = new DataGridColumn("picas");
codeCol.headerText = "PICAS/POINTS";
codeCol.width = 90;


var campaignCol:DataGridColumn = new DataGridColumn("millimetres");
campaignCol.headerText = "MILLIMETRES";
campaignCol.width = 300;


var myDP:DataProvider;
myData.columns = [dateCol, codeCol, campaignCol]; // DataGrid column Array
myData.width = 440;
myData.dataProvider = myDP;
myData.rowCount = myData.length;


}