Posts Tagged linux

gen-hx-classes papervision3d

After reading [haXe] Fisix + haXe = FisaXe? hehe, I started to wonder if I couldn’t use a similar trick to make papervision3d.

Though I was not able to get a pure haxe solution, I did get a happy ending

Updating papervision3d

ActionScript3 pointed out that the version of papervision3d he ported was old and that it would probably be worthwhile to grab a newer version

I thought about checking out a copy from SVN, but I know the sort of stuff you tend to get from checking out from the head… 😛

So I decided to go with what looked to the the last official release, version 1.5 from

% mkdir /home/brian/tmp/pv3d
% cd /home/brian/tmp/pv3d
% unzip
% ls PV3D_1_5/src
com  fl  livePreview  org


flex builder for linux

Word on the street is that the A3 compiler from flash is still faster than haxe.

So… I went to and grabbed a copy of the flex builder alpha for linux.

The install wanted an eclipse directory with a “configuration” subdirectory and barked at me… I’m not really an eclipse guy, so whatever. Maybe I will hook it up later…

Here is what it looked like:

% chmod 755 flexbuilder_linux_install_a3_033108.bin
% ./flexbuilder_linux_install_a3_033108.bin
% export PATH=${PATH}:${HOME}/data/Adobe_Flex_Builder_Linux/sdks/3.0.0/bin/
% which mxmlc

Sweet… now I can get that AS3 fanciness I keep hearing about!


This actually had me scratching my noggin… The original post had said:

mxmlc -include-libraries /AS3_src/Fisix/Bin/FisixEngine.swc -file-specs -output ./FisixLib.swf  -benchmark=true

Obvious is something I don’t have and I also don’t have a swc and I won’t bore you with how I came up with this bit of madness:

% cd /home/brian/tmp/pv3d
% mkdir tmp
% cd tmp
% find /home/brian/tmp/pv3d/PV3D_1_5/src -type f -name "*.as" >
% echo "package {" >
% cat | cut -f1 -d. | sed 's,.*src/,import ,;s,/,.,g;s,$,;,'  >>
% echo "public class Test {" >>
% cat  | cut -f1 -d. | sed 's,.*/,,;s,.*,public var tmp_& : &;,' >>
% echo "} }" >>

Of course that’s not exactly how I did it, but it was just as painful and used the same methodology.

So by now you are probably shaking your head and laffing, going “ok, bright-boy! now echo me up an swc file!”

Not nice…

Happily, I got some command line help from a guy I don’t know in Japan, so that I was able to hookup:

%  mxmlc -source-path ${HOME}/tmp/pv3d/PV3D_1_5/src -file-specs -output Papervision3d.swf

Kabloom! It dumped out a bunch gobble-de-gook.

Luckily, yours-truly is an old hand at ignoring compiler errors… A little of ye olde clickety-clack… and I had version of that would compile.

I did it like this:

% grep PV3D_1_5/src mxmlc.errors.compiling.PV3D_1_5.txt | cut -f1 -d\( | sed 's,.*/,,;s,.as$,,' | sort -u | sed 's,^,tmp_,'
tmp_InteractiveWireframeMaterial Error: A file found in a source-path must have the same package structure 'livePreview', as the definition's package, 'fl.livepreview'.

Look, maw! I’m UNIX hackin’! I’m UNIX hackin’! Got that one odd-man-out…

Comment those lines out:

//public var tmp_CompositeTriangleCuller : CompositeTriangleCuller;
//public var tmp_DepthTriangleCuller : DepthTriangleCuller;
//public var tmp_InteractiveWireframeMaterial : InteractiveWireframeMaterial;
//public var tmp_PV3DColladaScene : PV3DColladaScene;
//public var tmp_Stars : Stars;
//public var tmp_LivePreviewParent : LivePreviewParent;

Next thing you know:

%  mxmlc -source-path ${HOME}/tmp/pv3d/PV3D_1_5/src -file-specs -output Papervision3d.swf
Loading configuration file /home/brian/data/Adobe_Flex_Builder_Linux/sdks/3.0.0/frameworks/flex-config.xml
Papervision3d.swf (168851 bytes)

And now we know!

And knowing is half the battle…

Let’s fight on…


The next piece of good advice is that we can use

% haxe --gen-hx-classes Papervision3d.swf

Yeah… sure it spewed a bunch of madness, but let it!

It also generated a lot of good stuff!

% find hxclasses -name "*.hx" | wc -l

Kind of a lot of stuff.. the original library only had 85 .as files… hummm… thanks?

trying it on

% cp Papervision3d.swf /tmp
% cp -r hxclasses /tmp
%  cat TestHaxePv3d.hxml
-main TestHaxePv3d
-swf TestHaxePv3d.swf
-swf-version 9
-swf-lib /tmp/Papervision3d.swf
-cp /tmp/hxclasses
% haxe TestHaxePv3d.hxml
TestHaxePv3d.hx:19: characters 0-47 : Class not found : org.papervision3d.core.utils.FPSCounter

Which is actually ok… I reused my demo from before… clickety-clack…

% haxe TestHaxePv3d.hxml

Yup… it gacked up more “Unknown opcode 0x59” hairballs! but… lookit!

% ls *swf

Or better yet! Don’t bother!

Cuz it’s just a blank blue-ish screen!

Haha! It doesn’t really make me feel any better that Asger Ottar Alstrup got stuck at pretty much the same point…

When I asked him about it, he said he did get it to work:


Yes, I got it to work just fine. Just make a .as file referencing the classes you need, compile that to a papervision.swf file, then

haxe --gen-hx-classes papervision.swf

generates the classes, and everything works fine. Remember to add a "-cp" switch to point to the generated files, and link in the papervision.swf file using "-swf-lib". (I use swfmill to bundle a bunch of .swf's together to one .swf and then link that into the final .swf, but it also works if you just directly link in the papervision.swf file.)


So… I dunno

Bummer… I tried everything all over again trying to use the 2.0.1 version of mxmlc, but with the same result.

Silver Lining

Though I was originally hoping to be able to papervision3d via haxe, I finally did end up with a solution that works

% wget
% mxmlc -source-path ${HOME}/tmp/pv3d/PV3D_1_5/src -file-specs -output exampleSpherePrimtive.swf

Sure… it’s actionscript, but yeah the compiler is proprietary, but … eh.. at least there is some way forward.

It just wasn’t the way I wanted… boo+hoo=moving on

Time to get my AS3-fancy on!

Comments (1)