[SWFObject] external interface problems

Geoff Stearns geoff at deconcept.com
Mon Oct 16 19:47:06 PDT 2006


getURL won't return anything, only calls that you make through  
external interface.

normally when i set up things like this, i set up the js functions in  
the html (or in a js file) and then just use external interface to  
call those functions, and that allows you to get return values.

it also makes it much easier to troubleshoot things, since you can  
put in alerts and whatnot to see where the script is failing.



On Oct 16, 2006, at 7:12 PM, Maurice Moore wrote:

> hmm.. now i remember.
>
> i couldn't work out how to return something to flash when i use geturl
> to invoke the cookie 'get' function. at the moment it returns the  
> value but
>
> return getURL("javascrtipt:getCookie('page');");
>
> wasnt returning anything.
>
> any ideas?
>
> maurice
>
> nyls wrote:
>> 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
>>
>> _______________________________________________
>> SWFObject mailing list
>> SWFObject at lists.deconcept.com
>> http://lists.deconcept.com/listinfo.cgi/swfobject-deconcept.com
>>
>
> -- 
>
> MaD Computing Solutions
>
> W: http://www.madcomputing.com.au
> E: info at madcomputing.com.au
> P: 02 4936 1782
> M: 0411 416 368
>
> ---
>
> The information contained in this email is confidential and is
> authorised to be viewed by the intended recipient only. If you receive
> this email in error please delete it.
> _______________________________________________
> SWFObject mailing list
> SWFObject at lists.deconcept.com
> http://lists.deconcept.com/listinfo.cgi/swfobject-deconcept.com




More information about the Swfobject mailing list