[swfmill] The <call> tag and HaXe / AS3

András Parditka andras at michaeltristram.com
Thu Apr 10 05:01:44 PDT 2008


Thank you for the idea, Mark.

I went for the shared library option, and initially had no
success.
Sadly I was unable to get the example working at

http://osflash.org/swfmill#dynamic_shared_font_loading

and found that the examples link points to a missing page.

I would very much appreciate if you could give me some
pointers on this. I googled for it in vain.

I had to pass the shared library created in swfmill
through HaXe (an emtpy project), to get it to work.
I am not sure why.



Please look through the what I did, and I hope you can
correct me on how to do it properly.

1.
I created the main file called 'flash.swf' in the Flash IDE,
with a single frame and a TextField called 'test_txt' on the
stage. The file is AS3, targeted at Flash Player 9.

I added a font to the library, checked the 'Import for runtime
sharing', set its class to 'MySharedFont' and its URL to
'sl_haxe.swf'.

I added this code to the first frame:
------------------------------------------------------------
test_txt.embedFonts = true;
test_txt.defaultTextFormat = new TextFormat('Univers 67 I Condensed 
Bold', 18);
test_txt.text = 'Test successful.';
------------------------------------------------------------

2.
Created this 'sl_mill.xml':
------------------------------------------------------------
<?xml version='1.0' encoding='UTF-8'?>

<movie version="9" width="1024" height="640" framerate="25">
    <background color="#ff0000"/>
        <frame>
            <library>
                <font id="MySharedFont" name="Univers 67 I Condensed 
Bold" import="library/UniversI-CondensedRegular.ttf" />
            </library>
        </frame>
</movie>
------------------------------------------------------------

3.
I used:
------------------------------------------------------------
swfmill simple sl_mill.xml sl_mill.swf
------------------------------------------------------------
(Please note the library file's name 'sl_mill.swf' is not the
same as the file URL 'sl_haxe.swf' for the imported font above.)

Now this 'sl_mill.swf' file cannot be imported for runtime
sharing into the main swf ('flash.swf'). If you try to do so,
it will simply show a blank window with even the above mentioned
TextField ('test_txt') missing that was created in the Flash IDE and
not by code.
The loading fails for some reason, that is why we need to import
another file ('sl_haxe.swf'), created below.

4.
I created a simple, empty Main class ('Main.hx') for HaXe in the
same folder:
--------------------------------------------------------------
class Main
{
    public static function main()
    {
       
    }
}
--------------------------------------------------------------

5.
I used:
--------------------------------------------------------------
haxe -swf sl_haxe.swf -swf-lib sl_mill.swf -main Main -swf-header 
1024:640:25:ffffff -swf-version 9
--------------------------------------------------------------
And it worked! The font appeared in the main 'flash.swf' file.

I am not sure this is the best way to do it. I have tried a other
things, but nothing else worked. I'm afraid I am not doing
it the way you meant, so if you could please give me some
feedback, it would be well appreciated.

Thank you,
Andras

P.S. If I try to do swf2xml on either the 'sl_mill.swf' or
the 'sl_haxe.swf', it shows:
WARNING: end of tag DefineFont2 is @29426, should be @25033

This happens even with the latest build (0.2.12.4).


Mark Winterhalder wrote:
>>  Am I right about this, or have I missed anything?
>>     
>
> Hmm... I'm not sure. But maybe there is another option for you, if
> including everything into a single SWF is not a requirement -- loading
> a shared font library at runtime:
>
> <http://osflash.org/swfmill#dynamic_shared_font_loading>
>
> This works for me.
>
> Alternatively, you can simulate what <call/> does (in a somewhat
> hackish manner). Generate a simple SWF that calls your entry point,
> and use 'swfmill swf2xml your.swf' to output its XML (swfml-ll)
> representation. Copy the relevant <DoABCDefine/> (?) tag and include
> that in your swfml.
>
> HTH,
> Mark
>
>
>
> On Wed, Apr 9, 2008 at 4:12 PM, András Parditka
> <andras at michaeltristram.com> wrote:
>   
>> Thank you for your quick answer, Mark.
>>
>>  The reason for creating the swf with the code first and
>>  trying to add assets with swfmill later was that I wanted
>>  to find out what it would involve to use swfmill's most
>>  tempting feature (that I currently know): the ability
>>  to include all glyphs of a font in an swf.
>>
>>  It now seems to me this would involve having to use HaXe
>>  for compiling the code.
>>
>>  (For the Flash IDE cannot use an existing swf file as a
>>  library, and without the ability to call a function with
>>  swfmill, it is not possible to add the assets into the
>>  compiled file.)
>>
>>  Am I right about this, or have I missed anything?
>>
>>  Andras
>>
>>
>>
>>  Mark Winterhalder wrote:
>>  >>  All the examples containing the <call> tag seem to refer
>>  >>  to MTASC. Is the <call> tag usable with HaXe if you target
>>  >>  Flash 9?
>>  >>
>>  >
>>  > No, it's not usable for anything but AS2. <call/> is left over from
>>  > the very early days of Swfmill, IIRC the problem was that MTASC
>>  > compiled code executed before the SWF was fully initialized. That
>>  > problem was fixed shortly after, and I would discourage use even with
>>  > AS2 -- it's just not necessary anymore.
>>  > If you just remove the <call/> tag and use haXe's -main setting
>>  > instead, it should work, no?
>>  >
>>  > Mark
>>  >
>>  >
>>  >
>>  > On Wed, Apr 9, 2008 at 3:34 PM, András Parditka
>>  > <andras at michaeltristram.com> wrote:
>>  >
>>  >> Hello everyone,
>>  >>
>>  >>  All the examples containing the <call> tag seem to refer
>>  >>  to MTASC. Is the <call> tag usable with HaXe if you target
>>  >>  Flash 9?
>>  >>
>>  >>  I've tried to find answer to this in the mailing list
>>  >>  archives and in the available documentation, but could not
>>  >>  find one. I have also tried doing it a few ways, but
>>  >>  without success.
>>  >>
>>  >>  I've set up a little test project:
>>  >>
>>  >>  1.
>>  >>  Main.hx: (Just draws a black, 100x100px rectangle using script.)
>>  >>  ----------------------------------------------------------------
>>  >>  import flash.display.Sprite;
>>  >>  import flash.Lib;
>>  >>
>>  >>  class Main
>>  >>  {
>>  >>     public static var mySprite:Sprite;
>>  >>
>>  >>     public static function main()
>>  >>     {
>>  >>         mySprite = new Sprite();
>>  >>         Lib.current.addChild(mySprite);
>>  >>
>>  >>         mySprite.graphics.beginFill(0x000000);
>>  >>         mySprite.graphics.drawRect(0, 0, 100, 100);
>>  >>         mySprite.graphics.endFill();
>>  >>     }
>>  >>  }
>>  >>
>>  >>  2.
>>  >>  I use:
>>  >>  haxe -swf haxe.swf -swf-version 9 -swf-header 1024:640:25:ffffff -main Main
>>  >>
>>  >>  3.
>>  >>  mill.xml: (Should include the HaXe-generated swf, and call the
>>  >>  main() method of the Main class.)
>>  >>  --------------------------------------------------------------
>>  >>  <?xml version='1.0' encoding='UTF-8'?>
>>  >>
>>  >>  <movie version="9" width="1024" height="640" framerate="25">
>>  >>     <background color="#ff0000"/>
>>  >>         <frame>
>>  >>             <library>
>>  >>                 <clip id="mainApp" import="haxe.swf" />
>>  >>             </library>
>>  >>             <place id="mainApp" name="mainApp" x="0" y="0" depth="1" />
>>  >>             <call object="Main" method="main"></call>
>>  >>         </frame>
>>  >>  </movie>
>>  >>
>>  >>  4.
>>  >>  I use: (swfmill-0.2.12)
>>  >>  swfmill simple mill.xml mill.swf
>>  >>
>>  >>  Sadly, the black rectangle does not appear, which suggests the
>>  >>  call to Main.main() not taking place.
>>  >>  Am I doing something wrong?
>>  >>
>>  >>  Thank you in advance,
>>  >>  Andras
>>  >>
>>  >>  _______________________________________________
>>  >>  swfmill mailing list
>>  >>  swfmill at osflash.org
>>  >>  http://osflash.org/mailman/listinfo/swfmill_osflash.org
>>  >>
>>  >>
>>  >
>>  > _______________________________________________
>>  > swfmill mailing list
>>  > swfmill at osflash.org
>>  > http://osflash.org/mailman/listinfo/swfmill_osflash.org
>>  >
>>
>>  _______________________________________________
>>  swfmill mailing list
>>  swfmill at osflash.org
>>  http://osflash.org/mailman/listinfo/swfmill_osflash.org
>>
>>     
>
> _______________________________________________
> swfmill mailing list
> swfmill at osflash.org
> http://osflash.org/mailman/listinfo/swfmill_osflash.org
>   



More information about the swfmill mailing list