Resize actionscript stage dynamically? - actionscript

i want to build a project base on actionscript3.and it needs to re-size its stage area to fit the the customer's web browser's viewing size or fit it when customer change the web browser's size.
There is no fixed aspect ratio but have a minimal(for example 640x480) size and a maximum size(1600x1000). when the customer's web window's length is less than the minimal size , a scroll bar would appear in that dimension ,so the user can see the whole stage using scroll bar .when customer's web window's size is larger than maximum size ,the flash application would appear at the top-center.and it needs to be working on most of the web browsers including IE 6.
when the stage size is changed ,the content on the stage wouldn't scale.in my case,the project has dozens of view,every view needs to handle size change and rearrange their elements, i thought this would be a huge work,so need any suggestion to build a project like this.

Firstly, the resizing will be managed by JavaScript / CSS, not ActionScript. That said, there are some things that you need to do in ActionScript to prepare for this behaviour.
Firstly, you mentioned that you don't want all of the content in the SWF to scale with the web page. To counter this default behaviour, you need to change the scale mode that the stage will use:
stage.scaleMode = StageScaleMode.NO_SCALE;
Another thing that I find makes scalable websites easier to work with is to set the top-left corner of the SWF to 0,0. By default if you scale up a SWF, 0,0 will remain in the same place with some 'padding' representing the new size. By that I mean, if you scale up the SWF by 200 pixels across and it was originally 400 pixels across, 0,0 will fall 100 pixels into the SWF from the left side rather than representing the top-left corner. Here's what you can do to correct that:
stage.align = StageAlign.TOP_LEFT;
These two things will help your embedded SWF act in a more expected manner which will likely help you throughout your project.
Finally, you mentioned that you have many viewable objects on the screen that need to react to the stage / browser window being resized. This is quite easy to deal with using Event.RESIZE. You can attach a listener to the stage to deal with this event and pass information across to each of your viewable objects reflecting the changes.
You can create a class that has a handleResize() method, which will be a base class for your view objects:
class ViewComponent extends Sprite
{
public function handleResize(width:int, height:int):void
{
trace(width, height);
}
}
Each of these objects can be listed within another class that manages the overall view, like this:
class ViewManager extends Sprite
{
public var viewComponents:Vector.<ViewComponent>;
public function ViewManager(stage:Stage)
{
viewComponents = new Vector.<ViewComponent>();
stage.addEventListener(Event.RESIZE, _manageResize);
}
private function _manageResize(e:Event):void
{
for each(var i:ViewComponent in viewComponents)
{
i.handleResize(e.target.stageWidth, e.target.stageHeight);
}
}
}
This way you can simply list your ViewComponents within the ViewManager and deal with each appropriately in it's own class by overriding handleResize().

Related

Konva object snapping with transformer jitters

I'm trying to make an editor using Konva.js.
In the editor I show a smaller draw area which becomes the final image. For this I'm using a group with a clipFunc. This gives a better UX since the transform controls of the transformer can be used "outside" of the canvas (visible part for the user) and allow the user to zoom and drag the draw area around (imagine a frame in Figma).
I want to implement object snapping based on this: https://konvajs.org/docs/sandbox/Objects_Snapping.html. (just edges and center for now) However I want it to be able to work when having multiple elements selected in my Transformer.
The strategy I'm using is basically calculating the snapping based on the .back element created by the transformer. When I know how much to snap I apply it to every node within the transformer.
However when doing it, the items starts jittering when moving the cursor close to the snapping lines.
My previous implementation was having the draw area fill the entire Stage, which I did manage to get working with the same strategy. (no jitter)
I don't really know what the issue is and I hope some of you guys can point me in the right direction.
I created a codepen to illustrate my issue: https://codesandbox.io/s/konva-transformer-snapping-1vwjc2?file=/src/index.ts

Jung: prevent user from moving a vertex outside the Visualization size?

When in picking mode, I want to limit the user from dragging a vertex outside of the defined layout bounds. I've set the ISOMLayout, VisualizationModel, and the VisualizationViewer to be the same size. But if I zoom out (I'm using a CrossoverScalingControl) I can drag vertices way outside the layout/vv's bounds. This results in the scrollbars of my GraphZoomScrollPane not working as expected: there can be vertices floating out there that you can't scroll to and you have to zoom out to see them.
Surely there's a way to lock the user into a certain boundary?
Dimension preferredDimension = new Dimension(1200, 800);
Layout<CNode,CEdge> layout = new ISOMLayout<>(graph);
layout.setSize(preferredDimension);
VisualizationModel<CNode, CEdge> visualizationModel = new DefaultVisualizationModel<>(layout, preferredDimension);
vv = new VisualizationViewer<>(visualizationModel, preferredDimension);
If you want to set a boundary outside which you can't manually move a vertex, you can do that in your code (specifically, in the part that responds to you dragging a selected vertex; you can specify limits there on how far out you can drag a vertex). It's not JUNG's responsibility to prevent you from setting a vertex location to something that the Layout wouldn't use; as far as the JUNG is concerned, you can do that if you want to. :)

how can i set kivy widgets position platform independently?

I'm writing an application with kivy that scans a network and based on results it generates bunch of widget like labels and buttons or maybe a layout like Gridview.
I'm trying to position them by pos or center_x and center_y attributes. I can position them perfectly on my laptop but when I try my tablet or other devices with different screen sizes everything goes wrong and all widgets change their position.
My question is:Is there a elegant way to position widgets and layouts that pertain their position on any screen size?
P.S:
it's not working even when i maximize the window.
You have many different options here like::
Query the Window size and position your widget relative to the window using percentages instead of absulute values.
Use specific layout that fits the positioning style you need for you widgets.
Recomended
Use pos_hint in combination with your layouts
specify the widget pos using kivy.metrics.dp which gives you device independent pixels or use metrics.sp/cm/mm/in/...

Flash/ActionScript: How to center smaller swf when loaded in a larger one?

I am making an interactive storybook project given these specifications:
My book has 13 pages, where 1 page = 1 swf loaded externally into the book swf. As you can see, the page swf must be centered in between the 2 buttons that are both 100x450 each. Whenever I try to load the swf, usually it's cut off at some point.
In short, how do I center my externally swf when loaded?
Make the completeHandler Function like given bellow
function completeHandler(event:Event):void{
this.container.addChild(event.target.content);
this.container.x = this.stage.stageWidth/2 - event.target.width /2;
this.container.y = this.stage.stageHeight/2 - event.target.height /2;
}
U can change this.stage.stageWidth with the center container width and apply same for width also
The advice gyandas gives is good. However, from the way you've worded your question I'm guessing you're already doing something along the lines of what he suggests. If so, you could try adding a filled shape of 520x450 as the background of each of your pages. You can set the alpha to 0 or match the background color of the book itself, but the important thing is to have some actual content of the required dimensions rather than relying on the supposed width of the SWF when centering it in another movie.
I'm not in a position to test this right now, but I seem to recall that the dimensions of a loaded SWF are calculated according to the bounding box created around actual content, and that I have resorted to doing this as a result.

jquery Image slider without define width?

I have used the coin slider.But the coin slider is restricted by the width.I need to run my application in various screen size like 1280*768,800*600.is there any image slider in jquery without restrict width of image?Please help me.
Thanks in advance.
Most image sliders are designed for being placed within a container of a certain width, so that they fit within a specific slot in a layout. Given that the size of the screen/window(you don't specify) is irrelevant to that, it seems like what you're looking for is a gallery that adapts to the size of the entire window, rather than fit within a specific size.
You should probably widen your search to JS galleries in general, which might have that option or even function that way in the first place. As initial suggestions, have a look at the full-screen example for Galleria, or maybe the Supersized plugin

Resources