starev1l
07-13-2004, 01:48 AM
What I'm trying to achieve is to replicate Sajid Saiyed's Tutorial on FMX 2004 Pro + PHP + MySQL (http://www.macromedia.com/devnet/mx/flash/articles/flash_xmlphp.html) with a little twist while trying out the scrollPane component.
With reference to Step 2 of the .fla (http://www.macromedia.com/devnet/mx/flash/articles/flash_xmlphp_05.html), I'm trying to change the DataGrid to attach an instance of a movieClip from the library with label placeholders to a scrollPane dynamically and should I "click on" another cell of the dataGrid, another instance will be added to the scrollPane.
And because this is a nested screen (FMX 2004 Pro), I'm referencing using _parent.
_PARENT
|--- mcItemNo (mc) : the following code is the one doing the job of dynamically adding to the mcDetails which contains the scrollPane component)
|--- mcDetails (mc) : containing scrollPane named "spDetails", content is set to "mcItemDetailWrapper" which is a blank mc I have in my library)
|--- mcItemDetail (mc) I am populating the scrollpane with many instances of the "mcItemDetail" mc.
MY PROBLEM:
Everything worked fine up till "//Filling the labels with data" in the code. It seems that I have reference/target wrongly but I just can't seem to work it out. The label text are not taking in the data from dsDetail:dataSet.
I've tried placing an instance of mcItemDetail on stage and tweaking the reference/target and it works FINE, BUT once it gets nested in a dynamically attached movieClip which contains a scrollPane, it's way out of my "level" ;) .
So can some kind soul help to look through this and tell me what's wrong?
dgDescription.vScrollPolicy = "auto";
dgListener = new Object();
//function when selecting items in DataGrid
var i:Number = 0
trace("Cell pressed " + i + " time.");
dgListener.cellPress = function(evt){
if(evt.target==dgDescription){
var nr:Number = evt.itemIndex
var st:String = evt.target.selectedIndex
i++;
trace("Here goes " + i);
trace("Content Path is" + _parent.mcDetails.spDetails.contentPath);
// Attach movie
_parent.mcDetails.spDetails.content.attachMovie("mcItemDetail", "mcItemDetail" +i, i);
// Tracing what's happening when cell is clicked
trace("Content inside ScrollPane " + _parent.mcDetails.spDetails.content);
trace("Content created in " + _parent.mcDetails.spDetails.content["mcItemDetail" + i]);
// Aligning mcItemDetail inside spDetails:ScrollPane
_parent.mcDetails.spDetails.content["mcItemDetail" + i]._x = 0;
_parent.mcDetails.spDetails.content["mcItemDetail" + i]._y = _parent.mcDetails.spDetails.content["mcItemDetail" + (i-1)]._y + _parent.mcDetails.spDetails.content["mcItemDetail" + (i-1)]._height;
// Filling the labels with data
_parent.mcDetails.spDetails.content["mcItemDetail" + i].lblItemNo.text = dsDetail.items[st].ItemNo;
_parent.mcDetails.spDetails.content["mcItemDetail" + i].lblRate.text = dsDetail.items[st].Rate;
_parent.mcDetails.spDetails.content["mcItemDetail" + i].lblUnit.text = dsDetail.items[st].Unit;
_parent.mcDetails.spDetails.content["mcItemDetail" + i].taDescription.text = dsDetail.items[st].Description;
// Refreshing spDetails to reflect the change
_parent.mcDetails.spDetails.invalidate();
this.updateData(0)
}
}
//Setup which event to listen
dgDescription.addEventListener("cellPress", dgListener); //Press on datagrid
stop();
With reference to Step 2 of the .fla (http://www.macromedia.com/devnet/mx/flash/articles/flash_xmlphp_05.html), I'm trying to change the DataGrid to attach an instance of a movieClip from the library with label placeholders to a scrollPane dynamically and should I "click on" another cell of the dataGrid, another instance will be added to the scrollPane.
And because this is a nested screen (FMX 2004 Pro), I'm referencing using _parent.
_PARENT
|--- mcItemNo (mc) : the following code is the one doing the job of dynamically adding to the mcDetails which contains the scrollPane component)
|--- mcDetails (mc) : containing scrollPane named "spDetails", content is set to "mcItemDetailWrapper" which is a blank mc I have in my library)
|--- mcItemDetail (mc) I am populating the scrollpane with many instances of the "mcItemDetail" mc.
MY PROBLEM:
Everything worked fine up till "//Filling the labels with data" in the code. It seems that I have reference/target wrongly but I just can't seem to work it out. The label text are not taking in the data from dsDetail:dataSet.
I've tried placing an instance of mcItemDetail on stage and tweaking the reference/target and it works FINE, BUT once it gets nested in a dynamically attached movieClip which contains a scrollPane, it's way out of my "level" ;) .
So can some kind soul help to look through this and tell me what's wrong?
dgDescription.vScrollPolicy = "auto";
dgListener = new Object();
//function when selecting items in DataGrid
var i:Number = 0
trace("Cell pressed " + i + " time.");
dgListener.cellPress = function(evt){
if(evt.target==dgDescription){
var nr:Number = evt.itemIndex
var st:String = evt.target.selectedIndex
i++;
trace("Here goes " + i);
trace("Content Path is" + _parent.mcDetails.spDetails.contentPath);
// Attach movie
_parent.mcDetails.spDetails.content.attachMovie("mcItemDetail", "mcItemDetail" +i, i);
// Tracing what's happening when cell is clicked
trace("Content inside ScrollPane " + _parent.mcDetails.spDetails.content);
trace("Content created in " + _parent.mcDetails.spDetails.content["mcItemDetail" + i]);
// Aligning mcItemDetail inside spDetails:ScrollPane
_parent.mcDetails.spDetails.content["mcItemDetail" + i]._x = 0;
_parent.mcDetails.spDetails.content["mcItemDetail" + i]._y = _parent.mcDetails.spDetails.content["mcItemDetail" + (i-1)]._y + _parent.mcDetails.spDetails.content["mcItemDetail" + (i-1)]._height;
// Filling the labels with data
_parent.mcDetails.spDetails.content["mcItemDetail" + i].lblItemNo.text = dsDetail.items[st].ItemNo;
_parent.mcDetails.spDetails.content["mcItemDetail" + i].lblRate.text = dsDetail.items[st].Rate;
_parent.mcDetails.spDetails.content["mcItemDetail" + i].lblUnit.text = dsDetail.items[st].Unit;
_parent.mcDetails.spDetails.content["mcItemDetail" + i].taDescription.text = dsDetail.items[st].Description;
// Refreshing spDetails to reflect the change
_parent.mcDetails.spDetails.invalidate();
this.updateData(0)
}
}
//Setup which event to listen
dgDescription.addEventListener("cellPress", dgListener); //Press on datagrid
stop();