Jump to content
Search Community

Unable to use LiquidArea from document class

danissimo test
Moderator Tag

Recommended Posts

for

var flowingStage:LiquidStage = new LiquidStage (this.stage, 1024, 768, 1024, 768);

there's an error:

Access of possibly undefined property stage through a reference with static type Class.

for

var flowingArea:LiquidArea = new LiquidArea (this, 0, 0, 1024, 768, 0x666666);

there's an error

Implicit coercion of a value of type Class to an unrelated type flash.display:DisplayObjectContainer.

How should I point to main timeline and stage from doc class correctly?

Link to comment
Share on other sites

Does your document class extend Sprite or MovieClip or some other DisplayObjectContainer? It must (that's a Flash requirement, not LiquidStage).

 

As for accessing the "stage", keep in mind that a DisplayObject's "stage" property will be null until the DisplayObject is added to the display list (like if you addChild() it to a Sprite/MovieClip that's on the stage). Again, that's just a Flash thing. You can sense when it is added by using an Event.ADDED_TO_STAGE listener. For example, in your document class's constructor you could do:

if (this.stage) {
   init(null);
} else {
   this.addEventListener(Event.ADDED_TO_STAGE, init);
}

function init(event:Event):void {
   this.removeEventListener(Event.ADDED_TO_STAGE, init);
   //NOW WE KNOW this.stage IS NOT NULL
   var flowingStage:LiquidStage = new LiquidStage(this.stage, 1024, 768, 1024, 768);
}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...