On Thu, May 21, 2009 at 10:34 PM, Ludwig Weinzierl
<[email protected]> wrote:
> The following piece of code compiles and runs without errors when compiled
> with mxmlc from flex_sdk_3 or flex_sdk_4.0.0.4021.
>
> package{
> import flash.display.Sprite;
> public class Sitemap extends Sprite{
> public function Sitemap(){
> graphics.beginFill(0x00ff00, 1);
> graphics.drawCircle(100, 100, 40);
> }
> }
> }
>
> It compiles without errors with as3compile from swftools 0.9.0,
> the swf does *not* run however.
> It was compiled with:
>
> as3compile -v -R -X400 -Y400 -MSitemap
> -oSitemap-as3compiler-0.9.0-Faulty.swf Sitemap.as
>
> The Adobe Standalone Flash Debugger 10(10,0,22,87) says:
>
> An ActionScript error has occurred:
> ReferenceError: Error #1065: Variable is not defined.
>
I think mainclass *must* be a subclass of MovieClip in as3compile.
Why? I don't know.
It seems to me that the -M arg is ignored.
if you run swfdump on the resulting swf where the mainclass is a
subclass of Sprite, you have:
[HEADER] File version: 9
[HEADER] File is zlib compressed. Ratio: 77%
[HEADER] File size: 367
[HEADER] Frame rate: 25.000000
[HEADER] Frame count: 1
[HEADER] Movie width: 400.00
[HEADER] Movie height: 400.00
[045] 4 FILEATTRIBUTES as3
[052] 324 DOABC
[04c] 5 SYMBOLCLASS
exports 0000 as ""
[001] 0 SHOWFRAME 1 (00:00:00,000)
[000] 0 END
Look the line that says:
exports 0000 as ""
And now running swfdump in the resulting swf where the mainclass is a
subclass of MovieClip, you have:
[HEADER] File version: 9
[HEADER] File is zlib compressed. Ratio: 77%
[HEADER] File size: 391
[HEADER] Frame rate: 25.000000
[HEADER] Frame count: 1
[HEADER] Movie width: 400.00
[HEADER] Movie height: 400.00
[045] 4 FILEATTRIBUTES as3
[052] 341 DOABC
[04c] 12 SYMBOLCLASS
exports 0000 as "Sitemap"
[001] 0 SHOWFRAME 1 (00:00:00,000)
[000] 0 END
Now look to the "exports" line, you have your "Sitemap"
>
> I am running ubuntu 9.04 with kernel Linux 2.6.28-11-generic.
me too.
> The following compiles and runs fine when compiled with any of the
> mentioned compilers, including as3compile.
>
> package{
> import flash.display.MovieClip;
> public class Sitemap extends MovieClip{
> public function Sitemap(){
> graphics.beginFill(0x00ff00, 1);
> graphics.drawCircle(100, 100, 40);
> }
> }
> }
>
Yep, this one is OK
> Can anyone confirm this?
Yes, I get the same behaviour.
I have attach a possible solution for this.
With this you can have a Sprite as mainclass.
I don't know if this patch will raise others issues. Matthias???
Regards
Ricardo
=== modified file 'src/as3compile.c'
--- src/as3compile.c 2009-05-22 22:58:24 +0000
+++ src/as3compile.c 2009-05-23 00:43:29 +0000
@@ -161,7 +161,7 @@
printf("-X , --width Set target SWF width\n");
printf("-Y , --height Set target SWF width\n");
printf("-r , --rate Set target SWF framerate\n");
- printf("-M , --mainclass Set the name of the main class (extending flash.display.MovieClip)\n");
+ printf("-M , --mainclass Set the name of the main class (extending flash.display.MovieClip or flash.display.Sprite)\n");
printf("-l , --library <file> Include library file <file>. <file> can be an .abc or .swf file.\n");
printf("-I , --include <dir> Add additional include dir <dir>.\n");
printf("-N , --local-with-network Make output file \"local with networking\"\n");
@@ -253,7 +253,11 @@
tag = swf_InsertTag(tag, ST_SYMBOLCLASS);
swf_SetU16(tag, 1);
swf_SetU16(tag, 0);
- swf_SetString(tag, as3_getglobalclass());
+ /* user pass the name of the mainclass with
+ -M or--mainclass option, so we will use it.
+ If the mainclass name given is incorrect,
+ it will generate a runtime error */
+ swf_SetString(tag, mainclass);
} else {
as3_warning("no global public MovieClip subclass");
}