How to fix a text field width and height as well as its position when air window re-size in flash action script with air?
I am trying to use text field like as notepad editor area but when when i re-size adobe air window the text field property automatically adjust ,mean it change its position .
i want that when the width of air window re-size, text field should adjust its width according to adobe air window width .when the height of air re-size the text field should adjust it's height according to Adobe Air window height and text field position(x,y) should fix.
For controlling resize of components, in the beginning of application configure stage:
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
Subscribe for resizing of the stage, and implement resize of TextField:
stage.addEventListener(Event.RESIZE, onResize);
function onResize(e:Event):void {
//Implement logic, screen size is (stage.stageWidth x stage.stageHeight)
const padding: int = 20;
myTextField.width = stage.stageWidth - 2*padding;
myTextField.height = stage.stageHeight - 2*padding;
}
Related
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.
How to scale inside a clip?
I dynamically create a clip that simulates a window and calculate its width as
stage.stageWidth * my_window_width / my_scene_width;
inside the window, i need to create a square that must have a width, coordinate x, and so on, proportionally scaling according to the size of the window screen. Because if the size of the square is set pixel by pixel, then the sizes differ on different screens.
You could setting square w/h according to window size...
mc_window.square.width = (mc_window.width / 8); //square is eight times smaller
mc_window.square.height = mc_window.square.width; //set to "square" geometry
I create a clip that simulates a window:
window_bonus = new windowBonus;
window_bonus.x = stage.stageWidth * indent_to_x_to_photoshop / width_all_file_photoshop;
window_bonus.y = stage.stageHeight * indent_to_y_to_photoshop / height_all_file_photoshop;
window_bonus.width = stage.stageWidth * width_of_photoshop / width_of_all_file_photoshop;
window_bonus.height = stage.stageHeight * height_of_photoshop / height_all_file_photoshop;
I get a window like in figure 1.
Then I create another clip on the window - figure 2.
And on the device it looks like in figure 3.
I decided to create clips of containers that are not initially visible but they are installed on the window and therefore are scaled with the window,
Inside them already, I load the card image.
But my question is how to scale without containers,
using width, height, x and y
for a nested clip?
In my application, I am keeping so much of container with components. Now I have to create Fullscreen button for VideoDisplay. I tried some what like the followings
systemManager.stage.displayState = StageDisplayState.FULL_SCREEN;
And
this.stage.addChild(videoDisplay);
this.stage.displayState = StageDisplayState.FULL_SCREEN;
videoDisplay.width = stage.width;
videoDisplay.height = stage.height;
But no use.
Is any other way is there to do it?
If your app is going to fullscreen but your video doesn't then you should probably resize it using size of your full screen:
videoDisplay.width = stage.fullScreenWidth;
videoDisplay.height = stage.fullScreenHeight;
But since your video will probably deform when adjusting to different screen dimensions (3:4, 9:16 etc) you should resize only one side and adjust the other like this:
videoDisplay.width = stage.fullScreenWidth;
videoDisplay.scaleY = videoDisplay.scaleX;
Add the videodisplay object in a group and on fullscreen button click remove the video display from group and increase the group height and width according to screen resolution.
Then add the videodispaly object to the same group and set all the property like height = 100% width = 100% , etc
If its not working use videoplayer instead of videodisplay
I am having problem setting the stage height and width for the app i am developing.
I need to set the height and width as for the screen of the device it is on. So i do stage.fullScreenHeight and stage.fullScreenWidth.
But i just realized that the fullScreenHeight and width it is setting is the size for the stage inside flash pro cc under properties(the stage size).
And i am not able to make the stage width and height according to the phone's. Even if i do Capabilities.screenResolutionX; or stage.stageHeight. All of them set to either the size of the image, or the stage inside flash pro, but none is according to the device.
Edit:
E.g. var button = Button = new Button();
button.width = stage.stageWidth;
button.height = Button.width/stage.stageWidth * Button.height;
Try stage.scaleMode = StageScaleMode.NO_SCALE
or unchecking "full screen" checkbox in your Air settings
I need to scale an image with maintaining the aspect ratio in AS3. It should be scaled to the full stage size but nothing should be cut off.
How to do it?
Thank you,
Uli
Something like this should work:
// set the scale to fit the width of the image to the width of the stage
var scale:Number = stage.stageWidth / myImage.width;
// if the height of the image will be taller than the stage,
// set the scale to fit the height of the image to the height of the stage
if(myImage.height * scale > stage.stageHeight){
scale = stage.stageHeight / myImage.height;
}
// apply the scale to the image
myImage.scaleX = myImage.scaleY = scale;