PDA

View Full Version : createEmptyMovieClip, XML, scope


trcoffey
10-29-2005, 01:11 AM
Alright. this works but I can't stand using root. I've tried targeting an mc on the stage and createEmptyMovieClip and neither work. I think I'm screing up the variable scope or something. I'm always screwing up my variables...Please help, and thanks much.

import mx.xpath.XPathAPI;

var toDoList:XML = new XML();
toDoList.ignoreWhite = true;
toDoList.onLoad = function(success:Boolean) {
if (success) {
// Retrieve all titles in the path /rss/channel/item/title.
var messages:Array = this.firstChild.childNodes;
var due:Array = XPathAPI.selectNodeList(this.firstChild, "/todolist/message/due");
var type:Array = XPathAPI.selectNodeList(this.firstChild, "/todolist/message/type");
var regarding:Array = XPathAPI.selectNodeList(this.firstChild, "/todolist/message/regarding");
var priority:Array = XPathAPI.selectNodeList(this.firstChild, "/todolist/message/priority");
var summary:Array = XPathAPI.selectNodeList(this.firstChild, "/todolist/message/details/summary");
var author:Array = XPathAPI.selectNodeList(this.firstChild, "/todolist/message/details/author");
var functionCall:Array = XPathAPI.selectNodeList(this.firstChild, "/todolist/message/functionCall");
var leading:Number = 2;

/*
this block works attaching Movie Clip Row
but I need to have clickable area that can reference this todoList:XML.
Attempts to use buttons ref row[i]._name returned null so I am goint
to try a createEmptyMovieClip version of the same as below
*/

/*
for (var i:Number = 0; i < messages.length; i++) {
_root.attachMovie("toDoList_Row" , "row" + i , i );
_root["row" + i]._x = 0;
_root["row" + i]._y = i * 30;
_root["row" + i].due_txt.text = due[i].firstChild.nodeValue;
_root["row" + i].typ_txt.text = type[i].firstChild.nodeValue;
_root["row" + i].reg_txt.text = regarding[i].firstChild.nodeValue;
trace(priority[i].firstChild.nodeValue);

if(priority[i].firstChild.nodeValue == "Urgent"){
_root["row" + i].due_txt.setTextFormat(_root.uu);
_root["row" + i].typ_txt.setTextFormat(_root.uu);
_root["row" + i].reg_txt.setTextFormat(_root.uu);
}else if(priority[i].firstChild.nodeValue != "Urgent"){
_root["row" + i].due_txt.setTextFormat(_root.r);
_root["row" + i].typ_txt.setTextFormat(_root.r);
_root["row" + i].reg_txt.setTextFormat(_root.r);
}
*/

// /*




for (var i:Number = 0; i < messages.length; i++) {


// Creating three movie clips "due" "type" and "regarding" and text boxes therein to build our table
_root.createEmptyMovieClip("due" + i , getNextHighestDepth() );
_root["due" + i].onRelease = function(){
trace(this._name + " was Pushed, Yeehaaaaw!!");
};
_root["due" + i]._x = 0;
_root["due" + i]._y = i * 30;
_root["due" + i].createTextField("txt", i, 0, i*leading, 75, 20);
_root["due" + i].txt.text = due[i].firstChild.nodeValue;
_root["due" + i].txt.embedFonts = true;


_root.createEmptyMovieClip("type" + i , getNextHighestDepth() );
_root["type" + i].onRelease = function(){
trace(this._name + " was Pushed, Yeehaaaaw!!");
};
_root["type" + i]._x = 0;
_root["type" + i]._y = i * 30;
_root["type" + i].createTextField("txt", i, 75, i*leading, 200, 20);
_root["type" + i].txt.text = type[i].firstChild.nodeValue;
_root["type" + i].txt.embedFonts = true;

_root.createEmptyMovieClip("regarding" + i , getNextHighestDepth() );
_root["regarding" + i].onRelease = function(){
trace(this._name + " was Pushed, Yeehaaaaw!!");
};
_root["regarding" + i]._x = 0;
_root["regarding" + i]._y = i * 30;
_root["regarding" + i].createTextField("txt", i, 285, i*leading, 200, 20);
_root["regarding" + i].txt.text = regarding[i].firstChild.nodeValue;
_root["regarding" + i].txt.embedFonts = true;

//Application rules for text fomrmatting
if(priority[i].firstChild.nodeValue == "Urgent"){
_root["due" + i].txt.setTextFormat(uu);
_root["type" + i].txt.setTextFormat(uu);
_root["regarding" + i].txt.setTextFormat(uu);
}else if(priority[i].firstChild.nodeValue != "Urgent"){
_root["due" + i].txt.setTextFormat(r);
_root["type" + i].txt.setTextFormat(r);
_root["regarding" + i].txt.setTextFormat(r);
}

// */


/*
trace(messages.length);
trace(due[i].firstChild.nodeValue);
trace(type[i].firstChild.nodeValue);
trace(regarding[i].firstChild.nodeValue);
trace(priority[i].firstChild.nodeValue);
trace(summary[i].firstChild.nodeValue);
trace(author[i].firstChild.nodeValue);
trace(functionCall[i].firstChild.nodeValue);
//trace(linkArray[i].firstChild.nodeValue);

*/

}
} else {
trace("XML loading failed !!!");
}
};



toDoList.load("todolist.xml");


Here's the xml:

<?xml version="1.0" encoding="UTF-8"?>
<todolist>
<message>
<due>Today</due>
<type id="HelloShitHead">(C) Patient: ER/Hospitalization</type>
<regarding>Michele Wade</regarding>
<priority>Urgent</priority>
<details>
<summary>ER/ Hospitalization Details: Summary goes here. This is a more detailed fview of the information relative to this node.</summary>
<author>Author</author>
</details>
<functionCall>testFunction</functionCall>
</message>
<message>
<due>Today</due>
<type>(C) Referral: Transportation</type>
<regarding>Chris Travis</regarding>
<priority>Normal</priority>
<details>
<summary>Referral: Transportation Details: Summary goes here. This is a more detailed fview of the information relative to this node.</summary>
<author>Author</author>
</details>
<functionCall>testFunction2</functionCall>
</message>
<message>
<due>11/02/2005</due>
<type>Admin: Weekly Physician Report</type>
<regarding>null</regarding>
<priority>low</priority>
<details>
<summary>Admin: Weekly Physician Report Details: Summary goes here. This is a more detailed fview of the information relative to this node.</summary>
<author>Author</author>
</details>
<functionCall>testFunction3</functionCall>
</message>
<message>
<due>Today</due>
<type>(C) Patient: ER/Hospitalization</type>
<regarding>Michele Wade</regarding>
<priority>Urgent</priority>
<details>
<summary>ER/ Hospitalization Details: Summary goes here. This is a more detailed fview of the information relative to this node.</summary>
<author>Author</author>
</details>
<functionCall>testFunction</functionCall>
</message>
<message>
<due>Today</due>
<type>(C) Referral: Transportation</type>
<regarding>Chris Travis</regarding>
<priority>Normal</priority>
<details>
<summary>Referral: Transportation Details: Summary goes here. This is a more detailed fview of the information relative to this node.</summary>
<author>Author</author>
</details>
<functionCall>testFunction2</functionCall>
</message>
<message>
<due>11/02/2005</due>
<type>Admin: Weekly Physician Report</type>
<regarding>null</regarding>
<priority>low</priority>
<details>
<summary>Admin: Weekly Physician Report Details: Summary goes here. This is a more detailed fview of the information relative to this node.</summary>
<author>Author</author>
</details>
<functionCall>testFunction3</functionCall>
</message>
<message>
<due>Today</due>
<type>(C) Patient: ER/Hospitalization</type>
<regarding>Michele Wade</regarding>
<priority>Urgent</priority>
<details>
<summary>ER/ Hospitalization Details: Summary goes here. This is a more detailed fview of the information relative to this node.</summary>
<author>Author</author>
</details>
<functionCall>testFunction</functionCall>
</message>
<message>
<due>Today</due>
<type>(C) Referral: Transportation</type>
<regarding>Chris Travis</regarding>
<priority>Normal</priority>
<details>
<summary>Referral: Transportation Details: Summary goes here. This is a more detailed fview of the information relative to this node.</summary>
<author>Author</author>
</details>
<functionCall>testFunction2</functionCall>
</message>
<message>
<due>11/02/2005</due>
<type>Admin: Weekly Physician Report</type>
<regarding>null</regarding>
<priority>low</priority>
<details>
<summary>Admin: Weekly Physician Report Details: Summary goes here. This is a more detailed fview of the information relative to this node.</summary>
<author>Author</author>
</details>
<functionCall>testFunction3</functionCall>
</message>
<message>
<due>Today</due>
<type>(C) Patient: ER/Hospitalization</type>
<regarding>Michele Wade</regarding>
<priority>Urgent</priority>
<details>
<summary>ER/ Hospitalization Details: Summary goes here. This is a more detailed fview of the information relative to this node.</summary>
<author>Author</author>
</details>
<functionCall>testFunction</functionCall>
</message>
<message>
<due>Today</due>
<type>(C) Referral: Transportation</type>
<regarding>Chris Travis</regarding>
<priority>Normal</priority>
<details>
<summary>Referral: Transportation Details: Summary goes here. This is a more detailed fview of the information relative to this node.</summary>
<author>Author</author>
</details>
<functionCall>testFunction2</functionCall>
</message>
<message>
<due>11/02/2005</due>
<type>Admin: Weekly Physician Report</type>
<regarding>null</regarding>
<priority>low</priority>
<details>
<summary>Admin: Weekly Physician Report Details: Summary goes here. This is a more detailed fview of the information relative to this node.</summary>
<author>Author</author>
</details>
<functionCall>testFunction3</functionCall>
</message>
</todolist>

hangalot
11-04-2005, 02:27 PM
if you have scope issues look at mx.utils.Delegate

trcoffey
11-19-2005, 12:26 AM
excellent! Thank you.