2 Replies Latest reply on Mar 22, 2013 1:02 AM by xLite94

    Unable to get BitmapData.encode() to function - odd nonsensical compiler and runtime errors.

    Bramblethorne Level 1

      First... let me state that EVERY SINGLE STATEMENT REFERENCING THIS CLASS, ET. AL.,  is FULLY introspective when in the editor.   It will add the import statement if I haven't already added it.  It will autocomplete, etc.  Nothing is missing or misspelled, and the editor is fully aware that this class exists and how it is used. Doing a docs lookup on any of the terms (in the edit window) brings up the correct API reference in the help window.   It's only the compiler/runtime that complains, and usually, only the runtime.  I've cleaned and done every other little 'trick' I know of to overcome stupid errors that aren't errors.

       

      Based on web searches for this type of error:

      ReferenceError: Error #1065: Variable flash.display::PNGEncoderOptions is not defined.

      and

      VerifyError: Error #1014: Class flash.display::PNGEncoderOptions could not be found.

       

      ...I moved my actionscript code from the MXML component into an external class.  The only 'hint' I found from other contributors (and all on far older versions of the API) was that classes were not being declared public, so, even though I was using no class, but rather actionscript in a <fx:Script entity, I went ahead and created an external class.  To wit:

       

      [actionscript]

      package classes

      {

                import flash.display.BitmapData;

                import flash.display.PNGEncoderOptions;

                import flash.geom.Rectangle;

                import flash.utils.ByteArray;

       

       

                public class PngEncoder

                {

                          public function PngEncoder(bmpData:BitmapData, png:ByteArray, fast:Boolean)

                          {

                                    bmpData.encode(new Rectangle(0, 0, bmpData.width, bmpData.height), new flash.display.PNGEncoderOptions(fast), png);

                          }

                }

      }

      [/actionscript]

       

      This still provokes the following:

      ReferenceError: Error #1065: Variable flash.display::PNGEncoderOptions is not defined.

                at classes::PngEncoder()[D:\Dropbox\Work\PictureTools-OnTheMove\PictureTools-OnTheMove-MakeI t\src\classes\PngEncoder.as:12]

                at components::ChoosePictureButton/choosePictureLightboxClosed()[D:\Dropbox\Work\PictureTool s-OnTheMove\PictureTools-OnTheMove-MakeIt\src\components\ChoosePictureButton.mxml:165]

       

      It makes no difference what import statements I use.

       

      It makes no difference what form of reference I make, fully qualified "new flash.display.PNGEncoderOptions(..." or simply "new PNGEncoderOptions(..."

       

      It makes no difference if I create a public or private or protected var of type PNGEncoderOptions.

       

      It makes no difference if I instantiate and assign PNGEncoderOptions in the same statement where I declare the variable above the class, or if I instantiate it within the class constructor.

       

      It makes no difference which boolean value I pass to the PNGEncoderOptions constructor when instantiating.

       

      It makes no difference if I use the JPGEncoderOptions class instead.