I'm trying to load data from a website in my AS3 program. However, urlLoader.load() never finishes, yet the program runs without any errors.
Here's my code:
Main.as:
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLLoaderDataFormat;
import flash.net.URLRequest;
import flash.net.URLRequestMethod;
import ttTextField;
public class Main extends Sprite
{
private var textField:ttTextField = new ttTextField("", false);
public function Main():void
{
var urlRequest:URLRequest = new URLRequest("http://itch.io/api/1/API_KEY_REMOVED_FOR_SECURITY/my-games");
urlRequest.method = URLRequestMethod.GET;
var urlLoader:URLLoader = new URLLoader();
urlLoader.dataFormat = URLLoaderDataFormat.TEXT;
urlLoader.addEventListener(Event.COMPLETE, completeHandler);
urlLoader.load(urlRequest);
stage.addChild(textField);
}
private function completeHandler(event:Event):void
{
textField.text = event.target.data;
}
}
ttTextField.as:
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormatAlign;
import flash.text.TextFormat;
public class ttTextField extends TextField
{
[Embed(source = "../files/Fixedsys500c.ttf", embedAsCFF = "false", fontName = "fixedSys")] private var fontClass:Class;
private var textFormat:TextFormat = new TextFormat("fixedSys", 24);
public function ttTextField(string:String, centered:Boolean)
{
if (centered)
{
textFormat.align = TextFormatAlign.CENTER;
}
else
{
textFormat.align = TextFormatAlign.LEFT;
}
string = string;
this.autoSize = TextFieldAutoSize.LEFT;
this.mouseEnabled = false;
this.embedFonts = true;
this.textColor = 0xFFFFFF;
this.defaultTextFormat = textFormat;
this.text = string;
}
}
ttTextField can display regular strings, so it doesn't seem like this class is the issue. I just included it for completion's sake.
I'm also building and running using Sublime Text 2. My sublime-build file is as follows:
{
"cmd": ["C:\\Users\\Dan\\Documents\\flex_sdk_4.6\\bin\\mxmlc.exe", "-output=C:\\Users\\Dan\\TTTT\\TTTT.swf", "-default-background-color=#00FF00", "-default-size=800,600", "C:\\Users\\Dan\\TTTT\\src\\Main.as", "-static-link-runtime-shared-libraries=true"],
"file_regex": "(.*)[(](\\d+)[)]:(?: col: (?:\\d+))? *Error: (.*)",
"selector": "source.actionscript",
"variants":
[
{
"name": "Run",
"shell": true,
"cmd": ["C:\\Users\\Dan\\TTTT\\TTTT.swf"]
}
]
}
I've tried running the program in both Flash Player and Google Chrome. Every time the output is just a blank screen.
How would I get my URLLoader to actually load the URL? I can provide more information if needed. Thank you for reading.