Skip navigation
DKNMSIS
Currently Being Moderated

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

May 31, 2012 10:22 AM

Tags: #flash #ios #cacheasbitmap #movieclips #cs6

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..

 
Replies
  • Currently Being Moderated
    May 31, 2012 10:32 AM   in reply to DKNMSIS

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    May 31, 2012 5:09 PM   in reply to DKNMSIS

    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?

     
    |
    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