Array
AS2 to AS3 migration problems [Archive] - FlashMove Forum

PDA

View Full Version : AS2 to AS3 migration problems


0gani
10-09-2006, 03:07 PM
import flash.external.ExternalInterface;
var cookieValue: = ExternalInterface.call("myGetCookie", "yumyum");
if (cookieValue==1) {this.gotoandplay(15)}


This worked perfectly in AS2. But these people have compeletly changed everything with AS3. I get all kinds of errors in AS3. Any help on how to code this right in AS3?

ReferenceError: Error #1056: Cannot create property ::cookieValue on global.
at Timeline0_e48252b3c782d46a9f429a26c25bf69/::frame5()

The ExternalInterfaceCall is calling a javascript which gets a cookie called yumyum.


Please help...

Scottae
10-09-2006, 03:54 PM
Looks like you screwed up. Nothing to do with AS 2.0 to AS 3.0, it's user error. You have a colon after your variable name with no type after it. If you either get rid of the colon or put the correct data type after the colon, then you should get no errors.

import flash.external.ExternalInterface;
var cookieValue:Object = ExternalInterface.call("myGetCookie", "yumyum");
if (cookieValue==1)
{
this.gotoandplay(15);
}

P.S. Please use AS tags (http://flashmove.com/forum/flashhelp.php) for code....thx.

[PAUL FERRIE]
10-09-2006, 07:43 PM
I spoted that aswell :D

0gani
10-09-2006, 08:13 PM
here is the modified code...
I was given further advice by other people but the code is still not working...

here is the AS3



import flash.external.ExternalInterface;

var cookieValue:* = ExternalInterface.call("myGetCookie", "yumyum");

hello_txt.text = String(cookieValue);





here is the javascript


<script language="javascript">
function myGetCookie(boo)
{
alert(boo);
return boo;
}
</script>


I get the this output on screen "null"

on this page
www.myoperators.com/useless/bootycow.htm (http://www.myoperators.com/useless/bootycow.htm)

Please help

Scottae
10-09-2006, 08:32 PM
Oh yeah, I know what you mean. I've seen that too. You are wanting to get the object reference that flash.external.ExternalInterface.call method supposedly returns. It does seem to work in Firefox, but not in IE. A lot of fat good that does since a lot of people use IE. Don't know what you can do about that. So why do you need that reference anyway?

0gani
10-09-2006, 08:37 PM
I tried this code




import flash.external.ExternalInterface;

if(ExternalInterface.available)
{
trace(ExternalInterface.call("myGetCookie", "yumyum"));
}
else
{
trace("ExternalInterface is not available");
}




I get this result
www.myoperators.com/useless/b.htm (http://www.myoperators.com/useless/b.htm)

The flash never fully loads.... it is just loading for ages... any ideas people ?

Scottae
10-09-2006, 08:43 PM
Check out this thread (http://flashmove.com/forum/showthread.php?t=23369)

0gani
10-09-2006, 08:50 PM
These files are not on my computer... they are on a webserver... so my c: drive has nothing to do with it...does it?

Scottae
10-09-2006, 08:52 PM
I don't think so. That was when I was testing something locally. Maybe you should post an fla or something. Your example AS provides no clues to your problem.

0gani
10-09-2006, 08:56 PM
ok... you can get the fla here ..

http://myoperators.com/useless/helloworld.fla

Scottae
10-09-2006, 09:27 PM
Take a look at the comments on ExternalInterface.call (http://livedocs.macromedia.com/flash/8/main/00002203.html).

Dont forget to make sure allowScriptAccess="always" in the HTML object/embed code

But that still doesn't seem to fix things. I don't know what the deal is. I haven't ever fully trusted this class since it first came out. It sounds good in on paper, but using it is a different story. You may want to just go with the good ole trusty getURL.

getURL("javascript:functionName();");

0gani
10-09-2006, 09:32 PM
I can't import a variable from javascript with geturl.... can i ?

if so... how ?

Scottae
10-09-2006, 09:45 PM
I guess you could actually do a bit of leg work yourself and look around the internet.

http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_15683#jtfc
http://www.google.com/search?hl=en&q=javascript+to+flash&btnG=Google+Search

0gani
10-09-2006, 09:52 PM
thats just it... i already did my homework on this ..... i spent 2 weeks trying to find the AS2 solution to get cookies to flash. I got the solution using the ExternalInterface thing. but now i need to use AS3.

Last time i checked, the best and reliable way to import variables to flash from javascript is through Externalinterface. But it doesnt work for AS3.

Scottae
10-09-2006, 10:12 PM
I don't know. Flash 9 is still in beta, so I don't know if they've worked out all the kinks in AS 3.0 or Flash Player 9 as of yet. I assume you've already checked out everything here (http://livedocs.macromedia.com/flex/2/langref/flash/external/ExternalInterface.html). Maybe post a comment about this issue on that page. I didn't see any comments at the time. Also maybe post this as a bug in the Flash Player 9 Feedback Form (http://www.adobe.com/bin/fp9betafeedback.cgi).

[PAUL FERRIE]
10-09-2006, 10:19 PM
There is a page on adobe somewhere listing known issue's so far but i am damned if i can remember where it is...

Ah here it is
http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=4a8d52ae

Hope it helps shed some light on your problem.

Scottae
10-09-2006, 10:40 PM
Yeah, it doesn't seem like they have anything on the current issue. Looks like only thing listed is this:

Operands in file names cause SWF failure in Internet Explorer (http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=4b687833)

0gani
10-10-2006, 08:29 AM
This AS2 works great in both IE and firefox



import flash.external.ExternalInterface;
var cookieValue = ExternalInterface.call("myGetCookie", "yumyum");
hello_txt.text = cookieValue;




This AS3 works great only in firefox but not IE


import flash.external.ExternalInterface;
var cookieValue:* = ExternalInterface.call("myGetCookie", "yumyum");
hello_txt.text = String(cookieValue);




What's wrong with this? What is it that IE doesnt like about this code in AS3?

Scottae
10-10-2006, 03:14 PM
Check out this link (http://flashmove.com/forum/showthread.php?t=27673#post103119)