I imported a 3DS file with two squares into Prefab and exported as AS3
Class for Flash 10. With the AS3, I get as well one image folder with
2 jpgs inside for the textures. I guess so far so good.

In Flash CS4 I create a FLA and set the AS3 from prefab as class in
the properties. I compile and get this error:

Flex SDK Required!
Flex SDK path: $(AppConfig)/ActionScript 3.0/libs/flex_sdk_3/

I read that CS4 comes with an Flex SDK already installed so clicking
"Update library path" should call that version.
Am I wrong? Do I need to install another flex SDK?

After more errors, in the output text:
ReferenceError: Error #1065: Variable Test2_Box01_Bitmap is not
defined.

In the compile errors:
5000: The class 'Test2' must subclass 'flash.display.MovieClip' since
it is linked to a library symbol of that type.

Test2 is the AS3 class from Prefab.

Here is the code from Test2 generated by Prefab:

//AS3ExporterAIR version 2.2, code Flash 10, generated by Away3D:
http://www.away3d.com
package
{
        import away3d.containers.ObjectContainer3D;
        import away3d.containers.Scene3D;
        import away3d.core.math.*;
        import away3d.materials.*;
        import away3d.core.base.*;
        import away3d.core.utils.Init;
        import away3d.loaders.utils.*;
        import away3d.loaders.data.*;
        import flash.utils.Dictionary;
        import away3d.primitives.*;
        import flash.display.Bitmap;
        import flash.display.BitmapData;

        public class Test2 extends Mesh
        {
                [Embed(source="images/box01.png")]
                private var Box01_Bitmap:Class;

                private var objs:Object = {};
                private var geos:Array = [];
                private var oList:Array =[];
                private var aC:Array;
                private var aV:Array;
                private var aU:Array;
                private var _scale:Number;

                public function Test2(init:Object = null)
                {
                        var ini:Init = Init.parse(init);
                        _scale = ini.getNumber("scaling", 1);
                        setSource();
                        addContainers();
                        buildMeshes();
                        buildMaterials();
                        cleanUp();
                }

                private function buildMeshes():void
                {
                        var m0:MatrixAway3D = new MatrixAway3D();
                        m0.sxx = 1;
                        m0.sxy = 0;
                        m0.sxz = 0;
                        m0.tx = -5.01*_scale;
                        m0.syx = 0;
                        m0.syy = 1;
                        m0.syz = 0;
                        m0.ty = -5.97*_scale;
                        m0.szx = 0;
                        m0.szy = 0;
                        m0.szz = 1;
                        m0.tz = 1.98*_scale;

                        objs.obj0 = {name:"box01",  transform:m0, pivotPoint:new
Number3D(0,0,0), container:-1, bothsides:false, material:null,
ownCanvas:false, pushfront:false, pushback:false};
                        objs.obj0.geo=geos[0];

                        var ref:Object;

                        var j:int;
                        var av:Array;
                        var au:Array;
                        var v0:Vertex;
                        var v1:Vertex;
                        var v2:Vertex;
                        var u0:UV;
                        var u1:UV;
                        var u2:UV;
                        var aRef:Array ;
                        for(var i:int = 0;i<1;++i){
                                ref = objs["obj"+i];
                                if(ref != null){
                                        this.type = ".as";
                                        this.bothsides = ref.bothsides;
                                        this.name = ref.name;
                                        this.pushfront = ref.pushfront;
                                        this.pushback = ref.pushback;
                                        this.ownCanvas = ref.ownCanvas;
                                        if(ref.container != -1){
                                                
aC[ref.container].addChild(this);
                                        }

                                        oList.push(this);
                                        this.transform = ref.transform;
                                        this.movePivot(ref.pivotPoint.x, 
ref.pivotPoint.y,
ref.pivotPoint.z);
                                        if (ref.geo.geometry != null) {
                                                this.geometry = 
ref.geo.geometry;
                                                continue;
                                        }
                                        ref.geo.geometry = new Geometry();
                                        this.geometry = ref.geo.geometry;
                                        aRef = ref.geo.f.split(",");
                                        for(j = 0;j<aRef.length;j+=6){
                                                try{
                                                        av = 
ref.geo.aV[parseInt(aRef[j], 16)].split("/");
                                                        v0 = new 
Vertex(Number(parseFloat(av[0]))*_scale,
Number(parseFloat(av[1]))*_scale, Number(parseFloat(av[2]))*_scale);
                                                        av = 
ref.geo.aV[parseInt(aRef[j+1],16)].split("/");
                                                        v1 = new 
Vertex(Number(parseFloat(av[0]))*_scale,
Number(parseFloat(av[1]))*_scale, Number(parseFloat(av[2]))*_scale);
                                                        av = 
ref.geo.aV[parseInt(aRef[j+2],16)].split("/");
                                                        v2 = new 
Vertex(Number(parseFloat(av[0]))*_scale,
Number(parseFloat(av[1]))*_scale, Number(parseFloat(av[2]))*_scale);
                                                        au = 
ref.geo.aU[parseInt(aRef[j+3],16)].split("/");
                                                        u0 = new 
UV(parseFloat(au[0]), parseFloat(au[1]));
                                                        au = 
ref.geo.aU[parseInt(aRef[j+4],16)].split("/");
                                                        u1 = new 
UV(parseFloat(au[0]), parseFloat(au[1]));
                                                        au = 
ref.geo.aU[parseInt(aRef[j+5],16)].split("/");
                                                        u2 = new 
UV(parseFloat(au[0]), parseFloat(au[1]));
                                                        
ref.geo.geometry.addFace( new Face(v0, v1, v2, ref.material,
u0, u1, u2) );
                                                }catch(e:Error){
                                                        trace("obj"+i+": 
["+aV[parseInt(aRef[j],16)].split("/")+"],
["+aV[parseInt(aRef[j+1],16)].split("/")+"],["+aV[parseInt(aRef[j+2],
16)].split("/")+"]");
                                                        trace("     uvs: 
["+aV[parseInt(aRef[j+3],16)].split("/")+"],
["+aV[parseInt(aRef[j+4],16)].split("/")+"],["+aU[parseInt(aRef[j+5],
16)].split("/")+"]");
                                                }
                                        }
                                }
                        }
                }

                private function setSource():void
                {
                        var geo0:Object = {};
                        
geo0.aVstr="f8.800/-108.1e06/-1.2663,f8.800/108.1e06/-1.2663,-
f8.800/108.1e06/-1.2663,-
f8.800/-108.1e06/-1.2663,f8.800/-108.1e06/1.2663,-
f8.800/-108.1e06/1.2663,-
f8.800/108.1e06/1.2663,f8.800/108.1e06/1.2663";
                        geo0.aUstr="0.000459c9168586d1/0.0002b81dae137031c,
0.0002b81dae137031c/1.0000246d045890,0.23867615bd37dc/0.23867615bd37dc,
1.0000246d045890/0.0002b81dae13759da";
                        geo0.aV= read(geo0.aVstr).split(",");
                        geo0.aU= read(geo0.aUstr).split(",");
        
geo0.f="0,1,2,0,1,2,0,1,2,0,1,2,2,3,0,2,3,0,2,3,0,2,3,0,4,5,6,0,3,2,4,5,6,0,3,2,6,7,4,2,1,0,6,7,4,2,1,0,0,3,5,0,3,3,0,3,5,0,3,3,5,4,0,3,0,0,5,4,0,3,0,0,3,2,6,3,2,2,3,2,6,3,2,2,6,5,3,2,3,3,6,5,3,2,3,3,2,1,7,2,1,1,2,1,7,2,1,1,7,6,2,1,2,2,7,6,2,1,2,2,1,0,4,1,0,0,1,0,4,1,0,0,4,7,1,0,1,1,4,7,1,0,1,1";
                        geos.push(geo0);
                }

                private function buildMaterials():void
                {
                                var box01_Bitmap:Bitmap = new Box01_Bitmap();
                                applyMaterialToMesh("box01", 
box01_Bitmap.bitmapData);

                }

                private function applyMaterialToMesh(id:String, 
bmd:BitmapData):void
                {
                        for(var i:int;i<meshes.length;++i){
                                if(meshes[i].name == id){
                                        meshes[i].material = new 
BitmapMaterial(bmd);
                                        break;
                                }
                        }
                }

                private function cleanUp():void
                {
                        for(var i:int = 0;i<1;++i){
                                objs["obj"+i] == null;
                        }
                        aV = null;
                        aU = null;
                }

                private function addContainers():void
                {}


                public function get meshes():Array
                {
                        return oList;
                }


                private function read(str:String):String
                {
                        var start:int= 0;
                        var chunk:String;
                        var end:int= 0;
                        var dec:String = "";
                        var charcount:int = str.length;
                        for(var i:int = 0;i<charcount;++i){
                                if (str.charCodeAt(i)>=44 && 
str.charCodeAt(i)<= 48 ){
                                        dec+= str.substring(i, i+1);
                                }else{
                                        start = i;
                                        chunk = "";
                                        while(str.charCodeAt(i)!=44 && 
str.charCodeAt(i)!= 45 &&
str.charCodeAt(i)!= 46 && str.charCodeAt(i)!= 47 && i<=charcount){
                                                i++;
                                        }
                                        chunk = 
""+parseInt("0x"+str.substring(start, i), 16 );
                                        dec+= chunk;
                                        i--;
                                }
                        }
                        return dec;
                }

        }
}

How can I get what I created in Prefab showing up successfully after
compiling with Flash CS4

Thanx.

Reply via email to