I’m trying to get the ActionScript example from the script reference to work. However, when I run it I get an error:
InvalidOperationException: Operation is not valid due to the current state of the object
UnityEngine.Flash.ActionScript.Expression[Int32] (System.String formatString, System.Object arguments)
GameController.Start () (at Assets/Scripts/GameController.cs:14)
My calling script looks like this:
using UnityEngine;
using UnityEngine.Flash;
using System.Collections;
public class GameController : MonoBehaviour {
// Use this for initialization
void Start () {
#if UNITY_FLASH
print ("Yup, Unity Flash");
ActionScript.Import("com.mycompany.mytool");
string name = "Lerpz";
int protocolversion = ActionScript.Expression<int>("com.mycompany.mytool.GetProtocolVersionFromServer({0})", name);
print (protocolversion);
#endif
}
// Update is called once per frame
void Update () {
}
}
That script is attached to the main camera.
My ActionScript looks like this:
package com.mycompany
{
public final class mytool
{
public static function GetProtocolVersionFromServer(name: String): int
{
//talk the the flash api here.
return 18;
}
}
}
It is named mytool.as and is placed in a folder call ActionScript at the root of the project hierarchy.
I feel I’ve followed the example to the tee, but it’s not working. What can I do to make it work?