Skip navigation
Currently Being Moderated

Error #2136: The SWF file

May 15, 2012 2:01 PM

I am trying to learn how to use classes.The book i am using gave me this example.





            import flash.display.MovieClip;



            public class Vehicle extends MovieClip{


                        public var _gasMileage:Number;

                        public var _fuelAvailable:Number;

                        public var _milesTraveled:Number =0;

                        public var _go:Boolean;


                        public function Vehicle(mpg:Number=21, fuel:Number=18.5){


                                    _fuelAvailable = fuel;

                                    this.addEventListener(Event.ENTER_FRAME, onLoop, false,

                                    0, true);


            public function onLoop (evt:Event):void{

                        if (_go){



                                    if (_fuelAvailable < 1){




                                    trace(this, _milesTraveled,_fuelAvailable);




            public function go():void{

                        _go = true;





In the main.fla

In frame 1


var vehicle:Vehicle = new Vehicle(21,18.5);




when I compile it gives an output error.


Error #2136: The SWF file file:///C|/Users/Ravenwind/Documents/Main.swf contains invalid data.

                at Vehicle/frame1()

I am stumped

  • Currently Being Moderated
    May 15, 2012 3:12 PM   in reply to jrk110

    If I recreate the files and scenario that would support what you show, it works fine.  Describe what you have done as far as creating/placing the files and the Vehicle object.

    Mark as:
  • Currently Being Moderated
    May 15, 2012 4:28 PM   in reply to jrk110

    " I then assign Vehicle to document class box in the property box" Do not assign the Vehicle as the document class... remove it from there. 


    In the main file, if you didn't already create one, create a movieclip symbol (just draw a shape in it for now).  Right click the symbol in the library and select the Linkage option.   In the interface that appears, select the option to Export for Actionscript, and assign it the Class name "Vehicle" in the field labeled "Class"


    Make sure you save the file after you put the code into it and have that file in the same folder as your Main.fla file.


    If you do the things I just described you should see an instance of the movieclip moving across the stage when you run the file.

    Mark as:
  • Currently Being Moderated
    May 16, 2012 6:52 AM   in reply to jrk110

    You're welcome

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points