Loader?



  • I'm trying to do this seemingly simple program:

    package;

    import flixel.FlxG;
    import flixel.FlxSprite;
    import flixel.FlxState;
    import flixel.text.FlxText;
    import flixel.ui.FlxButton;
    import flixel.math.FlxMath;

    //with your imports
    import nme.net.URLLoader;
    import nme.net.URLRequest;

    class MenuState extends FlxState
    {

    //later on

    public var myLoader:URLLoader;

    override public function create():Void
    {
    super.create();
    //http://www.newgrounds.com/dump/item/f62b9334350d2718bdc5917a0f84ea05/letters.txt

    //make a new loader
    myLoader = new URLloader();
    //new request - for a file in the same folder called 'someTextFile.txt'
    var myRequest:URLRequest = new URLRequest("http://www.newgrounds.com/dump/item/f62b9334350d2718bdc5917a0f84ea05/someTextFile.txt");
    
    //wait for the load
    myLoader.addEventListener(Event.COMPLETE, onLoadComplete)
    
    //load!
    myLoader.load(myRequest);   
    

    }

    function onLoadComplete(e:Event):Void
    {
    trace(myLoader.data);
    }

    override public function update(elapsed:Float):Void
    {
    super.update(elapsed);
    }

    }

    And I am getting the following error:

    source/MenuState.hx:42: lines 42-45 : Type not found : Event
    source/MenuState.hx:29: characters 13-28 : Type not found : URLloader

    source/Main.hx:9: lines 9-16 : Defined in this class

    Anyone have any experience or know how to use this with haxeflixel?

    Posted this in the wrong forum.



  • I import flash.net.URLLoader; instead of nme.... and it works for me...worth a try? As for Event you probably want to import openfl.events.Event;.



  • Also in HaxeDevelop you can press Ctrl+Shift+1 when cursor is at unknown type to add import line. Saves a lot of time!



  • @IBwWG When you say "works for me" does the text change or does it not throw errors?



  • @xhunterko Sorry I mean in my project context, using that import both compiles properly (the errors you asked about) and loads data from the URL I specify. I didn't try changing the code you posted.


Log in to reply
 

Looks like your connection to HaxeFlixel was lost, please wait while we try to reconnect.