ActionScript 3.0 flex SWF metadata width and height - apache-flex

I have an actionscript, which makes a dynamic image wall. It gets parameters from FlashVar and changes the width and height dynamically.
When I use
[SWF(width="584",height="290")]
It's fully centered, but when I remove it, it's appear ~+50px from left.
How can I set dynamically the SWF metadata or what I need to set for the correct view?
Top of the picture with SWF tag and the bottom is without SWF tag.
alt text http://www.freeimagehosting.net/uploads/bbb4426bf0.jpg

You might want to try:
stage.scaleMode = "noScale";
stage.align = "TL";

Related

Dynamically set background-image-url

In my gwt-application i got a tree with a few images. These images can be copied by drag and drop to a panel. Now i want to make them resizable in this panel. when i test my css-code with a concrete image-path for "background-image", resize:both and background-size:cover works! My problem is, that i cannot set a concrete url to the css, becacuse the imagepath is dynamic.
when i delete background-image from css and set backgroundimage in my code, the surrounding container resizes, but the image not. Is it possible to set 'background-image' to the image that I choose during runtime? how can i solve that with css?
Thank you!!
You can set background image at any time in your code. For example:
myPanel.getElement().getStyle().setBackgroundImage("url(/myImage.jpg)");
To make it resizable, you need to apply the correct CSS to this panel. There are several CSS options for you to consider.

BitmapData with Scale9Grid

I have a Skin for SkinnableContainer.
Skin contains only the original contentGroup and s:BitmapImage as background.
Background image stretchers out according to width and height content.
The used image is .png with transparent regions.
To create hitarea, I used this algorithm:
http://www.webverwirklichung.com/en/blog/programming/flex/creating-hitarea-png-image-transparent-alpha-regions-flex
Everything's working fine until I start to stretch the SkinnableContainer (along with the image in the skin).
I have a scale9Grid for the image.
The problem is, that when stretching the image, the bitmapData of the image is still the same (same width and height). Therefore I need to somehow obtain the bitmapData of the image for the scale9Grid application.
The background of the component is an image, which has some transparent areas. It is only possible to click on the visible part of the image. The image will stretch according to the content in contentGroup.
Need an advice, please.
How about using the BitmapData.draw() method?
After the container is resized and the 9 slice scaling has been applied (or whatever the appropriate trigger is) do:
var b:BitmapData = new BitmapData(container.width, container.height);
b.draw(container);
Then use this new bitmap with the algorithm that creates the hit area.

Resizing container on resize of application window in Adobe Flex/AIR Application

I am working on an Adobe AIR Application. The size on Application window is 800X600 and is contains border container and border container contains many controls.
What I want is to if user re-sizes the application then that container should also be re-sized according to scale. i.e If user maximizes or minimizes the window then that border container should also be maximized or minimized respectively.
If you don't want to (or can't for some reason) use percentage based widths then you can always just do the following in MXML:
<s:BorderContainer
xmlns:mx = "http://www.adobe.com/2006/mxml"
xmlns:s = "library://ns.adobe.com/flex/spark"
width = "{parentApplication.width / 2}"
height = "{parentApplication.height / 2}">
You are just getting a reference to the component's parentApplication and directly binding to its width and height. Throw whatever math you want on the end.
An easier way to do this is to have your components declare their sizes/positions relative to their outer containers. For example, rather than setting x, y, width and height, set left, right, top and bottom in your Application component as well as the containers within your Application. If you want to enforce a minimum size of 800x600, you can set the minWidth and minHeight properties. Hope that helps.
This can be accomplished using an MVC framework. Some options include RobotLegs, Mate, Cairngorm or it is possible to use some quick design patterns and implement a custom version.
Essentially, the Application event Event.RESIZE should be detected and applied to the container. The properties of stageHeight and stageWidth will give the necessary info to resize the container.
Resize events will traverse the display hierarchy in any case, but it's convenient to intercept at the application level, should a custom event or function apply to the controls.

Flex: How to get the image size of an Image?

Give an Image component, how can I tell the size [width and height] of the bitmap image that the Image is containing (not the size of the Image component)
Also I want to know this as soon as possible, so I think this needs to be in the Event.COMPLETE event?
Thanks!!
Since Image extends SWFLoader, properties contentWidth and contentHeight are both publicly available. They are available on the "complete" event.
Accessing the Image's bitmap data might not be allowed if the Image is loaded from another domain.
The BitmapData class will give you the width and height properties.
This should be available in the
protected measure()
method, which you can override if you need to do things to it.

Increase the height of Flex Container dynamically and introduce scrollbar on the browser

I am trying to increase the height of container with increase in the number of contents inside the container.
Like in my case i m using tileList inside tabNavigator , when I put contents inside the tileList, the height of tileList does not increase
beyond vertical height of the viewport. It puts scrollbar on the container. I want to increase the height of an flex container with increase in the contents and introduce
scrollbar on the browser with increase in contents in the flex container.
Could anybody please suggest me how I could achieve this.
Thanks in advance.
You need to write a javascript function which increases the height of embed object and you need to call this javascript method from flex while adding a new item to tile list.
This link explains how to access javascript from flex.
Have considered using javascript and resize the element directly in the source HTML?
The JS code could look something like that:
function changeSize(id) {
var flex = document.getElementById(id);
flex.setAttribute("width", "800");
flex.setAttribute("height", "600");
}

Resources