Home » ActionScript 3.0

Get US state name and Abbreviations in AS3-Flash

23 July 2012 No Comment
Share on Facebook

A simple AS3 Flash utility function to convert or get US state name from its abbreviation or US state abbreviation from its name.

Hope will be useful for the users.

Get US State abbreviation from State Name:

AS3 function to convert US-State name to its abbreviation.

AS3 Code and Usage:

 
trace(getStateToAbbreviationName("Alaska"))

function getStateToAbbreviationName( $state ):String
{
	var resultStr:String ="";

	if ($state=="Alaska"){ resultStr = "AK"; }
	if ($state=="Alabama"){ resultStr = "AL"; }
	if ($state=="Arkansas"){ resultStr = "AR"; }
	if ($state=="Arizona"){ resultStr = "AZ"; }
	if ($state=="California"){ resultStr = "CA"; }
	if ($state=="Colorado"){ resultStr = "CO"; }
	if ($state=="Connecticut"){ resultStr = "CT"; }
	if ($state=="District of Columbia"){ resultStr = "DC"; }
	if ($state=="Delaware"){ resultStr = "DE"; }
	if ($state=="Florida"){ resultStr = "FL"; }
	if ($state=="Georgia"){ resultStr = "GA"; }
	if ($state=="Hawaii"){ resultStr = "HI"; }
	if ($state=="Iowa"){ resultStr = "IA"; }
	if ($state=="Idaho"){ resultStr = "ID"; }
	if ($state=="Illinois"){ resultStr = "IL"; }
	if ($state=="Indiana"){ resultStr = "IN"; }
	if ($state=="Kansas"){ resultStr = "KS"; }
	if ($state=="Kentucky"){ resultStr = "KY"; }
	if ($state=="Louisiana"){ resultStr = "LA"; }
	if ($state=="Massachusetts"){ resultStr = "MA"; }
	if ($state=="Maryland"){ resultStr = "MD"; }
	if ($state=="Maine"){ resultStr = "ME"; }
	if ($state=="Michigan"){ resultStr = "MI"; }
	if ($state=="Minnesota"){ resultStr = "MN"; }
	if ($state=="Missouri"){ resultStr = "MO"; }
	if ($state=="Mississippi"){ resultStr = "MS"; }
	if ($state=="Montana"){ resultStr = "MT"; }
	if ($state=="North Carolina"){ resultStr = "NC"; }
	if ($state=="North Dakota"){ resultStr = "ND"; }
	if ($state=="Nebraska"){ resultStr = "NE"; }
	if ($state=="New Hampshire"){ resultStr = "NH"; }
	if ($state=="New Jersey"){ resultStr = "NJ"; }
	if ($state=="New Mexico"){ resultStr = "NM"; }
	if ($state=="Nevada"){ resultStr = "NV"; }
	if ($state=="New York"){ resultStr = "NY"; }
	if ($state=="Ohio"){ resultStr = "OH"; }
	if ($state=="Oklahoma"){ resultStr = "OK"; }
	if ($state=="Oregon"){ resultStr = "OR"; }
	if ($state=="Pennsylvania"){ resultStr = "PA"; }
	if ($state=="Rhode Island"){ resultStr = "RI"; }
	if ($state=="South Carolina"){ resultStr = "SC"; }
	if ($state=="South Dakota"){ resultStr = "SD"; }
	if ($state=="Tennessee"){ resultStr = "TN"; }
	if ($state=="Texas"){ resultStr = "TX"; }
	if ($state=="Utah"){ resultStr = "UT"; }
	if ($state=="Virginia"){ resultStr = "VA"; }
	if ($state=="Vermont"){ resultStr = "VT"; }
	if ($state=="Washington"){ resultStr = "WA"; }
	if ($state=="Wisconsin"){ resultStr = "WI"; }
	if ($state=="West Virginia"){ resultStr = "WV"; }
	if ($state=="Wyoming"){ resultStr = "WY"; }

	return resultStr;
}

Get US State Name from abbreviation:

AS3 function to convert US-State abbreviation to its name.

AS3 Code and Usage:

trace(getStateNameByAbbreviation("AK"))

function getStateNameByAbbreviation( $abbr ):String
{
	var resultStr:String ="";

	if ($abbr=="AK"){ resultStr = "Alaska"; }
	if ($abbr=="AL"){ resultStr = "Alabama"; }
	if ($abbr=="AR"){ resultStr = "Arkansas"; }
	if ($abbr=="AZ"){ resultStr = "Arizona"; }
	if ($abbr=="CA"){ resultStr = "California"; }
	if ($abbr=="CO"){ resultStr = "Colorado"; }
	if ($abbr=="CT"){ resultStr = "Connecticut"; }
	if ($abbr=="DC"){ resultStr = "District of Columbia"; }
	if ($abbr=="DE"){ resultStr = "Delaware"; }
	if ($abbr=="FL"){ resultStr = "Florida"; }
	if ($abbr=="GA"){ resultStr = "Georgia"; }
	if ($abbr=="HI"){ resultStr = "Hawaii"; }
	if ($abbr=="IA"){ resultStr = "Iowa"; }
	if ($abbr=="ID"){ resultStr = "Idaho"; }
	if ($abbr=="IL"){ resultStr = "Illinois"; }
	if ($abbr=="IN"){ resultStr = "Indiana"; }
	if ($abbr=="KS"){ resultStr = "Kansas"; }
	if ($abbr=="KY"){ resultStr = "Kentucky"; }
	if ($abbr=="LA"){ resultStr = "Louisiana"; }
	if ($abbr=="MA"){ resultStr = "Massachusetts"; }
	if ($abbr=="MD"){ resultStr = "Maryland"; }
	if ($abbr=="ME"){ resultStr = "Maine"; }
	if ($abbr=="MI"){ resultStr = "Michigan"; }
	if ($abbr=="MN"){ resultStr = "Minnesota"; }
	if ($abbr=="MO"){ resultStr = "Missouri"; }
	if ($abbr=="MS"){ resultStr = "Mississippi"; }
	if ($abbr=="MT"){ resultStr = "Montana"; }
	if ($abbr=="NC"){ resultStr = "North Carolina"; }
	if ($abbr=="ND"){ resultStr = "North Dakota"; }
	if ($abbr=="NE"){ resultStr = "Nebraska"; }
	if ($abbr=="NH"){ resultStr = "New Hampshire"; }
	if ($abbr=="NJ"){ resultStr = "New Jersey"; }
	if ($abbr=="NM"){ resultStr = "New Mexico"; }
	if ($abbr=="NV"){ resultStr = "Nevada"; }
	if ($abbr=="NY"){ resultStr = "New York"; }
	if ($abbr=="OH"){ resultStr = "Ohio"; }
	if ($abbr=="OK"){ resultStr = "Oklahoma"; }
	if ($abbr=="OR"){ resultStr = "Oregon"; }
	if ($abbr=="PA"){ resultStr = "Pennsylvania"; }
	if ($abbr=="RI"){ resultStr = "Rhode Island"; }
	if ($abbr=="SC"){ resultStr = "South Carolina"; }
	if ($abbr=="SD"){ resultStr = "South Dakota"; }
	if ($abbr=="TN"){ resultStr = "Tennessee"; }
	if ($abbr=="TX"){ resultStr = "Texas"; }
	if ($abbr=="UT"){ resultStr = "Utah"; }
	if ($abbr=="VA"){ resultStr = "Virginia"; }
	if ($abbr=="VT"){ resultStr = "Vermont"; }
	if ($abbr=="WA"){ resultStr = "Washington"; }
	if ($abbr=="WI"){ resultStr = "Wisconsin"; }
	if ($abbr=="WV"){ resultStr = "West Virginia"; }
	if ($abbr=="WY"){ resultStr = "Wyoming"; }

	return resultStr;
 }

Thanks for using :)

GET THE UPDATES VIA EMAIL

We don't share your email anywhere, grab our rss via feedburner