Possible to destroy a running game and then rerun it or run a different game - playn

I noticed that the PlayN doc says that you can only call Playn.run once. Here is my scenario and I'm looking for advice on how to tackle it.
Let's say I have a list of games to choose from in a menu on my web page. Upon clicking a game, I call PlayN.run on that game and it runs on my web page inside the playn-root div. Now lets say I want the user to be able to stop and load a new game by selecting a different one in the game list and load that into the div and play that.
How would I go about tackling that? Do I need to re-register the HtmlPlatform all over again and the play the new game? Or is there a way to destroy the current game and then play the new game using the existing platform which is already registered in PlayN?

The easiest route would be to just use normal HTML links and have each PlayN game be on its own web page (which could be in an iframe if you don't want the URL to change at the top of the browser).
Trying to clear out and reinitialize everything internally is just a big waste of effort when the web browser will take care of all of that for you when you reload the web page.

Related

Implementing back-forward in a Flex application

I'm responsible for a Flex application which shows cards/tiles. A click on each card sends a request to the server and then the Flex app renders new cards from the data returned from the server.
Now I need to add a back-forward functionality, so that after several clicks on cards, I will be able to return to the previous requests. As I understand it, I just need to save some kind of a stack of URLs which were sent to the server.
The need is for regular back-forward, so that if I'm viewing card X, then click back and then click on a different tile, I can drop card X from my data structure and forget it.
What data structure would you recommend using? Any examples?
Thanks.
Use SWFAddress and simply use the browser's back/forward functionality. Here's a video tutorial to get you started.

Web server instances?

Very newbie question, please forgive me:
I'm creating an asp.net website. I assume that when multiple people request the page each person gets a new instance of the site. However, if the site uses a .jpg image on the server and manipulates the image, does each person get an instance of the image also, or do they share the image somehow? I think I know, and that this is probably a dumb question, but I wanted to ask.
As an example: A user logs into the site, and adds times to a schedule. Depending on the schedule, a blue line is drawn on an image (grid.jpg), which depicts a daily timeline. The image is then saved as newgrid.jpg and displayed to the user. Is there a way for each user to get an instance of the image that only they can see?
A great way to generate dynamic images in ASP.NET is by using a Handler. The answer over here offers a good, simple example. In this scenario, the generated image never touches the local file system, it's just generated in memory, and returned to the client.
Well, usually the site is always the same for all users, but there are sessions created for each user with specific settings that you can set. So yes, all people will by default see the same changes (and the same content).

How can I stop the Flash privacy popup from occurring twice on a page?

My web-app records users via webcam and microphone. I want to use HTML/JS for the controls and content, so I created two separate Flex modules:
* A "Webcam Setup" module that lets you choose your camera and mic input devices
* A "record" module that lets the user record and submit the recording
When I embed either of these on the page, since they access the user's Camera/Mic object, Flash shows the Privacy dialog that says "[mysite] is requesting access to your camera and microphone. If you click Allow, you may be recorded."
The problem is, if I answer Yes in the Setup module, and later add the Record module to the page using Javascript, it again shows the Privacy dialog.
Is there a way to avoid the second privacy popup?
I would think that saying "Yes" for [mysite] would store that permission for at least that session, but apparently not.
What I've tried
I tried combining them into one SWF, adding it to the page once and moving the DOM element with jQuery's append() function when needed. When I move it, however, it reloads and asks me again.
Imagine if [mysite] was, say, blogger.com or livejournal.com (or, if it were still around, geocities.com). Would you want a "yes" response on that site to be good for every page under that domain?
Rememeber, just because you promise (cross your heart & hope to die) not to abuse the security hole you request, doesn't mean they can allow you to have that security hole.
Eventually, I found a usable workaround, similar to what I originally tried (above).
I combined the setup and record modules into one SWF. I first show the setup screen. When the user hits the Continue button on my page, Javascript calls a function in the SWF to swap to the Record screen.
I then move the <div> containing the Flash object to another location on page using absolute positioning, and resize the object.
Previously, I was trying to use jQuery's append() function to move the div within the DOM, and that was causing the SWF to reload. Just changing position and size does actually work.
You could build the "record" component to simply send and receive signals using an API you've created for your "setup" component (which has already been authorized, meaning one auth & two swfs) by using the LocalConnection class:
http://livedocs.adobe.com/flex/3/langref/flash/net/LocalConnection.html
This seems far closer to best practice than the other implementations mentioned, which smell a bit hacky and would probably confuse anyone who may inherit the codebase in the future.

Forcing Wordpress Header to not refresh on page load

I developed a band website using wordpress, and I placed a flash MP3 player that autoplays in the header. Whenever you click on a link, the entire page refreshes and the mp3 player starts playing the first song all over again. I wish to have the entire header including the mp3 player) stay constant while the content/sidebar/footer reloads when you click a link. That way the music will continue playing while the rest of the page loads, and the user can have a real listening experience.
To all of your knowledge, is there any way to do this without making the rest of the site completely dynamic?
Thanks in advance
There are acutally only two ways to do this without Ajax:
Use a frameset (which is a very bad idea nowadays)
Use a pop-up which holds the player
I know that pop-ups might be blocked, but this is the only way that users will accept. many large sites with audio players use pop-ups for such a functionality.

Synchronize flash video on multiple PC's?

For an event we need the following setup:
Multiple computers running a kinda of quiz (in asp.net). Every one of them plays a video as background (in the browser), sorta like a screensaver (with advertising). When moving the mouse a div pops up which allows the user to choose a quiz in fill out the forms. The catch is that the video needs to be synchronized on all the PCs.
These are the constraints:
The asp.net code is already there, so writing it completely in flash is no option.
We know .NET, javascript, html, the standard webdev stuff best, so investing time is something new is a last resort.
Any suggestions?
The way I see it, you have a couple options here:
1) Hack together synchronicity using a server-side timestamp passed to the Flash clients. Give the client the current time (server-side) and the time you want playback to begin (server-side, also). Then have the client wait that many milliseconds.
2) Configure your media server to stream the video as though it were a live feed. I am 90% sure this is possible with Flash Media Server, but I've never had the budget to manage my own video server.

Resources