# Scope in object class file using LoadVars - help

**URL:** <https://forum.kirupa.com/t/scope-in-object-class-file-using-loadvars-help/155323>\
**Category:** Uncategorized\
**Created:** [July 16, 2005, 9:57am UTC](https://forum.kirupa.com/t/scope-in-object-class-file-using-loadvars-help/155323 "2005-07-16T09:57:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![whitespirit](https://avatars.discourse-cdn.com/v4/letter/w/b782af/32.png) [@whitespirit](https://forum.kirupa.com/u/whitespirit)\
**Post date:** [July 16, 2005, 9:57am UTC](https://forum.kirupa.com/t/scope-in-object-class-file-using-loadvars-help/155323/1 "2005-07-16T09:57:27Z")

</div>

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:

```auto
 
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…

```auto

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…

```auto
 
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…
