Sravan0313
Sravan0313

Reputation: 83

Changing the Stage size during runtime in AS3

Can we change the stage size during runtime?

I need to change the size of the stage dynamically during the runtime when the swf receives a flashvar from the html page. Can this be done?

Upvotes: 0

Views: 3387

Answers (2)

dick_claus
dick_claus

Reputation: 26

It's possible using flash.external.ExternalInterface

if (ExternalInterface.available) {
    ExternalInterface.call('JSResizeBlockFunction');
}

JSResizeBlockFunction should be a javascript function defined on top level on the same page as running swf.

In this function you should change size of div in which <object>/<embed> is wrapped. But your swf on page should have size in percents to receive RESIZE event.

Upvotes: 0

Marty
Marty

Reputation: 39458

If you resize the <object> / <embed> elements in your HTML, that will resize the stage of the SWF.

The content of the SWF however will scale unless you specify that there will be no scaling within AS3:

stage.scaleMode = StageScaleMode.NO_SCALE;

It is also important to note when working with scalable SWFs that by default, the exported stage dimensions will always sit centred within the resized area, e.g.

enter image description here

I find it easier when everything is measured from the top-left of the resized area, which can be done by adding this as well:

stage.align = StageAlign.TOP_LEFT;

Upvotes: 3

Related Questions