Using flash for cutscenes

Hey,

Has anybody tried to mix unity and flash?
I’m especially wondering not only about the case where you have unity and flash running next to eachother on the same page talking to eachother, but rather a scenario where we switch between unity and flash.

I’d like to say things in unity like:

StartFlashCutScene(“level4intro”)

, and have my unity dissapear, replaced by a flash movie. which at the end (or at mouseclick) switches back to unity. The same unity instance as before, not a reloaded unity instance.

I’m basically fishing for comments like “Don’t waste your time, we tried this it didn’t work”… or “works fine for me, stop complaining, get to work”.

Bye, Lucas

Hey Lucas,

I did something like this before (a long time ago, when Unity 1.6 was brand new). That was before there was video support in Unity, and I had a working solution to switch between showing Unity and the QuickTime plugin in the same browser window. Basically I used some JavaScript in the html to hide/show the plugin. The problem is (as all browser scripting), it requires a lot of testing and special casing, because some browsers are more equal then others.

There is a JavaScript (browser, not mono) function in Unity to hide the plugin, but it’s not guaranteed to work across all browsers. If it doesn’t work, you can resize the plugin rect to be very small.

I just dug up this hacked-together code snippet - not tested, but known to work at some point a couple of years back:

var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1);

function UnitySetSuspended(sus)
{
	if(isWin)
	{
		try {
			document.getElementById("UnityPlug").height=(sus==true?1:400);
		} catch(err){}
		try {
			document.getElementById("UnityObj").height=(sus==true?1:400);
			return;
		} catch(err){}
	}
	else
	{
		try {
			document.getElementById("UnityPlug").SetSuspended(sus);
		} catch(err){}
		try {
			document.getElementById("UnityObj").SetSuspended(sus);
			return;
		} catch(err){}
	}
}

function ShowVideo()
{
	UnitySetSuspended(true);
	document.getElementById("Video").style.display='block';
	showVideo=true;
}

function ShowUnity()
{
	if(showVideo)
	{
		showVideo=false;
		try{document.MoviePlug.Stop();}
		catch(err){}
	}
	UnitySetSuspended(false);
	document.getElementById("Video").style.display='none';
}

In the tag, I added id=“UnityObj”, in the tag id=“UnityPlug”

Then, in Unity, you can use Application.ExternalCall(“ShowVideo”); To get back to Unity, you’d need to call the ShowUnity function from Flash/JavaScript/whatever.

Hope this helps getting you started

Thanks a bunch jonas. We’ll use this for our initial test. If we need to update the code to make it work with 2008 browsers I’ll post back the changes here.

Bye, Lucas

You can also check out what our team members did here:
http://www.postopia.com//beeboy/game.aspx

There’s also this one:
http://forum.unity3d.com/viewtopic.php?t=10684

Cheers,
-Jon

Definitely possible by doing some iframe/div tag switching. Have one of each with the width/heights set to show or not show and use JavaScript (in-browser) as a communication bridge.