Hi guys,
please help, i’m pulling my hair out!!;( i can’t seem to get my head around scopes within a class file i’ve tried to create…
the aim of the class file is to go and retrieve a news article form a mysql database and store data such as “headline” and “textBody” etc in it so that i can then display it in a dynamic text box later in the movie file.
here is the code on the flash file creating the flash:
import as.*
trace("step 1");
var testING:newsArticle = new newsArticle(3);
trace ("step 2");
trace ("head = "+testING.headLine + " &id = "+testING.aID);
here is the actual class file newsArticle.as…
import mx.utils.Delegate;
class as.newsArticle {
var aID:Number;
var table:String = "sales_headlines";
var returnPage;
var graphic:String = "";
var headLine:String;
var bodyText:String = "";
var mainText:String = "";
var catID:Number = 0;
var displayAsNews:Number = 0;
var articleDate;
var $loader:LoadVars;
var $url:String = "[http://www.xyz.com/flash/getdata.php](http://www.xyz.com/flash/getdata.php)";
var thisObj;
function newsArticle($id) {
//----------------------------------------------
// article is being created so go to the
// database and get all the details
//----------------------------------------------
aID = $id;
var thisObj:newsArticle;
_global.thisObj = this;
init();
execute();
trace ("sweet "+headLine);
} // end of constructor
function init () : Void {
$loader = new LoadVars();
$loader.onLoad = Delegate.create (this, onLoad2);
}
function execute () : Void {
$loader.load($url);
}
function onLoad2 (success:Boolean) : Void {
if(success) {
_global.thisObj.headLine = $loader.headline0;
trace ("ok ----- "+headLine);
} else {
trace ("bad !");
}
}
} // end of class file
and finally here is the trace output…
step 1
sweet undefined
step 2
head = undefined &id = 3
ok ----- The world's first 100Mbps Hotel Internet Pipe
Please can anyone advice on what the heck i’m doing wrong??? I want to be able to call “testING.headLine” anywhere in my movie file… how do i make it a global object? and how do i populate the class variables so they can be accessed from the .fla file… the aID works but not the headLine arrghhh!
Thanks in advance for any advice…