Legacy Documentation: Version 4.6.2
Language: English
  • C#
  • JS
  • Boo

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

ActionScript

Namespace: UnityEngine.Flash

Description

Inline ActionScript support.

When targetting the Flash Player, it is often convenient to be able to execute some manually written ActionScript. Examples of this would be: talking to some flash API (think networking, sockets), running some existing ActionScript code, or integrating with some 3rd party ActionScript library. You can call "handwritten" ActionScript methods, and get return values from them most easily like this:

	import UnityEngine.Flash;
	
	function Start()
	{
		ActionScript.Import("com.mycompany.mytool");
		var name = "Lerpz";
		var protocolversion = ActionScript.Expression.<int>("com.mycompany.mytool.GetProtocolVersionFromServer({0})", name);
	}

You then also have to provide the ActionScript file that contains the com.mycompany.mytool actionscript class. You can do this by creating a folder called "ActionScript" anywhere in your Project Folder, and adding the ActionScript class file in there, respecting ActionScripts requirements that the path needs to match the class namespace. In this example, you would place this ActionScript file:

	package com.mycompany 
	{
		public final class mytool
		{
			public static function GetProtocolVersionFromServer(name: String): int
			{
				//talk the the flash api here.
				return 18;
			}
		}
	}

Static Functions

Expression Emits an ActionScript expression translating variable and field references to their ActionScript names.
Import Causes an import directive to be emitted in the ActionScript code generated for the current type.
Statement Emits a block of ActionScript code in the current method translating variable and field references to their ActionScript names.