Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AS2 to AS3 migration problems

Status
Not open for further replies.

0gani

Technical User
Oct 9, 2006
14
SK
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...
 
I haven't explored AS3 properly yet but what do you get if you do this? :
Code:
import flash.external.ExternalInterface;
if(ExternalInterface.available){
	trace(ExternalInterface.call("myGetCookie", "yumyum"));
}else{
	trace("ExternalInterface is not available");
}

Kenneth Kawamoto
 
Code:
import flash.external.ExternalInterface;
if(ExternalInterface.available){
    trace(ExternalInterface.call("myGetCookie", "yumyum"));
}else{
    trace("ExternalInterface is not available");
}
this code gives me nothing. The flashdoes not seem to fully load. Here is the result.

 
Sorry "trace()" was no good as the SWF needs to be embedded in the HTML!

Javascript:
Code:
function myGetCookie(str){
	return str;
}

AS3:
Code:
import flash.external.ExternalInterface;
if(ExternalInterface.call("myGetCookie", "yumyum") != null){
	var cookieValue:String = ExternalInterface.call("myGetCookie", "yumyum");
	hello_txt.text = cookieValue;
}

I get no compile/runtime errors and "yumyum" is displayed in the TextField.

Kenneth Kawamoto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top