Friday, April 20, 2012

AS3: Function and variables

What i am basically looking to do is change the name of the outputted instance.



But the problem i have is how to send variables passed thought the function 'find_name' to the 'Event.Complete' function loadNameInfo?



Code Below:



    // Finds a persons name using the ID
private function find_name(page_Name='search.php',instance_name='name',get1='g1=1',get2='g2=2',get3='g3=3'):void
{
var randomParam:String = "?p=" + Math.floor(Math.random() * (10000000));
var create_URL = (URL + page_Name + randomParam + '&'+ get1 + '&' + get2 + '&' + get3);
_loader = new URLLoader();
_request = new URLRequest(create_URL);
_request.method = URLRequestMethod.POST;
_loader.addEventListener(Event.COMPLETE, loadNameInfo);
_loader.load(_request);
}
// Loads the name into the correct place
public function loadNameInfo(e:Event)
{
instance_name.text = e.target.data;
}


Is this kinda thing possible?



Eli





No comments:

Post a Comment