[SWFObject] external interface problems
Maurice Moore
info at madcomputing.com.au
Mon Oct 16 07:35:07 PDT 2006
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
More information about the Swfobject
mailing list