0 Replies Latest reply on Dec 6, 2011 12:11 AM by Geri4Gears

    Help for a Designer


      I have a quad core imac with os 10.7.2.

      I am using Flash Builder 4.5 with the latest AIR sdk.

      I am trying to create an app that can convert and manipulate a collada file.

      Papervision, Flartoolkit and the ColladaAIR Viewer is installed in FB.

      I am using the code in Collada Viewer to design another air app.

      When I open the Main.as that came with Collada Viewer I get no errors.

      But when I copy it to my new src folder I get the following errors:


      1120: Access of undefined property (insert 100 properties from the Collada Viewer)


      I am embarrassed to say how long I have been working on this.

      Its seems as though it can not read the supporting collaviewer.as file.

      What do you do when your files don't access other files?




                This is the script source for the main mxml document called from script source

                (thus why it has no "packaging")




                All graphics, design, and additional programming by: Anthony Scavarelli - http://blog.anthony-scavarelli.com/

                Special thanks to:

                - Fuel Industries for the time to build this. http://www.fuelindustries.com/

                - The Papervision team for their wonderful Papervision classes

                - The Kingnare css and swf control styles by Jin Xin here: http://www.scalenine.com/themes/kingnare/Kingnare.html#

                - Pablo Bandin (http://pablobandin.wordpress.com), for the basis of an animation control class

                - and the many Papervision and Flex resources on teh interwebs for help with the set-up and many problems encountered building this app.


                This application is available for any use, or modeification. I would appreciate any feedback or comments on how you have been able to use it or modify it at it’s original source:



        //the slider controls

                import com.core.ColladaViewer;


                import flash.events.Event;

                import flash.events.MouseEvent;

                import flash.events.OutputProgressEvent;

                import flash.filesystem.*;

                import flash.net.FileFilter;







          public var _preloader:Class;


                protected var modelOpen:File = new File();

                protected var textureOpen:File = new File();

                protected var txtFilter:FileFilter = new FileFilter("Text", "*.dae;*.DAE;"); //opening models filters

                protected var imageFilter:FileFilter = new FileFilter("Texture", "*.jpg;*.png;"); //texture filters


                protected var _mFileName:String; //model filePath

                protected var _mTextureName:String; //texture filePath


                protected var _modelSelected:Boolean = false;

                protected var _textureSelected:Boolean = false;

        protected var _playButton:Boolean = true; //to keep track of switch from play to pause



                 protected var _mouseDown:Boolean = false;

                protected var _mouseOver:Boolean = false;

                protected var _mmDown:Boolean = false;

                protected var _mmCountXOld:Number = 0;

                protected var _mmCountYOld:Number = 0;

                protected var _mmCountXNew:Number = 0;

                protected var _mmCountYNew:Number = 0;

                protected var _mmDeltaX:Number = 0;

                protected var _mmDeltaY:Number = 0;


        //second xml window

                public var _xmlWin:XMLWin;

                public var _secondaryWinOpen:Boolean = false;

        public var _daeData:File; //holds dae data for viewing/saving

                public var _daeDataStream:FileStream = new FileStream();

                protected var _modelAnimated:Boolean = false;



        /*********************** initialization *************************/

        protected function init():void {

                          ModelColour.selectedColor = CollView.modColour;

                          WireFrameColour.selectedColor = CollView.wfColour;


        //setting up listeners for closing and minimizing

                          minCloseApp.addEventListener(MinClose.MIN_PRESSED, minApp);

                          minCloseApp.addEventListener(MinClose.CLOSE_PRESSED, closeApp);


        /*********************** end initialization *************************/



        /*********************** event functions *************************/


                protected function closeApp(e:Event):void {

                          minCloseApp.removeEventListener(MinClose.CLOSE_PRESSED, closeApp);




                protected function closeSecondWin(e:Event):void {

                          if (_xmlWin != null) {


                                    _secondaryWinOpen = false;




        //for dragging window

                protected function dragWindow(e:MouseEvent):void {




                protected function fileReadHandler(e:Event):void {

                          _daeDataStream.removeEventListener(Event.COMPLETE, fileReadHandler);


        trace("finished reading file");

                          var str:String = _daeDataStream.readUTFBytes(_daeDataStream.bytesAvailable);

                          var lineEndPattern:RegExp = new RegExp(File.lineEnding, "g");

                          str = str.replace(lineEndPattern, "\n");

                          _xmlWin.daeData.text = str;



                          _xmlWin.reading = false;



                protected function fileWriteHandler(e:OutputProgressEvent):void {

                           _daeDataStream.removeEventListener(OutputProgressEvent.OUTPUT_PROGRESS, fileWriteHandler);


        trace("finished writing");




                           _xmlWin.writing = false;



                protected function getStats():void {



                          Triangles.text = CollView.numTriangles.toString();

                          Vertices.text = CollView.numVertices.toString();

                          Num3DObjects.text = CollView.numVisSceneObjects.toString();

                          ScaleDiff.text = (round(((CollView.currScale * 100)/(CollView.AXIS_LENGTH)),3)).toString();



                protected function initLoadData(e:Event):void {

                          _xmlWin.removeEventListener(XMLWin.CREATION_DONE, initLoadData);







                 protected function interactiveMove(e:MouseEvent):void {

        //viewport camera rotations

                           if (_mouseOver && _mouseDown) {


        //if alt is pressed then can "track" or "pan" in case user has only one mouse button

                                     if (CollView.altDown) {

                                               _mmCountXNew = mouseY;

                                              _mmCountYNew = mouseX;


                                              _mmDeltaY = _mmCountXNew - _mmCountXOld;

                                              _mmDeltaX = _mmCountYNew - _mmCountYOld;


                                               CollView.moveCamera(_mmDeltaX/2, _mmDeltaY/2); //move camera

                                     } else {

                                               _mmCountXNew = mouseY;

                                              _mmCountYNew = mouseX;


                                              _mmDeltaX = _mmCountXOld - _mmCountXNew;

                                              _mmDeltaY = _mmCountYOld - _mmCountYNew;


                                               interactiveRotMod(_mmDeltaX, _mmDeltaY); //moving camera "orbit around model"



                          } else if (_mouseOver && _mmDown) {

                           //viewport camera movement x-y tracking


                                    _mmCountXNew = mouseY;

                                    _mmCountYNew = mouseX;


                                     _mmDeltaY = _mmCountXNew - _mmCountXOld;

                                    _mmDeltaX = _mmCountYNew - _mmCountYOld;


                                    CollView.moveCamera(_mmDeltaX/2, _mmDeltaY/2); //move camera




                protected function minApp(e:Event):void {




        //middle mouse functions

                protected function mmDown(e:MouseEvent):void {

                          EmptyBox.removeEventListener(MouseEvent.MIDDLE_MOUSE_DOWN, mmDown);

                          EmptyBox.addEventListener(MouseEvent.MIDDLE_MOUSE_UP, mmUp);


                          _mmCountXOld = mouseY;

                          _mmCountYOld = mouseX;


                          _mmDown = true;


                          CollView.camPanning = true;



                protected function mmUp(e:MouseEvent):void {

                          EmptyBox.addEventListener(MouseEvent.MIDDLE_MOUSE_DOWN, mmDown);

                          EmptyBox.removeEventListener(MouseEvent.MIDDLE_MOUSE_UP, mmUp);


                          _mmDown = false;

                          CollView.camPanning = false;



                protected function modelSelected(event:Event):void {

                           var _absPath:String = File(event.target).url;


                           LMText.text = _absPath;

                           _modelSelected = true;



                protected function mouseDown(e:MouseEvent):void {

                          EmptyBox.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDown);

                          stage.addEventListener(MouseEvent.MOUSE_UP, mouseUp);


                          _mouseDown = true;


                          _mmCountXOld = mouseY;

                          _mmCountYOld = mouseX;


                          if (CollView.altDown) {

                                    CollView.camPanning = true;

                          } else {

                                    CollView.camRotating = true;




                protected function mouseOutBox(e:MouseEvent):void {

                          EmptyBox.addEventListener(MouseEvent.MOUSE_OVER, mouseOverBox);

                          EmptyBox.removeEventListener(MouseEvent.MOUSE_OUT, mouseOutBox);


                          _mouseOver = false;



                protected function mouseOverBox(e:MouseEvent):void {

                          EmptyBox.removeEventListener(MouseEvent.MOUSE_OVER, mouseOverBox);

                          EmptyBox.addEventListener(MouseEvent.MOUSE_OUT, mouseOutBox);

                          EmptyBox.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);


                          _mouseOver = true



                protected function mouseUp(e:MouseEvent):void {

                          EmptyBox.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);

                          stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUp);


                          _mouseDown = false;

                          CollView.camRotating = false;


                          CollView.camPanning = false;

                          CollView.camRotating = false;



                protected function mouseZoom(e:MouseEvent):void {

                          CollView.cameraZoom(e.delta * 5);

                          CollView.camZooming = true;



                protected function reloadModel(e:Event):void {

                          if (_xmlWin != null) {





                protected function saveEdits(e:Event):void {

                          if (!CollView.animLoading) {

                                    _xmlWin.writing = true;


        CollView.releaseModel(); //remove references to model (will reload after write)


                                    _daeData = new File(CollView.modelDir);

                              _daeDataStream = new FileStream();

                                    _daeDataStream.openAsync(_daeData, FileMode.WRITE);


                                    _daeDataStream.addEventListener(OutputProgressEvent.OUTPUT_PROGRESS, fileWriteHandler);




      Thanks Geri