How to modify the size of Flash stage programmatically - actionscript-3

Initially I set the stage width 500 and height 400. After make a file, now I want it to be 700*500 and I want to show all content in stage. How can I achieve this?
Any help will be appreciated.

If it's a website you're creating you can programmatically control its size via call through a class called ExternalInterface which in turn calls JavaScript-functions. JavaScript can then be used to resize the embedded flash object.
You can find another post about this here: How can I resize a swf during runtime to have the browser create html scrollbars?

Related

it is possible to change the width and height of an swf with AS3 onclick event?

it is possible to change the width and height of an swf with AS3 onclick event ?
see image : change the width and height of an swf with AS3
Not if you are targeting FlashPlayer. From your comments it looks like you want to build a standalone application.
Target the Adobe Air runtime for that. It is meant to b a standalone application that's not embedded in a website. It provides access to additional features, such asNativeWindow.

how to make existing flash file responsive

I have e learning books in flash file(.swf format) and i want to make it responsive.Can any one suggest a solution for this.please refer the link flash file
If you open the raw swf files in a browser, you can see that they are already responsive by default: http://rtpublishers.com/data/Hindi/Book1/pages/page1.swf
So, you need to change the way the Flash is embedded in your html page. Where you are using fixed 1300 x 900 pixels dimensions, use percentages instead.
In your Flash file, you can set the stage scaleMode = StageScaleMode.EXACT_FIT as explained here:
http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS0D75B487-23B9-402d-A52D-CB3C4CEB9EE4.html
If there are parts of the Flash that you want to scale differently depending on stage size, you can listen to the stage RESIZE event, and respond accordingly.

Resize External swf

I'm writing an android app in flex as I need to display swf animations.
These swf files are larger than the mobile screen - they're advertisements used elsewhere.
I don't seem to be able to resize the loaded swf file. I've set height and width on the container, the loader everywhere I can think of and nothing changes the size of the swf.
It's frustrating, the swf is of a set size as they display full screen when used as advertisements, I just want to show a small preview within the app of what they will look like.
I'm beginning to think that it cannot be done? or am I missing something
I've seen similar questions asked here, but no answer that works for me.
There is only one stage, and the loaded swf probably resizes itself according to the stage dimensions, so it ignores the properties of the loader.
If you can modify the code of the loaded swf, you can:
either add it a method like setSize(width, height), and invoke it from the main swf:
yourSWFLoader.content.setSize(width, height);
or access to the loader dimensions from the loaded swf, using something like:
width = parent.parent.width;
height = parent.parent.height;
The second solution assumes the SWF is loaded from a trusted domain.

flex is not able to find the Screen class [duplicate]

Can I get the obtain the size of the browser window in AS3?
The best method I've found is to get the size with Javascript and send it to Flash as a FlashVar. One limitation of this method is that it doesn't give the current size if the window is resized.
Is there a pure Flash way to do this?
If you embedd your swf with height: 100%; width:100% you could use stage.stageWidth and stage.stageHeight. If this is not the case you could implement a communication with JavaScript by using ExternalInterface.
It depends if you are trying to set your swf to fullscreen, or simply obtain window dimensions for some other purpose.
If you are doing fullscreen, you need to set your stageScaleMode to NO_SCALE, and embed your flash object into a div that has its height and width parameters set to 100%. To deal with resizing, your flash project needs a resize event listener (applied to the stage), and all display objects need to respond to that resize listener. Once your swf is resizing properly, you can, as already noted, use stage.stageHeight / stageWidth to retrieve exact dimensions internally.
If, on the other hand, you just want to obtain the dimesions of the window, you will need to use ExternalInterface to make a javascript call. jQuery has some nice tools for quickly obtaining screen dimentions. Then its just a matter of sending that data back into flash. Remember that javascript has a resize event, as well, and that you can use it to force state changes in flash.
You're correct in the initial piece of the sequence - sending flashvars in on load, but to respond to screen size changes, you will need to apply one of these techniques.
Good luck

How do you make a SWF resize inside a HTML page?

The stageHeight and stageWidth are read-write properties of the Stage class.
Is there any way to embed the swf so that when you set them to a different value, this is reflected in the HTML page? Possibly without calling a JS function via ExternalInterface to modify the embed's parameters?
The main idea is that I don't know what size my swf will be. I'm loading a video inside it and I want to resize the swf to match the size of the video.
We use
http://code.google.com/p/swfobject/
which allows for auto resizing in addition to some other nice features.
Your definitely going to need to call a JS function, the good news is it's really simple code, something like this:
function resizeIt(height)
{
document.getElementById("myDiv").height = height;
}
Using SWFObject in this case you can set the width and height to be 100%, so it'll resize with the containing DIV, so you're not modifying the embed paramerters, but just the css.
To my knowledge you can't do that. I can't actually fiddle around with it, 'cause i currently don't have access to flash.
It could work if you would insert the swf into a div, or whatever, that's "too big" for it in the first place, and then just try and resize it. What are you using to embed the swf, the basic thingie offered by the Flash IDE or something else, like swfobject?
I don't know, you might have to actually use ExternalInterface or something like that to get the job done. And if it's not terribly important to work the player into your web layout, i would just implement the whole thing in the flash movie.