Adding container controls programmatically and declare them in advance

I’m creating a Myst style demo game, basically you have front,left,right,back views which I’m using a page panel and canvas in a container… there’s an example here:
https://dl.dropboxusercontent.com/u/26539256/gamezep/Builds%20-%20gamezep.xojo_binary_project/Windows/zeptest/zeptest.rar
This works but if you click on the door you’ll notice a white flash also the notebook flickers
In other post someone said this could be down to the way I did the containers and the canvass that turn the page

At the moment in the demo the container controls are stacked and turned on and off when needed, from the previous post I saw its better to add them programmatically, the turn left and right hotspots have conditions so they turn the correct page in the correct container control, how do I define the control if it doesn’t exist until needed?
I thought I could do a property but this doesn’t seem to work
In the thread I saw (I wish I could remember were it was!) the containers were added to the workspace but off the window, but If I did a bigger game this wouldn’t be practical

I hope my rambling makes sense

To Programmatically add a container control you use the EmbedWithin method:

Here’s an example of where I create a new container control when a new page is added to a page panel control. In this case, I am using the EmbedWithinPanel method. It works the same way as EmbedWithin except it’s for page panel controls so you can embed the container into the page panel and not the window.

[code] Dim c as New CandCContainer(self)
//
c.EmbedWithinPanel(WallPanels,WallPanels.PanelCount-1,0,0)
//
me.value = WallPanels.PanelCount-1
ControlContainers.Append(c)
c.ContainerIndex = ControlContainers.Ubound
c.LockRight = True
c.LockLeft = True
c.LockTop = True

If Not me.closeBox(0) and me.Value > 0 Then
me.closeBox(0) = True
End If
[/code]

So you call EmbedWithin on the ContainerControl you want to embed. The structure is like:

ContainerControl.EmbedWithin(Window,[Left],[Top],[width],[height])

http://documentation.xojo.com/index.php/ContainerControl.EmbedWithin

Thanks Jon, I’ve got that bit
Is it possible to define

Dim c as New CandCContainer(self)

Globally so you can change the current container control?
What I was hoping to do is have each scene (the 4 views) as a single container and keep the left and right turns independent but I’d need to define each scene at runtime
I guess the other option is one big page panel with all the images, but is there a limit on pages?

[quote=139708:@nige cope]Thanks Jon, I’ve got that bit
Is it possible to define

Dim c as New CandCContainer(self)

Globally so you can change the current container control?
What I was hoping to do is have each scene (the 4 views) as a single container and keep the left and right turns independent but I’d need to define each scene at runtime
I guess the other option is one big page panel with all the images, but is there a limit on pages?[/quote]
Dim c as New CandCContainer(self) would work. But you would have to create a constructor and add a parameter that takes self.

[quote=139708:@nige cope]Thanks Jon, I’ve got that bit
Is it possible to define

Dim c as New CandCContainer(self)

Globally so you can change the current container control?
What I was hoping to do is have each scene (the 4 views) as a single container and keep the left and right turns independent but I’d need to define each scene at runtime
I guess the other option is one big page panel with all the images, but is there a limit on pages?[/quote]
I have a project where I can easily add lots of pages to my pagepanel.

[quote=139708:@nige cope]Thanks Jon, I’ve got that bit
Is it possible to define

Dim c as New CandCContainer(self)

Globally so you can change the current container control?
What I was hoping to do is have each scene (the 4 views) as a single container and keep the left and right turns independent but I’d need to define each scene at runtime
I guess the other option is one big page panel with all the images, but is there a limit on pages?[/quote]
It seems you are only limited to not going over the top. http://en.wikipedia.org/wiki/Graphics_Device_Interface#Limitations

Why are you using ContainerControls instead of a canvas that takes the images from a spritesheet?

[quote=139708:@nige cope]Thanks Jon, I’ve got that bit
Is it possible to define

Dim c as New CandCContainer(self)

Globally so you can change the current container control?
What I was hoping to do is have each scene (the 4 views) as a single container and keep the left and right turns independent but I’d need to define each scene at runtime
I guess the other option is one big page panel with all the images, but is there a limit on pages?[/quote]

First of all, the call:

Dim c as New CandCContainer(self)

is calling the constructor method on the container control which takes a parameter of the calling window. I store a reference to the calling window in the new container control. You may or may not need to do that.

What you can do is create 4 container controls in advance (or however many you need). That’s what the CandCContainer is for me.

Then when you need to embed that control, you just create a new Container control of whatever view you want and embed that into the window. It’s quite simple to do actually once you get your head around it.

Make sure you’re storing a weakRef to the window. Otherwise you may get a memory leak from the circular reference.

You know I was just thinking about that because of some of my other memory leak issues on my web project. But I’m a little foggy on how you store a weak reference when passed as a parameter. I haven’t been able to find good examples for it but maybe I’m looking in the wrong place.

Please educate me on this…

Start a new thread, and I’ll be happy to help. :wink:

The size of the sprite sheet would be insane also with it being 3D rendered by myself I do place holder graphics first so I can test easily and move stuff around if need be
It would be a lot easier in a game engine but where’s the fun in that?! The demo I originally did with Visionaire as a 1st person template

Thanks Jon and Greg, I think I understand