[SWFObject] external interface problems

nyls info at nyls.nl
Mon Oct 16 08:22:15 PDT 2006


mm.. so you write the JS functions through the external interface call .. 

Did you try putting the cookie javascript outside the flash (on the page or
in a .js file ??) 

Nyls








-----Oorspronkelijk bericht-----
Van: swfobject-bounces at lists.deconcept.com
[mailto:swfobject-bounces at lists.deconcept.com] Namens Maurice Moore
Verzonden: Monday, October 16, 2006 4:35 PM
Aan: swfobject at lists.deconcept.com
Onderwerp: Re: [SWFObject] external interface problems

hi and thanks for the replies,

the javascript is set from within the flash and is below (this is my 
first time at a mailing list and the format is all over the place, sorry).

the actual actionscript that calls the following class 'CookieBroker' is 
as follows

------------------
function GetPage(pageToLoad)
{
	if(pageToLoad == "/") { pageToLoad = "/?"; }
	var val = CookieBroker.GetCookie("page");
	if (val == undefined || (pageToLoad.indexOf(val) < 0))
	{
		CookieBroker.SetCookie("page", pageToLoad, "/");
		getURL(pageToLoad);
	}
}
------------------

then on(release) of the nav i call

on(release)
{
   _root.GetPage(_root.HomePage); // or _root.GetPage(_root.ContactUs);
}

// the pages are set as constants, so i can do the checking
------------------

<script type="text/javascript">
   // <![CDATA[
   var fo = new SWFObject("/swf/navigation.swf", "nav", "771", "75", 
"8", "#FFFFFF");
   fo.write('flash_container');
   // ]]>
</script>

and the .as file i include for the external interface is this

import flash.external.ExternalInterface;
/*
* CookieBroker Class to manage javascript cookies within the flash movie
*/
class CookieBroker
{
	//
	private static var write_cookie:String = "function set_cookie(name,
value, path) {  var cookie = name + \"=\" + escape(value) + \"; path=\"
+ escape(path); document.cookie = cookie; }";
	//
	private static var get_cookie:String = "function
get_cookie(cookie_name) { var results =
document.cookie.match(cookie_name + '=(.*?)(;|$)'); if (results) return
(unescape(results[1])); else return null; }";
	//
	private static var remove_cookie:String = "function
removeCookie(name){var cookie = name + \"=\";cookie += '; expires=Fri,
02-Jan-1970 00:00:00 GMT';document.cookie = cookie;}";
	//
	public static function SetCookie(name:String, value:String,
path:String):Void
	{
		ExternalInterface.call(write_cookie, name, value, path);
	}
	//
	public static function GetCookie(name:String):Object
	{
		return ExternalInterface.call(get_cookie, name);
	}
	//
	public static function DeleteCookie(name:String):Void
	{
		ExternalInterface.call(remove_cookie, name);
	}
}

when i run the page in FF there are no problems, but in IE i get three
errors.

1. 'nav' is undefined @ line 0
2. 'nav' is undefined @ line 0
3. 'nav' is undefined @ line 55

any ideas please?

regards,

Maurice
Click2Install Software



_______________________________________________
SWFObject mailing list
SWFObject at lists.deconcept.com
http://lists.deconcept.com/listinfo.cgi/swfobject-deconcept.com




More information about the Swfobject mailing list