Haxe Forum > Flash Loader

  • I apologize if this has been asked before in another thread.

    I've made a UI using AsWing and I wish to show the flash file natively. How can I do that using haXe? I tried the following code, but it generates an error: "Main.hx:2: characters 0-28 : You can't access the flash package with current compilation flags (for flash.display.Loader)"

    import cpp.Lib;
    import flash.display.Loader;
    import flash.net.URLRequest;
    
    class Main
    {
        public static function main()
        {
            var loader:URLLoader = new URLLoader();
            var request:URLRequest = new URLRequest("Hello.swf");
            loader.dataFormat = URLLoaderDataFormat.BINARY;
            loader.addEventListener(Event.COMPLETE, onLoad);
            loader.load(request); 
        }
    }
  • Hi if you look at the API you will notice there are sections specific for each target language.

    http://haxe.org/api

    So when you target flash you have to make sure all the imports are flash imports and that you setup the project for flash.

    So this import

    import cpp.Lib;

    needs to be changed to
    import flash.Lib;

    You need to setup the haxe project for compiling to flash.
    http://haxe.org/doc/start/flash

    In terms of loading a movie at runtime, I found some of my old code here...

    http://lists.motion-twin.com/pipermail/haxe/2011-September/048173.html

    But maybe I can come back and post something more relevant if your still having problems, it's late here so should probably read more carefully to check if this link is useful for your needs and if not post something simpler. So will revisit thread if you don't get anywhere sometime tomorrow, but I will wait for you to explore given the new information, so just let us know how you get on. Good luck ;j

  • By the way just rereading your question and I realise I may have missunderstood... if your wanting to use NME to remap the flash to desktop cpp or neko then take a look through http://www.haxenme.org tutorials, basically you need to add --remap flash:nme or manually change all flash imports to nme ( but unsure on loading a swf into NME ) to target desktop, but you have to have NME setup properly so best to visit the site dedicated to it. Another alternative to NME is to use AIR3 Jan can cover that if it is your requirement? Sorry if I am providing lots of information just not sure exactly what your requiring.

  • I apologize Justin if I didn't make myself clear. I was tired when I wrote the question. What I wanted was a way to create a cpp binary that would load a swf file when launched. I have NME installed because I had some issues when targeting cpp using haXe.

  • OK. So I've decided to use PHP-GTK to enable me to write stand-alone applications, however I would also like to use haXe as the programming language hence why I am writing here. How would I translate PHP code into haXe code given this simple example:

    <?php
        $window = new GtkWindow();
        $window->connect_object('destroy', array('gtk', 'main_quit'));
        $window->show();
        gtk::main();
    ?>

    I'm assuming I wouldn't have to add the PHP tags, but not sure how to pass $ variables and so on.

  • I'm sorry if this is going off topic, but I think what would be great is having perhaps PHP-GTK support in haXe out of the box. Even going as far as compiling for Window, Mac OS and Linux. Has anyone been looking at this? I've spent the best part of this morning just getting PHP-GTK working in Linux as I couldn't find any pre-built libraries. If you're using Ubuntu 12.04 you might want to read this post: http://ncloy.co.uk/blog/?p=86

  • Wow that sounds kind of tricky you probably really need to use the haxelang google group, I have not heard of the PHP target used like that before, you don't have to use NME there are some other alternatives that might be simpler than this approach, for instance there are some tutorials on http://code.google.com/p/waxe/ and there is also hxopenframeworks, but...

    It maybe easier to stick with NME it's very powerful just sometimes takes some setup. First I would try following through with the tutorial to check it's all setup...
    http://haxe.org/doc/start/cpp

    and get back to us if that stage works ok. Or try the haxelang group if you really want to do this php thing, the link is in forum FAQ's at top.

  • Seems like the answer was staring at me in the face. Doh!

< Prev | Page 1 / 1 | Next >