I've created a FlashProxy.cs file with some functions: Code (csharp): using UnityEngine; using System.Collections; [NotConverted] [NotRenamed] public class FlashProxy : MonoBehaviour { public static void setHost(object o) { } public static void UpdateTime(object o) { } } And in an ActionScript directory in my unity project i put the appropriate .as file. Code (csharp): package { import flash.display.MovieClip; import flash.display.Stage; public class FlashProxy { static var _stage:Stage; static var _mc:MovieClip; public static function setHost(o:Object):void { _mc = o.host as MovieClip; _stage = _mc.stage; } public static function UpdateTime(n:Number):void { _mc.log(n); } } } However, when i run my flash project that loads up the unity.swf and i call the UpdateTime function i get the following error: Code (csharp): TypeError: Error #1009: Cannot access a property or method of a null object reference. at FlashProxy$/UpdateTime()[/Users/Kevin/Documents/Work/TKD/Assets/ActionScript/FlashProxy.as:18] at global::Controller/Controller_GetAnimationTime()[/Users/Kevin/Documents/Work/TKD/Temp/StagingArea/Data/ConvertedDotNetCode/global/Controller.as:38] at com.unity::UnityNative$/Ext_Flash_InvokeMethodOnObject() at com.unity::UnityNative$/_ZN13MonoBehaviour30InvokeMethodOrCoroutineCheckedEP15ScriptingMethodPFP15ScriptingObjectPvPP18ScriptingExceptionES3_() at com.unity::UnityNative$/_Z15SendMonoMessageRN5Unity10GameObjectEPKcP15ScriptingObject() at com.unity::UnityNative$/NativeExt_SendMessage() at com.unity::UnityContentInternal/sendMessage() at com.unity::UnityContent/sendMessage() at nl.superflat.screenmanager.screen::PatternsScreen/updateTime()[/Users/Kevin/Documents/Work/TKD Flash/src/nl/superflat/screenmanager/screen/PatternsScreen.as:79] (Filename: Line: 0) It's still referring to the FlashProxy.as file that i had in my unity project. Have i set all this up incorrectly?
Do you have another FlashProxy defined aside from the one in Unity? From the error, it looks like setHost was not called with a valid movieclip.
Attached is a zip file with my AS3 and C# code. Should give you a better idea of what might be going wrong. Is it required to have an actual FlashProxy.as class present in the as3 project? I made adjustments but the problems still occur.
Is the error you are dealing with the same as your initial post ? If so in this function of flashproxy; public static function UpdateTime(n:Number):void { _mc.log(n); } Check that _mc is not null first, then check where it's set that it's actually set to a non null object.
Hi Ralph, I found that my host wasn't being set because the functions from IUnityContentHost aren't being called. Right now i'm loading the swf using a normal loader and then casting it as UnityContent because SetSize wasn't working. Has this been fixed yet? [EDIT] I got it all working when i use the regular UnityContentLoader except the SetSize. If i do it the other way around with a normal Loader it all works as well except that I have to wait with setting the the contenthost because the unity content isn't ready when it's done loading. Anyway to set the size after it's all loaded using the UnityContentLoader? i tried setting the size on the .content.