Can´t get swf embedding to work

164 views
Skip to first unread message

Lazer Starr

unread,
Feb 6, 2015, 12:23:07 PM2/6/15
to fla...@googlegroups.com
Hello,

i downloaded this branch of flambe to be able to pack the assets into the swf: 

As described here it should work: https://github.com/aduros/flambe/pull/267

BUT ... nothing really happens.
I added "embed_assets: true" to my yaml file, but it´s being totally ignored.

I tested it where it should do something in FlashPlatform.hx:
#if embed_assets
trace("embed_assets = true");
            return new FlashEmbeddedAssetPackLoader(this, manifest).promise;
        #else
trace("embed_assets = false");
            return new FlashAssetPackLoader(this, manifest).promise;
        #end

Always traces embed_assets=false.

Then i just hardcoded it in that Class like

 public function loadAssetPack (manifest :Manifest) :Promise<AssetPack>
    {
return new FlashEmbeddedAssetPackLoader(this, manifest).promise;
    }


But still my swf does not embed the assets.

Am I missing something here?
What else do I have to do to make this work.

Embedding assets is really a must-have feature.

Thx

Mark Knol

unread,
Feb 6, 2015, 6:11:36 PM2/6/15
to fla...@googlegroups.com
You need to add "-D embed_assets" to the compiler flags

Mark Knol

unread,
Feb 6, 2015, 6:14:48 PM2/6/15
to fla...@googlegroups.com
More about conditional compilation can be found here,its a quite useful/powerful tool to understand:

http://haxe.org/manual/lf-condition-compilation.html
https://github.com/markknol/flambe-guide/wiki/Conditional-compilation

Hope this helps!

Lazer Starr

unread,
Feb 9, 2015, 3:40:29 AM2/9/15
to fla...@googlegroups.com
Great! Thank you very much!
The flag works now!

But still the asset embedding does not :(

I don´t get any error message, but the project does not work as it should. 
I am testing with the original starting template with the plane flying from above.
The plane does not appear when I set embed_assets: true

I guess I have to install hxswfml or somethin else somehow?
In the zip of the "flambe-flash_embedded_assets" are various files in the "bin" folder, also hxswfml.n.
Do I have to put this somewhere?!

Thx

Emilio Shodi

unread,
Feb 12, 2015, 5:34:30 PM2/12/15
to fla...@googlegroups.com
I have took a look at this problem and found out one more thing:
Even when you embedding assets into swf, flambe still tries to live reload all assets, so first of all you have to add -D flambe_disable_reloading to haxe_flags.
But even then, my swf file is less then 1Mb, when assets are ~4Mb. 
So, still not working.

Have you had any luck with it?

пятница, 6 февраля 2015 г., 20:23:07 UTC+3 пользователь Lazer Starr написал:

Emilio Shodi

unread,
Feb 12, 2015, 5:50:24 PM2/12/15
to fla...@googlegroups.com
Actually, i dont even understand how it works.

For instance, this code:

var className = ~/[^\d|\w|\$]|^[^A-za-z]/g.replace(url.substring(url.indexOf("/") + 1, url.lastIndexOf(".")), "$");
if (Type.resolveClass(className) != null)
{
 //handling assets
}


but tracing Type.resolveClass(className) gives null for all of my assets.

Why exactly this code should embed assets into SWF?



пятница, 6 февраля 2015 г., 20:23:07 UTC+3 пользователь Lazer Starr написал:
Hello,

Emilio Shodi

unread,
Feb 12, 2015, 6:30:26 PM2/12/15
to fla...@googlegroups.com
Forget my previous messages, i was talking nonsense.

I made a hack:
npm link ./command
haxelib dev flambe
./src


When i tried to build my project i had this kind of errors:
Missing required field in config file: XXX
Build halted with errors.

Where XXX — embed_assets, width, height

So i added them to my flambe.yaml
embed_assets: true
width: 640
height: 800

And the final error, with which i don't know what to do:

Building Project
Running Pre-Build Command Line...
cmd: cmd /c flambe build  --debug
neko D:\TEMP DELETE\flambe\command/../bin/hxswfml.n xml2lib build/.cache/swf/hxswfml_asset_lib_def.xml libs/library.swf
Uncaught exception - load.c(181) : Module not found : D:\TEMP
Build halted with errors.


Any ideas anyone?




пятница, 6 февраля 2015 г., 20:23:07 UTC+3 пользователь Lazer Starr написал:
Hello,

Emilio Shodi

unread,
Feb 12, 2015, 6:39:15 PM2/12/15
to fla...@googlegroups.com
I managed to get rid of last error (problem was occuring because of space in the dev path).
Now i got a bunch of stuff and i almost gave up 

Called from sys.io.FileOutput::$statics line 1
Called from be.haxer.hxswfml.Main::main line 51
Called from be.haxer.hxswfml.SwfLibWriter::write line 67
Called from be.haxer.hxswfml.SwfLibWriter::bitmap line 120
Called from be.haxer.hxswfml.SwfLibWriter::createDefineBitsJPEG line 323
Called from be.haxer.hxswfml.ImageWriter::getTag line 104
Called from format.png.Tools::extract32 line 204
Uncaught exception - Invalid operation (+)
Build halted with errors.




пятница, 13 февраля 2015 г., 2:30:26 UTC+3 пользователь Emilio Shodi написал:

n...@purplepwny.com

unread,
Feb 12, 2015, 7:22:45 PM2/12/15
to fla...@googlegroups.com
Hi,

I haven't touched the code in a while, but I think it should still work, and other people have told me that they've used it.

Yes, you do need hxswfml, and it seems like you've gotten the furthest Emilio. As to your error, it looks like it's happening inside of hxswfml to me. Maybe one of the assets is causing hxswfml to throw an exception? Try emptying the assets folder and then putting one brand new PNG in there, and see if it still throws the exception.



Peter Achberger

unread,
Feb 13, 2015, 2:20:04 AM2/13/15
to fla...@googlegroups.com, n...@purplepwny.com
Looking at my old index.js, I told it to only use sound datatype for mp3, otherwise always bytearray, as that saved filesize (hxswfml would unpack the png to bitmap). Not sure if I did some changes to asset unpacking code, but I guess I had to. Point is that error is most probably caused by hxswfml not being able to decode your png/jpeg.

Lazer Starr

unread,
Feb 13, 2015, 3:34:55 AM2/13/15
to fla...@googlegroups.com, n...@purplepwny.com
Hi guys ... i´m still not succeeding ... i´m a bloody noob when it comes to command line stuff etc.

I´m still not getting any error message and still don´t know how to install or whatever to do to make hxswfml do anything


Is this what you´re doing here? i don´t really understand what that does :/
npm link ./command
haxelib dev flambe
./src

thx

nox

unread,
Feb 13, 2015, 9:13:03 AM2/13/15
to fla...@googlegroups.com
On Friday, February 6, 2015 at 12:23:07 PM UTC-5, Lazer Starr wrote:
Lazer,

hxswfml should be included in the bin folder of that branch.

As far as these commands:

npm link ./command
haxelib dev flambe ./src

They're basically used when you want to change the filesystem location of flambe that you're currently using; for instance, when you want to move from a zip archive of flambe to using the git repo. In your case, you'd want to execute these from within the "flambe-flash_embedded_assets" directory. This will cause flambe to be included and executed from the sources in this new directory.

What happens when you execute the following from "flambe-flash_embedded_assets":

neko bin/hxswfl.n

I think that's right, but I don't have access to a machine right now.

Also, does your test project (the plane demo) have a "libs" directory after you try to build it with embedded assets? If so, is there anything in it?

Lazer Starr

unread,
Feb 13, 2015, 10:21:51 AM2/13/15
to fla...@googlegroups.com, n...@purplepwny.com
Hmm, i´ve done that, executed 

 npm link ./command
    haxelib dev flambe ./src

in my "flambe-flash_embedded_assets" folder.

But i got an error log (see attachment).

Now Flambe doesn´t work any more.

When i try to build i get this error:
module.js:340
    throw err;
          ^
Error: Cannot find module 'flambe'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (E:\_LIBS_FLAMBE\Flambe_Branches\flambe-flash_embedded_assets\command\flambe.js:8:14)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
Build halted with errors.

What to do?
Is there at least a simple way to undo this so i can work with flambe again at all?

thx
npm-debug.log

nox

unread,
Feb 13, 2015, 10:47:21 AM2/13/15
to fla...@googlegroups.com
On Friday, February 6, 2015 at 12:23:07 PM UTC-5, Lazer Starr wrote:
To undo it run:

sudo flambe update
haxelib dev flambe

Beyond that, if you have never run those commands before, then that would probably be why it wasn't working. The game was looking for the assets, but they've never been built because the new build scripts aren't being used. I can't personally help the exact error you're getting right now, though you could see what happens when you undo it, and then try to build again after just running the npm command.

Emilio Shodi

unread,
Feb 13, 2015, 12:53:03 PM2/13/15
to fla...@googlegroups.com, n...@purplepwny.com
I got it to work with default flambe project, but i had to downgrade my format lib to 3.0.5 (i guess that is because flambe-flash_embedded_assets is based on flambe4 and current version of format working only with flambe4.1)

Now main-flash.swf containts bootstrap$plane symbol and starts on flambe server. But still, if i open it separately via google chrome, it still doesn't work, all i see is a white page.

пятница, 13 февраля 2015 г., 3:22:45 UTC+3 пользователь n...@purplepwny.com написал:

nox pp

unread,
Feb 13, 2015, 2:26:10 PM2/13/15
to Emilio Shodi, fla...@googlegroups.com
Cool, it sounds like you're really close. I mentioned in my pull request that you actually also need this commit of mine, @d29c102(https://github.com/aduros/flambe/commit/d29c102). It will force the system to wait for a Context3D to be acquired, let me know if that changes anything.

nox pp

unread,
Feb 13, 2015, 2:52:14 PM2/13/15
to Emilio Shodi, fla...@googlegroups.com
I should note that you have to actually wait on the promise returned by System.init in order to experience that benefit.

Emilio Shodi

unread,
Feb 13, 2015, 3:24:47 PM2/13/15
to fla...@googlegroups.com, kaiz...@gmail.com
Actually i guessed it myself :)
My solution was dumb: i just Timer.delay(...)'ed loading of assets.
I noticed, that when i launch main-flash.swf and check trace, i see there:
ERROR flambe: Unexpected Stage3D failure! [error=Error #3702: Context3D not available.]

Is it a problem with my version of flash player?

P.S. It still works via flambe's server



пятница, 13 февраля 2015 г., 22:52:14 UTC+3 пользователь nox написал:
Message has been deleted

Emilio Shodi

unread,
Feb 13, 2015, 3:38:25 PM2/13/15
to fla...@googlegroups.com, kaiz...@gmail.com
I totally forgot to set wmode=direct!
It works as it should.

Thank you for your help, nox!
What's left to do is to port this code to flambe4.1 and make preloader work.

пятница, 13 февраля 2015 г., 22:52:14 UTC+3 пользователь nox написал:
I should note that you have to actually wait on the promise returned by System.init in order to experience that benefit.

nox pp

unread,
Feb 13, 2015, 3:51:44 PM2/13/15
to fla...@googlegroups.com, Эмиль Шодиев
Sweet, I'm glad you got it working!

If would be of any help to you, I have a preloader branch here that I use with the embedded assets:

https://github.com/purplepwny/flambe/commits/flash_preloader



> My solution was dumb: i just Timer.delay(...)'ed loading of assets.

Yeah, that was my first solution as well. It works!

--
You received this message because you are subscribed to a topic in the Google Groups "Flambe" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/flambe/D3tF7KLMgF8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to flambe+un...@googlegroups.com.
To post to this group, send email to fla...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flambe/18881005-3191-45af-affe-89bfb15a961b%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Lazer Starr

unread,
Feb 17, 2015, 11:07:47 AM2/17/15
to fla...@googlegroups.com, kaiz...@gmail.com
thx guys, got it working too!
gotta look at the preloader and the problem with file increasing PNGs (and probably JPGS as well) later ;)

Still hope this will be implemented in the official flambe release though ... would be awesomish!

omega...@gmail.com

unread,
Feb 26, 2015, 1:55:13 PM2/26/15
to fla...@googlegroups.com
Hey guys,

I'm currently trying to get this to work. I've got it building without errors using purplepwny's fork, but I'm stuck on just a white screen.

I think my issue is that I don't know *what* to use as the 'flash preloader' parameter. I've got a class and a static main() function since it wouldn't compile without one, but I can't figure out what the preloader class should actually do..

It would be great if nox could chime in again with an explanation here. I've looked through the code and commit message of every commit in the flash_preloader branch, but I just haven't grasped what it wants me to do.

omega...@gmail.com

unread,
Feb 26, 2015, 2:00:12 PM2/26/15
to fla...@googlegroups.com, omega...@gmail.com
I should mention that if I *do* leave the parameter out, and let the build fail after building the main swf, I don't get a white screen. I just get my normal flambe preloader, stuck at 0% forever.

nox pp

unread,
Feb 26, 2015, 2:44:12 PM2/26/15
to fla...@googlegroups.com
Hi Omega,

I would recommend getting the embedded assets branch working before merging the preloader branch--probably. Also keep in mind that the embedded assets branch basically depends on also pulling the asynchronous initialization branch (https://github.com/purplepwny/flambe/commit/d29c102) and using it by waiting for System.init's new promise. I think that point is catching a lot of people.

If you get to the point where you are in fact ready for a preloader, this is the entirety of my preloader for Super Murderwolf, which I adapted from here (http://old.haxe.org/doc/flash/preloader):

package preloader;

import flash.Lib;
import flash.display.Sprite;
import flash.events.Event;
import haxe.Timer;

class Preloader extends Sprite
{
    public function new()
    {
        super();
        addEventListener(Event.ENTER_FRAME, onLoadProgress);
        progress_bar = new Sprite();

        addChild(progress_bar);
    }
    function onLoadProgress(event:Event):Void
    {
        var bytesLoaded = Lib.current.stage.loaderInfo.bytesLoaded;
        var bytesTotal = Lib.current.stage.loaderInfo.bytesTotal;
        var percentLoaded = bytesLoaded / bytesTotal;

        progress_bar.graphics.clear();
        var bar_width = 350;
        var bar_height = 50;
        progress_bar.graphics.beginFill(0x9b3730);
        progress_bar.graphics.drawRect(-bar_width / 2, -bar_height / 2, bar_width * percentLoaded, bar_height);
        progress_bar.x = stage.stageWidth / 2;
        progress_bar.y = stage.stageHeight / 2;
        progress_bar.graphics.endFill();
       
        if ( percentLoaded == 1 )
        {
            removeEventListener(Event.ENTER_FRAME, onLoadProgress);
            Lib.current.removeChild(this);
            var cls = Type.resolveClass("nss.Main");
            untyped cls.main();
        }
    }
    public static function main()
    {
        var preloader = new Preloader();
        Lib.current.addChild(preloader);
    }
   
    private var progress_bar : Sprite;
}









--
You received this message because you are subscribed to a topic in the Google Groups "Flambe" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/flambe/D3tF7KLMgF8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to flambe+un...@googlegroups.com.
To post to this group, send email to fla...@googlegroups.com.

omega...@gmail.com

unread,
Feb 26, 2015, 5:03:05 PM2/26/15
to fla...@googlegroups.com
Thanks so much for the quick reply!

I finally managed to get everything working right. I did it gradually like you suggested, first merging flash_embedded_assets and asynch_init, and then just using the development branch once I got embedded assets working properly.

I did have some problems for a while, with the game freezing on the first frame of my Flambe preloader scene - the bootstrap pack would load, but my actual game assets would not. It turned out it was having trouble with some of my assets (.tga files, audio files other than .mp3, etc), and it worked fine once I removed those.

Thanks again!

Arian Allenson Valdez

unread,
Apr 24, 2015, 9:18:22 AM4/24/15
to fla...@googlegroups.com
Is Flambe Development Dead? This was an issue reference a year ago and it still isn't integrated into master

Emilio Shodi

unread,
Apr 24, 2015, 10:26:44 AM4/24/15
to fla...@googlegroups.com
I guess, no one said that this feature gonna end up in master.
As for project status — i really hope that's project is going to grow (although i haven't heard any news for quite a long time)


пятница, 24 апреля 2015 г., 16:18:22 UTC+3 пользователь Arian Allenson Valdez написал:
Reply all
Reply to author
Forward
0 new messages