Skip to main content
JEJoll
Known Participant
April 24, 2017
Answered

Resize flash stage to match contained external swf

  • April 24, 2017
  • 1 reply
  • 608 views

I've created a media player in flash which loads both flvs and swfs at runtime. It was originally designed to run at a fixed size, but I have a new requirement to have the player resize to fit the content.

Imagine the player is 1366x768 (for example), and the loaded media is 500x500. Currently the player will retain its size of 1366x768, and the loaded media will also stay at 500x500.

Now suppose that, instead, I want the player (and the window containing it) to fit itself to the size of the contents, so that in the above example, both the player and the content will be 500x500.

Essentially, what I would like to do is say something like

stage.width = myLoadedContent.width;

stage.height = myLoadedContent.height;

//Some math to reposition all of my UI elements, etc.

Based on my search results, and my own experimentation, stage height and width cannot be set at run time (and even setting the size of the document through 'Modify>Document...' does not change the size of the stage, as tracing the stage size gives numbers different than what I've set the document dimensions to).

Is there some way this can be done?

    This topic has been closed for replies.
    Correct answer Joseph Labrecque

    If you make a call out to a JS function on the parent DOM, you should be able to target and resize the Flash Player content whenever anything loads.

    ExternalInterface - Adobe ActionScript® 3 (AS3 ) API Reference

    1 reply

    Joseph Labrecque
    Community Expert
    Joseph LabrecqueCommunity ExpertCorrect answer
    Community Expert
    April 24, 2017

    If you make a call out to a JS function on the parent DOM, you should be able to target and resize the Flash Player content whenever anything loads.

    ExternalInterface - Adobe ActionScript® 3 (AS3 ) API Reference

    JEJoll
    JEJollAuthor
    Known Participant
    April 24, 2017

    Thanks for the reply Joseph.

    I'm not entirely sure I understand this approach.

    Based on what you've said, do these steps seem to make sense to you:

    1. Check the size of the loaded content (the external swf loaded into the player swf)
    2. Make an external JS call to resize my flash object
    3. Move my player controls based on the size of the loaded content
    Joseph Labrecque
    Community Expert
    Community Expert
    April 24, 2017

    Pretty much, yeah.

    • load content and make size determination
    • send this data to parent JS function in DOM to resize the container swf
    • adjust anything internal to container swf as needed