How to preserve the size of children movieclips in a fluid scrollPane in AS3? - actionscript-3

I'm working on an AIR desktop project.
I have a scrollPane with a container assigned to it...
mainScrollPane.source = mainContainer;
The scrollPane is resized whenever the window is resized, in order to keep things fluid (it fits under a header container, and to the right of a left container)...
mainScrollPane.setSize(Math.round(stageWidth - leftContainer.width), Math.round(stageHeight - headerContainer.height));
mainScrollPane.source = mainContainer;
I'm dynamically creating movieclips and adding each one to the container...
mainContainer.addChild(boxMC);
In my library, boxMC is set to 400 pixels wide, yet I'm finding that each boxMC is displayed much wider than that.
When I resize the window, each boxMC doesn't scale in size (good).
I'm clearly not understanding the process for creating a fluid scrollPane that can be resized while having it's contents remain the size that I've created them at in the library. Can sometime please enlighten me?
Thank you.

The solution was not to give mainContainer width and height settings. So instead of mainContainer.graphics.drawRect(0,0,100,100); mainContainer.width = 500; mainContainer.height = 200; I just made it mainContainer.graphics.drawRect(0,0,100,100); then added movieclip don't scale their size when mainScrollPane is resized.

Related

find out new image width height after browser window resize

i have an image and i have placed markers on it.
problem is that when the browser window resizes, the image size also changes and thus the marker comes to a different position than where it was before.
so, i want to find out the new positions and dimensions of the image after the browser window size changes.
I want to find out the new dimensions of the image, but nothing has worked till now.
i have used clientWidth , offsetWidth, naturalWidth and it all shows the same width before and after the window resize.
(I actually have a zoom property too and it shows the same width even after using zoom), so I am not sure what's wrong?
how do I find out the new image height width and positions after it is zoomed or after the browser window size is changed?
Trigger an event on window resize and find the image height
window.addEventListner("resize",function(){
var img = document.getElementById("img1");
console.log(img.clientWidth);
}

AS3 : Create a responsive mxml resize bitmapimage which resizes according to browser

I have a simple bitmap image 3px wide and 150px high included as the top banner in my layout.
<s:BitmapImage id="blueBanner" source="{this.bmpimg}" width="100%"/>
The rest of the content is centered below this.
When the page opens no matter the size of the browser window, the image always fills the width available.
I have a browser window resize handler that resets my main content below the banner to the center of the new window size and this works perfectly.
But no matter how many times the browser is resized, the BitmapImage will never stretch wider than the original window width.
I have tried every property and method of BitmapImage that I think could affect this in the resize handler but nothing I can find has any effect at all.
I cannot understand how it remembers the original stage width to begin with.
Its parent containers are all set to 100% width and there are no unusual skins or any other reference to this object in the whole project except in a function where it can be included in the layout or not, but this function is never called in this case.
Can anyone offer any clue as to why it won't stretch automatically?
Doug
Simple , just set the width to screen.width and you are good to go.
<s:BitmapImage id="blueBanner" source="{this.bmpimg}" width="{screen.width}"/>
Thanks for all the responses. In fact I solved the problem by adding the BitmapImage line to the Application Skin. Once it's here as well as in the layout it works. I have no idea why it needs to be in both places, but once it's set up like this everything works correctly.
Setting ScaleMode makes no difference and setting screen.width either in the blueBanner tag or later in the resizeHandler (because not always available when the tag is run) also makes no difference in my layout.
Doug

How to make flash animation responsive

i'm starting to build this bootstrap site where I have flash animation on my fontpage. --> http://testi9.aada.fi/index.php?cID=180
My animation size is 1472px x 485px. Now I want it to be 100% width on bootstrap site so that it would strech nicely on different screen sizes.
I added this css code on bootstrap css file:
#swfcontent169 {
border:solid thin #f00;
width:100%;
}
Now my flash animation is 100% but somehow those "symbols" that are
on my flash animation on each side are visible too and animation is not stretched as i would like it to be (full width).
Can someone help me out with this?
// Mika
You need to set the proper scaling mode for the flash object. (the scale embed property) or stage.scaleMode through AS3 code.
Here is a visual rundown of the options: (you will likely want exact fit or no border)
Let's say this is your document:
We have four boxes (one per corner), and some gray boxes that are off the stage.
Here are you options:
Show All:
Show all scales the content so the whole stage fits, but then you get a gutter if it's not the right size and objects off stage may be visible.
No Border:
This will scale it so the whole content will fill the bounds (keeping aspect), but then if it's not the exact size, you'll get cropping of the stage, see how the boxes are being cropped on the top bottom? You can change the way it aligns the cropped stage with the stageAlign property.
Exact Fit
This will just make the whole stage fit in the area defined, but it will not honor your aspect ratio and things could looked squished/stretched.
No Scale
This won't scale the stage AT ALL. So if the defined area is smaller than the stage, it will crop it, if larger, you'll get gutters.
You probably want exact fit or no border - depending on if you need the aspect ratio to be fixed. You can also use no-scale and use code to align your contents the way you want.
You can align the content several ways too using the align embed parameter.
You can adjust these in your embed code. There are also options in the FlashPro publish settings (when you click on the HTML Wrapper Format), or you can use an online tool like: http://embed-swf.org/embed-swf.php

AS3 EXACT_FIT Creative Work Around?

I want my background image to fit the screen of the device. I have tried the basic code below
BG.height = stage.stageHeight;
BG.width = stage.stageWidth;
This works however, I have to choose EXACT_FIT to get it to fill the screen on different devices. THE ISSUE IS MY OTHER CONTENT GETS STRETCHED. I am wondering if there is a creative way to stretch the background using EXACT_FIT and then load in new content and find out how much the content has been stretched and reduced it to normal height and width.
In short looking for ideas or best ways to have access to full screen of device without having to stretch my content to funny proportions.

resizing widget in pygtk

I have a scrolled window, which contains a drawing area in pygtk. I would like to change the size of the drawing area, and keep the scrolled window as it is. I don't find a function that works on widgets. I can get the size and so on, but I can't set it. Could someone give me a pointer to the solution?
Thanks,
v923z
It sounds like .set_size_request() is what you need. An example would be:
drawingarea.set_size_request(400, 400)
The values are the width and height of the canvas. Assuming you're ScrolledWindow is setup correctly, the scrollbars should adjust automatically to the size of the DrawingArea.