MattyJim
04-02-2008, 11:59 PM
Hello!
I'm new to actionscript (I'm using AS3, by the way), so please forgive me if I get my terminology mixed up:
I have a couple of textfields name "txtTest0" and "txtTest1" on the stage.
I'm using the following code to read delimited values from a .php script and into an array, which I then pass into an AS3 class (custData.graph)
import custData.graph;
//Create the URLLoader instance
var myLoader:URLLoader = new URLLoader();
//the data will come as URL-encoded variables
myLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
//Load using an URLRequest, even beeing local
myLoader.load(new URLRequest("http://localhost:81/mattyjim_proj/ajax_script.php"));
//onLoad handler listener
myLoader.addEventListener(Event.COMPLETE, onDataLoad);
//add a listener for the complete event
function onDataLoad(evt:Event)
{
var arrData:Array = new Array();
for(var i:uint=0; i<2; i++)
{
arrData.push(evt.target.data["xxx"+i]);
}
var Graph:graph = new graph();
Graph.newsData = arrData;
//pass a reference to the stage
Graph.stageRef = this.stage;
Graph.init();
}
My graph class is as follows:
package custData
{
public class graph
{
private var m_stageRef:Object = new Object;
private var m_arrNews:Array = new Array();
public function set newsData(value):void
{
m_arrNews = value;
}
public function set stageRef(value):void
{
m_stageRef = value;
}
public function init():void
{
//trace(m_arrNews[0]);
m_stageRef["txtTest0"].htmlText = m_arrNews[0];
}
}
}
Passing the array into the class works just fine. If I do...
trace(m_arrNews[0]);
...then I get exactly the value that I'm expecting.
However, the line...
m_stageRef["txtTest0"].htmlText = m_arrNews[0];
..throws an error "Error #1069: Property txtTest0 not found on flash.display.Stage and there is no default value"
I want to write the array values into my text fields, but I don't seem to be able to access objects that are on the stage properly.
Does anybody have any idea where I might be going wrong with this?
Any help would be greatly appreciated.
Thanks :)
I'm new to actionscript (I'm using AS3, by the way), so please forgive me if I get my terminology mixed up:
I have a couple of textfields name "txtTest0" and "txtTest1" on the stage.
I'm using the following code to read delimited values from a .php script and into an array, which I then pass into an AS3 class (custData.graph)
import custData.graph;
//Create the URLLoader instance
var myLoader:URLLoader = new URLLoader();
//the data will come as URL-encoded variables
myLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
//Load using an URLRequest, even beeing local
myLoader.load(new URLRequest("http://localhost:81/mattyjim_proj/ajax_script.php"));
//onLoad handler listener
myLoader.addEventListener(Event.COMPLETE, onDataLoad);
//add a listener for the complete event
function onDataLoad(evt:Event)
{
var arrData:Array = new Array();
for(var i:uint=0; i<2; i++)
{
arrData.push(evt.target.data["xxx"+i]);
}
var Graph:graph = new graph();
Graph.newsData = arrData;
//pass a reference to the stage
Graph.stageRef = this.stage;
Graph.init();
}
My graph class is as follows:
package custData
{
public class graph
{
private var m_stageRef:Object = new Object;
private var m_arrNews:Array = new Array();
public function set newsData(value):void
{
m_arrNews = value;
}
public function set stageRef(value):void
{
m_stageRef = value;
}
public function init():void
{
//trace(m_arrNews[0]);
m_stageRef["txtTest0"].htmlText = m_arrNews[0];
}
}
}
Passing the array into the class works just fine. If I do...
trace(m_arrNews[0]);
...then I get exactly the value that I'm expecting.
However, the line...
m_stageRef["txtTest0"].htmlText = m_arrNews[0];
..throws an error "Error #1069: Property txtTest0 not found on flash.display.Stage and there is no default value"
I want to write the array values into my text fields, but I don't seem to be able to access objects that are on the stage properly.
Does anybody have any idea where I might be going wrong with this?
Any help would be greatly appreciated.
Thanks :)