Hey, I’m really new to AS3. This is a simple problem to solve but I just can’t seem to figure it out or find the answer to it. I’m still trying to wrap my head around OOP.
Here’s my code:
package
{
import flash.display.*;
import flash.net.*;
import flash.events.*;
public class pixel extends Sprite
{
public function pixel()
{
myTextField.text = getEntry("pages.page[1].pageName");
}
private dynamic function getEntry(req:String):String
{
var request:URLRequest = new URLRequest("getXML.php?q=" + req); //queries my PHP file for data using the string (works)
var myEntry:URLLoader = new URLLoader();
myEntry.addEventListener(Event.COMPLETE, loadedMyEntry);
myEntry.load(request);
function loadedMyEntry(event:Event):String
{
var loader2:URLLoader = URLLoader(event.target);
return loader2.data;//how the heck do i get it out of here into myTextField or any other thing I want to use it for?
}
}
}
}
Hopefully you can see that I’m trying to write a function that pulls data from a PHP file using a string for an argument, and I want that same function to return the results so that I can assign it to whatever I want. Can someone help me understand how to accomplish this with AC3/OOP? Thanks so much!