# Returning variable from class

**URL:** https://forum.kirupa.com/t/returning-variable-from-class/318692
**Category:** Uncategorized
**Created:** [January 27, 2011, 10:40am UTC](https://forum.kirupa.com/t/returning-variable-from-class/318692 "2011-01-27T10:40:47Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![illustratorDavi](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/illustratordavi/32/3426_2.png) [@illustratorDavi](https://forum.kirupa.com/u/illustratorDavi)
#### Post date: [January 27, 2011, 10:40am UTC](https://forum.kirupa.com/t/returning-variable-from-class/318692/1 "2011-01-27T10:40:47Z")

</div>

Hi

I’m trying to simplify my code by repeated stuff to classes.

```auto
var rtn:String = licenseCheck(paramObj.sugar,localURL);

```

Sends to the following class, with the idea of returning returnStr at the end.

```auto
package couk.me.od
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.net.*;
	
	public class licenseCheck extends Sprite
	{
		
		static public var localURLreq:URLRequest = new URLRequest("http://www.google.com/odRem/odRem.cfm");
		static public var localURL:String = "";
		static public var returnStr:String = "empty";
		
		public function licenseCheck(sweetener:String,localURLin:String) {
			localURL = localURLin;
			
			var variables:URLVariables = new URLVariables();
			variables.sugar = sweetener;
			
			localURLreq.method = URLRequestMethod.POST;
			localURLreq.data = variables;
			
			var loader:URLLoader = new URLLoader();
			loader.addEventListener(Event.CONNECT, checkingLicense);
			loader.addEventListener(Event.COMPLETE, onLicenseChecked);
			loader.load(localURLreq);
		}
		
		
		private function checkingLicense(event:Event):void {
			returnStr = "still checking license...";
		}
		
		private function onLicenseChecked(evt:Event):String {
			
			if (String(evt.target.data) != "no") {
				var retStr:String = String(evt.target.data);
				var spaceless:String = stringFuncs.stripSpaces(retStr);
				var comStr:String = String(localURL).toLowerCase();
				if (comStr.indexOf(spaceless) != -1) {
					// loads designer if successful
					//loadDesigner(1);
					returnStr = "license is correct";
				} else {
					returnStr = comStr + " " + retStr + " Please check your license domain is correct";
				}	
			} else {
				returnStr = "Please check your license domain is correct";
			}
			
			return returnStr
		}
		
	}
}

```

But this creates two errors

1067: Implicit coercion of a value of type couk.me.od:licenseCheck to an unrelated type String.

1137: Incorrect number of arguments. Expected no more than 1. designerAppMain.as

Please could someone point me in the right direction for how I could change my class

Thanks  
David
