How to create a new Window?

How do I make a new window in openfl ? If I can then how would I add content to it ?


Pretty sure you can do this with -Next.

Check this class, it contains code of window creation, and as you can see, it has windows array. So you can push your own windows into it.

I don’t think that’s complete just yet,
you can create another window and get events for it,
but rendering isn’t done as far as I know.

Though it is planned.

Did you want two windows, or are you asking about opening a single window? (like the default)

I wanted Two windows but I guess I’ll make two projects and use the Process class.

Okay, cool, yeah, this is planned – and the Lime API has been designed around it, but I haven’t actually gone and tried to create multiple windows to know if it works yet or if there are little things that need to be polished to support. Generally, though, you would create a new Lime “Window” instance, then call application.addWindow

Hello, sorry for making this back from the heart of the earth.

Is it possible actually in OpenFL ? I’ve make some tries but nothing look to really work.
The problem look like I can’t make the an OpenFL Renderer on the Lime Window.

But, I still try to make things work, I’ve planned to duplicate some fragment of the actual code, so I can keep you in touch about the Window addition part, if Iv’e find a way to do that. :smile:

I try as possible to use the heritage, to not make simple copy-paste, like that it would be more maintainable. :wink:

After many hours of searching, I’ve discovered that many things do a reference on the first window only, and the first render, so if we want to make a new Window, actually, it’s clearly impossible to keep the OpenFL comportment on, and we will have to use the Lime comportment.

It’s sad but it look like many things had to be rethink if we want more than one window on OpenFL. :confused:

I think the first step is making sure Lime is ready to support multiple windows, I have tried to lay this into the foundation, but haven’t gone through making sure it’s working.

If it works in Lime, then I’m sure that getting my OpenFL to work on two windows is possible.

I’m sure that Lime don’t correctly manage the Event on multi-windows. I’ve make some test and, we can’t know on whose window an event had be done. To manage a Mouse Event it can be really problematic.

But as what I’ve see, when Lime will support correctly the events for all the windows, it can be such a big deal to do, and this, without many work, because it’s generally just a question of reference on the Lib.current or things like that. :smile:

If somebody is interested or want to continue the research, there is a very particular Main who override many of the componenent of the Stage, and replace the used Stage of the application : [Pastebin link][1]

I’ve used an handmade DisplayObject there, who can be replace by a Sprite if you want. In fact, he just allow the access on the Graphics of an OpenFL DisplayObject.

I’ve try many ways, this is the last I’ve try, because add simply a Window doesn’t give anything, and all the drawing event was going on the first Window, I’ve speculated that make a new Application can be a solution.

I’ve not keep the twenty ways I’ve try, but this can give you a good root to test, if you want. :slight_smile:

I think that Lime will have to return a renderer, not a render context, so you can renderer.window and know which window you are drawing to

The first step is just a simple GL clear (or something similar) on each window, so we’re sure each is drawing separately, then input events can be tested to make sure they properly dispatch to the correct window only

After Lime is supporting multiple windows properly, we’ll have to make sure OpenFL can handle multiple stage instances

For the multiple stage instance of OpenFL, with what I’ve try, it work, it’s actually just a problem of connecting the Stage on a window. :wink:

I’ve successfully make an Application with two Module Stage the last time, and the two where rendering different things on the same window. :stuck_out_tongue:

So yeah, we have to wait for an update of Lime, because even if I make a Renderer for a window and use it to render on it, and successfuly make the Stage connected, the problem still the impossibility to say if the caught eventy is from the Window A or B, worth than that :

Taking a Mouse Pressed event Alpha, defined for Window A, and an other, Beta, defined for Window B, if I click on B, Alpha AND Beta are executed, not only Beta. :confused:

Hi there,
Sorry for reviving this once again ^^

Does anything new happened here?
I’ve found a reference in OpenFL 3.3.1 & Lime 2.6 changelog that a multi-windows support have been added, but I don’t seem to be able to make it work properly.

I’ve managed to create a new window using Application.current.createWindow, but it seems that anything I try to do with this new window makes my app crash (like adding any sprite or rendered object to an hypothetical stage there…)
Is there any subtleties when working with multiple windows ?

I’ve also come across the class, does that have anything to do with this issue?
The doc is rather scarse on these subjects… :confused:

I don’t use OpenFL but it works every well in Lime.
You just create it and add a new listener in window.renderer.onRender and its done.

Although there is not much documentation the API is well designed and the code is clean. You can get most of it by just sneaking around the source.

Hey @elFlashor I have same problem like you said app crashed.

@Hammeron, really? How does it look code example?

private var _win: Window

private function openWindowClick(evt:MouseEvent):Void
_win = new Window();
_win.renderer.onRender = winRenderer;

private function winRenderer(): Void
_win.title = “Window 2”;
_win.x = _win.y = 200;
_win.width = 500;
_win.height = 350;

Is it correct?

I can not understand I have tried… because error shows always Should be to Event_Void_Void What does it mean???

Please don’t hide us!

_win = new Window();
1 Like

Thanks for explanation I will try later.

It ends up looking something like this:

var secondWindow = new Window ();
application.addWindow (secondWindow);

Then when you get application render events, it will occur twice each frame (instead of once), once for each window.

If both should be OpenFL windows, instead, it would look more like this:

var secondWindow = new openfl.display.Window ();
stage.application.addWindow (secondWindow);

secondWindow.stage.addChild (...);