Skip to main content
Participating Frequently
May 31, 2012
Question

correct way to implement cache as bitmap to deeply nested movieclips? help!

  • May 31, 2012
  • 4 replies
  • 1025 views

I've been really stuck at this problem for a number of days and cant find any help online as to where im going wrong.

1119: Access of possibly undefined property CloudsNAnim through a reference with static type Class.

the setup as of now, there are 4 movieclips i want to cacheasbitmap. two copies of a vector movieclip called CloudS2 and two copies of one called CloudS4

those are in a movieclip holding them called CloudsNear and another movieclip holding that which holds an animation of the CloudsNear movieclip moving past the screen in a loop which is called CloudsNAnim

and that is inside the main level which is added to the stage called PlaneLevel

where do i place the cacheasbitmap lines in my code to load them into memory before I load the main movieclips

package

{

      // all my imports etc //

   

    public class MightyMend extends MovieClip

        {

        public function MightyMend()

            {

           

            // constructor code

            addChild(PLoading);                      //this loads my loading screen png to the stage

            stage.addEventListener(Event.ENTER_FRAME, loading); //reoccuring event listener happens as often as is set by FPS

            PlaneLevel.CloudsNAnim.CloudsNear.CloudS2.cacheAsBitmap = true;    

            PlaneLevel.CloudsNAnim.CloudsNear.CloudS4.cacheAsBitmap = true;     //these lines dont work

            }

       

        private var PLoading:Bitmap = new Bitmap (new PlaneLoading());       

       

        private var PLevel:PlaneLevel = new PlaneLevel();   

       

        public function loading(e:Event):void //

            {

            var total:Number = this.stage.loaderInfo.bytesTotal;

            var loaded:Number = this.stage.loaderInfo.bytesLoaded;

            var percent:Number = loaded/total * 100;

            trace (percent);

            if (total == loaded) //checks if all bytes for all movieclips have been loaded

                {

                stage.removeEventListener(Event.ENTER_FRAME, loading);

                onComplete();

                }

                 //the rest of the code staes that when oncomplete it will remove the loading screen and add the plevel to the stage etc..

This topic is closed to new replies. Start a new post to keep the conversation going.

4 replies

Colin Holgate
Inspiring
May 31, 2012

Try adding a var declaration:

public var PlaneLevel:MovieClip;

Because you don't have that, the compiler is interpreting your PlaneLevel lines as if PlaneLevel is a Class, and not a MovieClip.

DKNMSISAuthor
Participating Frequently
May 31, 2012

The movieclip is called Plane_Level but i had linked it to actionscript as a class nameed PlaneLevel

im not sure if that makes a difference but when iadded that declaration

the line :

private var PLevel:PlaneLevel = new PlaneLevel();

now gives an error

1046: Type was not found or was not a compile-time constant: PlaneLevel.

1180: Call to a possibly undefined method PlaneLevel.
Colin Holgate
Inspiring
June 1, 2012

You were meant to use the exact line I gave:

public var PlaneLevel:MovieClip;

That assumes it's a movie clip that is already on the stage. Is it? Or do you add it with code? Does the class file for PlaneLevel extend MovieClip?