Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
super_fan

LiquidStage resize event [SOLVED]

Recommended Posts

elsewhere on the forum, Jack posted...

 

Also, you can add an event listener to LiquidStage to listen for when it resizes things and then you can run any code you want (like adjusting the scale of an object so that it's proportional). Just do:

 

LiquidStage.addEventListener(Event.RESIZE, myFunction);

 

...and so I've been hoping to use that to trigger some code I found elsewhere on the web to fill the stage with a repeated bitmap as a background.

 

however, one obviously has to learn to walk before they can run, and I'm having problems running even a basic test function from the resize listener, so if anyone point out what I'm overlooking in getting the following working, hopefully I can apply it to other functions and not have to bother anyone again. :)

 

import gs.utils.*;

function flagit(){
trace("resized");
}

LiquidStage.init(this.stage, 550, 400);
LiquidStage.pinObject(RectangleForBackground, LiquidStage.TOP_LEFT);

LiquidStage.addEventListener(Event.RESIZE, flagit);

 

the pinned object is just there to make sure that LiquidStage is actually doing something; it's the triggering of the flagit function when the stage is resized that's the important bit.

 

this is the error I'm getting...

 

ArgumentError: Error #1063: Argument count mismatch on GS_fla::MainTimeline/flagit(). Expected 0, got 1.

at flash.events::EventDispatcher/dispatchEventFunction()

at flash.events::EventDispatcher/dispatchEvent()

at gs.utils::LiquidStage$/update()

 

thanks.

Link to comment
Share on other sites

further experimentation reveals that the LiquidStage resize event handler is passing the following parameter to the function called...

 

[Event type="resize" bubbles=false cancelable=false eventPhase=2]

 

...which I discovered with the following code:

 

import gs.utils.*;

function flagit(unknownparam){
trace(unknownparam)
trace("resized");
}

LiquidStage.init(this.stage, 550, 400);
LiquidStage.pinObject(RectangleForBackground, LiquidStage.TOP_LEFT);

LiquidStage.addEventListener(Event.RESIZE, flagit);

 

so am I correct in thinking that so long as I include a parameter in the definition of the function I want to call, and then just ignore it, that's the best way of dealing with resize events?

 

thanks.

Link to comment
Share on other sites

  • 2 weeks later...

Yep, event handlers will always receive an Event object as an argument. The function you wrote initially, however, didn't accept any, so Flash burped. You must tell the function to expect a parameter. It's fine if you don't use that Event object anywhere inside your function though. Just make sure your function is allowing it to be passed in, that's all.

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