haXe Forum > n00b Q re: flash library assets

  • Hi everyone, new to the forums although I've tinkered with HaXe a couple of years ago. I'm picking it up again now.

    I'm proficient in using Flash but I'm trying out a fairly basic Flash test with HaXe and I'm not understanding how complex I can make my library assets.

    I'm using the Adobe Flash CS4 IDE and targeting AS3 / FP10. I made a MovieClip with a rectangular vector shape and it has a class name of "SampleButton" and created a resource.swf

    In FlashDevelop, I have:

    var s = flash.Lib.attach("SampleButton");
    flash.Lib.current.addChild(s);

    Cool. That works.

    But once I start adding stuff like TextFields in the IDE, or even making a Tweened animation, I get this error:

    Error: Error #2136: The SWF file file:///C|/Workspace/Haxe/Tests/FlashTest/bin/Test.swf contains invalid data.
        at flash::Lib$/attach()[C:\Program Files\Motion-Twin\haxe/std/flash9/Lib.hx:73]
        at ca.klab.haxe.test::Main$/main()[C:\Workspace\Haxe\Tests\FlashTest\src/ca/klab/haxe/test/Main.hx:37]
        at MethodInfo-62()[<null>:1]
        at flash::Boot()[C:\Program Files\Motion-Twin\haxe/std/flash9/Boot.hx:86]

    What limitations do these library assets have??? Can it only be 1 frame and simple vector shapes?

    Didn't find an answer in the regular docs so some clarification is needed. Thanks so much.

  • I think about as complex as you like you will need to make stub files if you using classes and make sure you create instances so that haXe can find them and sometimes you have to tweak the stub class by hand.
    using as3 classes
    But I tend to load a flash IDE movie in at runtime as often the graphics are heavier and it allows separate compilation, I try not to include any code in the flashIDE and only base classes, I explain my workflow here...
    compositeflashgraphicswithhaxe
    I use the same process on as3 sites and haXe sites and it seems to work. If I am testing some code I may just use a bit of code to draw a button and keep it all in one haXe class or code something in flashIDE and move it to haXe after.
    I think it's a bit tricky to create streaming timeline loaders ( not really tried ) so it can makes sense to code a preloader as as3 timeline code in frames without classes that loads you main haxe code movie, it gets more tricky passing the assets and graphics, xml, swf loading information up.
    You can get into swfmill but if you know flashIDE and you want designers to be able to manually tweak pixels, it can make a lot of sense to use flashIDE for layout, whether you use haXe or as3 is somewhat irrelevant, clients prefer as3 because they trust it, I prefer haXe because code is less tied to flash player.
    But I do find textfields a pain in flashIDE and I am wondering over the advantage of using flash for layout really haXe community needs to create another tool and just keep flash for complex shape tweens, I normally find coded tweens allow more interaction, but scale9grid is easier with flashIDE.

  • I am not sure what the problem is with the example you have but if you upload the fla and all the code somewhere so its really easy to test I am sure someone can take a quick look, loading at runtime is likely to be less problematic though.

  • Hi Justin,

    I think I had a false positive. The movieclip that I was seeing was the one already on the stage.

    I'm going to go through these tutorials again (thanks for the links) and see what I missed!

    Thanks.

  • If you need some code for a basic setup with xml and fla and haXe let me know I can't promise it will be best solution but it works for me.

< Prev | Page 1 / 1 | Next >