Reputation: 21
I was wondering if there is a way to make the actual stage dynamic to the content loaded in the flash file.
Firstly the method I am using is importing a external swf to the stage into a container called container. The main stage, lets call it index, is still on default size, and I want this to expand dynamically as content is loaded in.
page1 may be 900px width, page2 may be 500px width, and as I load the content the index stage should expand the width to that of the page loaded.
Some steps I have tried but did not work.
trace(container.p1_stage.height);
gives this error:TypeError: Error #1010: A term is undefined and has no properties.
at index_fla::MainTimeline/frame1()
Upvotes: 2
Views: 925
Reputation: 3581
The stage is already fully dynamic and will adjust its stageHeight and stageWidth properties automatically with content. What you want is for the container (usually HTML) to update with these changes.
Add a listener to the RESIZE event of the stage and call your javascript via ExternalInterface. You can pass it along the new height & width values and resize the container that way.
Just a note: be careful of resizing the body tag. In certain browsers, that will reload your SWF.
Upvotes: 0
Reputation: 4629
swffit will do this (sort of).
It doesn't actually resize the stage, it's a Javascript that resizes the SWF in the browser. You would call it through ExternalInterface from within Flash with the size you need when the new content is loaded.
Upvotes: 2
Reputation: 1149
The stage is a singleton in flash. When you add your external swf via addChild()
, its stage property
changes to the stage of the parent display object.
Moreover, you cannot change the stage width and height in actionscript code because they are read only parameters.
This problem was discussed here:
http://activeden.net/forums/thread/change-stage-width-height-just-with-actionscript/8854
http://forums.adobe.com/message/2705364
Upvotes: 0