Improper use of "return"

I am in the process of re-creating a Flash file that was written in AS2 into something that will work in AS3.  Fortunately, most of the code ports over just fine.

I am baffled with a compile error that I keep getting.  It says that "Return value must be undefined" for my command, "return(R)" (which is within the GetValue function in the attached code).  I know I must be doing something wrong, but I cannot put my finger on it, especially since the "return(R)" command doesn't trip the compiler in my Initialize function.  

Can an AS3 expert find my flaw?  If you know how SCORM works, that's an added bonus, as I won't rule out SCORM being an issue.

PS, I placed the GetValue function first for purposes of this code to help out.  If there is anything else I can do to aid in this solution, I'll be more than happy to elaborate.
function GetValue(n:String):void
{
	var R:String;
	var doGetValue = ExternalInterface.call("doLMSGetValue", n);
	R = String(doGetValue);
	return (R);
}
 
 
import flash.external.ExternalInterface;
 
/* This portion is required for SCORM compliance. 
 
=================================================
 
*/
 
var bookmark:Number;
 
function Initialize():Boolean
{
	var R:Boolean;
	var initCheck = ExternalInterface.call("doLMSInitialize");
	
	if (initCheck == "true")
	{
		SetValue("cmi.core.lesson_status", "incomplete");
		bookmark = Number(GetValue("cmi.core.lesson_location"));
		
		if (bookmark < 2)
		{
			bookmark = 1;
		}
		
		R = true;
	}
	else
	{
		R = false;
	}
	return(R);
}
 
function SetValue(n:String, v:String):void
{
	var R:Boolean;
	var doSetValue = ExternalInterface.call("doLMSSetValue", n, v);
}
 
 
function Terminate():void
{
	var R:Boolean;
	var termCheck = ExternalInterface.call("doLMSFinish");
}
 
 
/*
 
=================================================
 
*/
 
 
 
stop();
 
next_btn.addEventListener(MouseEvent.CLICK, clickNext);
prev_btn.addEventListener(MouseEvent.CLICK, clickPrev);
 
prev_btn.visible = false;
next_btn.visible = false
 
var init:Boolean = Initialize();
 
if (bookmark >1)
{
	gotoAndPlay(bookmark);
}
else
{
	if(init)
	{
		next_btn.visible = true;
	}
}
 
function clickNext(event:MouseEvent):void
{
	nextFrame();
	bookmark = currentFrame;
	SetValue( "cmi.core.lesson_location", String( bookmark ) );
 
}
 
function clickPrev(event:MouseEvent):void
{
	prevFrame();
	bookmark = currentFrame;
	SetValue( "cmi.core.lesson_location", String( bookmark ) );
}

Open in new window

LVL 9
jkunreinAsked:
Who is Participating?
 
section25Commented:
In other words, change:

function GetValue(n:String):void

to

function GetValue(n:String)

or

function GetValue(n:String):String

0
 
section25Commented:
You are calling a function and trying to return a value. However the function you are calling is already defined to return "void". Therefore it can not return your value.

Remove the :void off of the function you are calling.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.