Hi all,
I start with Away3D and HaXe. I do not understand why essai_01.swf
file contains errors that seem to be in initMaterials function ():
Void ().
Thank you for your help.


import away3d.containers.Scene3D;

import away3d.containers.View3D;

import away3d.containers.ObjectContainer3D;

import away3d.core.math.Number3D;

import away3d.materials.BitmapMaterial;

import flash.display.Bitmap;

import flash.display.BitmapData;

import away3d.materials.ColorMaterial;
import away3d.materials.MovieMaterial;

import away3d.materials.WireColorMaterial;

import away3d.primitives.data.CubeMaterialsData;

import away3d.primitives.RoundedCube;

import away3d.primitives.Cube;

import away3d.lights.DirectionalLight3D;

import away3d.cameras.Camera3D;

import flash.Lib;

import flash.display.Sprite;

import flash.events.Event;

import flash.events.MouseEvent;
import flash.external.ExternalInterface;


class Gangs_of_New_York extends Sprite {}



class Gladiator extends Sprite {}


class Kill_Bill extends Sprite {}



class Ouest extends Sprite {}



class Loup extends Sprite {}



class Bon extends Sprite {}



class Essai_01 extends Sprite {


        var scene:Scene3D;

        var camera:Camera3D;

        var view:View3D;
        var _rc: Cube;
        var _material:MovieMaterial;

        var matleft:MovieMaterial;
        var mattop:MovieMaterial;
        var matbottom:MovieMaterial;
        var matfront:MovieMaterial;
        var matright:MovieMaterial;
        var matback:MovieMaterial;
        var _gladiator:Gladiator;
        var _kill_bill:Kill_Bill;
        var _ouest:Ouest;
        var _loup:Loup;
        var _bon:Bon;
        var _gangs: Gangs_of_New_York ;
        var cubedata:CubeMaterialsData;
        var move:Bool ;

        var lastMouseX:Float;

        var lastMouseY:Float;

        var lastRotationX:Float;

        var lastRotationY:Float;
        var light:DirectionalLight3D;
        var spherecontainer:ObjectContainer3D;

        public function new() {

                super();

                Lib.current.stage.frameRate=60;



                initEngine();

                initMaterials();

                initObjects();

                initLights();

                initListeners();

        }

        function initMaterials():Void

        {
                _gladiator = new Gladiator();

                matleft = new MovieMaterial(_gladiator );
                _gangs = new Gangs_of_New_York ();
                mattop = new MovieMaterial(_gangs );
                _kill_bill = new Kill_Bill();
                matbottom = new MovieMaterial(_kill_bill );
                _ouest = new Ouest();
                matfront = new MovieMaterial(_ouest );
                _loup = new Loup();
                matright = new MovieMaterial(_loup);
                _bon = new Bon();
                matback = new MovieMaterial(_bon );


                cubedata = new CubeMaterialsData(
                        {top:mattop,
                        bottom:matbottom,
                        front:matfront,
                        back:matback,
                        left:matleft,
                        right:matright});


        }

        function initEngine():Void

        {

                scene = new Scene3D();



                camera = new Camera3D();

                camera.z = -1000;



                view = new View3D();

                view.scene= scene;

                view.camera = camera;



                addChild(view);



        }

        function initObjects():Void

        {

                _rc = new Cube(

                {cubeMaterials:cubedata,

                width:150,

                depth: 150,

                height: 150,

                rotationY:0.0 } );
                view.scene.addChild(_rc);
                spherecontainer = new ObjectContainer3D([_rc]);

                scene.addChild(spherecontainer);
                _matleft.addEventListener( MouseEvent.CLICK, Navigation1);
                _mattop.addEventListener( MouseEvent.CLICK, Navigation2);



        }

        function initLights():Void

        {

                //light = new DirectionalLight3D({x:1, y:1, z:-1, ambient:0.2});

                light = new DirectionalLight3D();

                light.x = 1;

                light.y = 1;

                light.z = -1;

                light.ambient = 0.2;



                scene.addChild(light);

        }

        function initListeners():Void

        {

                addEventListener(Event.ENTER_FRAME, onEnterFrame);

                Lib.current.stage.addEventListener(MouseEvent.MOUSE_DOWN,
onMouseDown);

                Lib.current.stage.addEventListener(MouseEvent.MOUSE_UP, 
onMouseUp);

                Lib.current.stage.addEventListener(Event.RESIZE, onResize);
                Lib.current.stage.addEventListener( MouseEvent.CLICK, 
Navigation1);
                Lib.current.stage.addEventListener( MouseEvent.CLICK, 
Navigation2);

                onResize();

        }

        function onEnterFrame(e:Event):Void

        {

                _rc.rotationY += 0.2;

                if (move) {

                        spherecontainer.rotationX = (mouseY - lastMouseY)/2 +
lastRotationX;

                        if (spherecontainer.rotationX > 90)

                                spherecontainer.rotationX = 90;

                        if (spherecontainer.rotationX < -90)

                                spherecontainer.rotationX = -90;

                        _rc.rotationY = (lastMouseX - mouseX)/2 + lastRotationY;

                }



                view.render();

        }

        function onMouseDown(e:MouseEvent):Void

        {

                lastRotationX = spherecontainer.rotationX;

                lastRotationY = _rc.rotationY;

                lastMouseX = mouseX;

                lastMouseY = mouseY;

                move = true;

                Lib.current.stage.addEventListener(Event.MOUSE_LEAVE,
onStageMouseLeave);

        }

        function onMouseUp(e:MouseEvent):Void

        {

                move = false;

                Lib.current.stage.removeEventListener(Event.MOUSE_LEAVE,
onStageMouseLeave);

        }

        function onStageMouseLeave(event:Event):Void

        {

                move = false;

                Lib.current.stage.removeEventListener(Event.MOUSE_LEAVE,
onStageMouseLeave);

        }

        function onResize(?event:Event = null):Void

        {

                view.x = Lib.current.stage.stageWidth / 2;

                view.y = Lib.current.stage.stageHeight / 2;

        }


        private function Navigation1( e: Event ):Void

       {

              var _callJasFunction= "callJavascript";
              var _myURL = "http://www.youtube.com/watch?
v=WjudEF7yobg";
              ExternalInterface.call(_callJasFunction, _myURL);


       }

         private function Navigation2( e: Event ):Void

       {

              var _callJasFunction= "callJavascript";
              var _myURL = "http://www.youtube.com/watch?
v=UxCAvK2wIEo";
              ExternalInterface.call(_callJasFunction, _myURL);

       }


        static function main()

        {



                Lib.current.addChild(new Essai_01());

        }



}



Il s'est produit une erreur de code ActionScript :
Error: Error #2136: Le fichier SWF 
file:///home/fab/Installation/AwayCube/essai_01.swf
contient des données non valides.
        at Essai_01/initMaterials()
        at Essai_01()
        at Essai_01$/main()
        at MethodInfo-1982()
        at flash::Boot()

Reply via email to