- Home /
unable to call C# method from AS3 script ...
I have two swf files. First (let's call it A) one is a kind of host application with login UI, etc. The second one (B) is generated by Unity. So, A after some actions from user load and starts B. At this point I can easily call B (AS3) method from A (C#) and it works, but I can't call A (C#) methods from B (AS3). There is no any information about this direction communication on official documentation page: http://docs.unity3d.com/Documentation/Manual/flash-gettingstarted.html
So, I've tried this way: http://forum.unity3d.com/threads/147415-Call-AS3-function-from-C-and-Call-C-function-from-AS3-maybe-helpful but it doesn't work for me. So what I've done:
on C# (project A) side I've created FlashCB.cs:
using UnityEngine;
using System.Collections;
[NotRenamed]
public class FlashCB {
public static int Func() {
Debug.Log("Unity function called with message. ");
return 10;
}
}
on AS3 (project B) side NetTest.as:
import global.FlashCB;
[...]
public function onLoadComplete( evt : Event ) : void
{
[...]
var res:int = FlashCB.Func();
}
Finally, it crashes with this error:
[Fault] exception, information=ReferenceError: Error #1065: Variable FlashCB is not defined.
Am I doing something wrong?
Your answer
