Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

UnityShared.swc; Communicating between Unity Flash Content and AS3.

Discussion in 'Flash' started by RalphH, Dec 23, 2011.

  1. Lord_Pall

    Lord_Pall

    Joined:
    Sep 25, 2009
    Posts:
    52
    Any ideas on how we can get access to the stage in actionscript? I don't see a way to do that currently.
     
  2. cannon

    cannon

    Joined:
    Jun 5, 2009
    Posts:
    751
    Only way I've found to do that was to use a preloader, and have that pass it in.
     
  3. mrx000

    mrx000

    Joined:
    Feb 3, 2012
    Posts:
    25
    can you please give an example for us, what codes did you used or give us a direction to try
     
  4. paulosigales

    paulosigales

    Joined:
    Dec 15, 2011
    Posts:
    5
    Hello
    Two questions.

    - How i can unload? I try unload and remove the swf but it stay!

    - Have some about change position of object?

    Thank you!
     
  5. cannon

    cannon

    Joined:
    Jun 5, 2009
    Posts:
    751
    Here.
    This sample contains:

    - demo of how to call functions from Unity to Flash and from Flash to Unity using the 3.5f1 API
    - shows a reference to the Stage being passed from the preloader to the Unity swf
    - a sample of how to use the new [NotRenamed] and [NotConverted] attributes
    - a sample FlashDevelop project suitable for loading Unity-compiled Flash swfs
    - (NEW) a sample FlashDevelop Air workspace

    Run index.html; this runs the initial FlashDevelop project that loads the compiled Unity.swf.

    The messages on the left are displayed by Unity, the messages on the right are displayed by Flash.
     

    Attached Files:

    Last edited: Feb 20, 2012
  6. mrx000

    mrx000

    Joined:
    Feb 3, 2012
    Posts:
    25
    I'm speechless, thank you so much for the example!
    helped a lot to understand
     
  7. cannon

    cannon

    Joined:
    Jun 5, 2009
    Posts:
    751
    No problem. There's currently a dearth of examples using the new API, which is a shame as it's rather neat.
    Hopefully the API won't change much in the final build (which is probably due out any day now).

    The only other things I would request that would make integration more complete would be a way to access the stage without a preloader, and a way to add SWCs to the build.
     
  8. laurent-clave

    laurent-clave

    Joined:
    Jul 18, 2011
    Posts:
    280
    Hello and thank you for these examples!
    Is it be possible to load a texture with this method and manage events?
     
  9. akasurreal

    akasurreal

    Joined:
    Jul 17, 2009
    Posts:
    442
    @cannon, excuse my ignorance here if I am missing something obvious, but I tried using your example project to load my unity swf, and keep getting this error:

    Code (csharp):
    1. Fatal Error : ReferenceError: Error #1069: Property http://unity3d.com/cil2as::DefaultValue not found on class Main and there is no default value.
    2.     at UnityEngine.Marshalling::Marshaller$/GetUninitializedObject()
    3.     at com.unity::UnityNative$/Ext_GetNewMonoBehaviour()
    4.     at com.unity::UnityNative$/_ZN13MonoBehaviour19RebuildMonoInstanceEP15ScriptingObject()
    5.     at com.unity::UnityNative$/_ZN13MonoBehaviour9SetScriptERK4PPtrI10MonoScriptEP15ScriptingObject()
    6.     at com.unity::UnityNative$/_ZN13MonoBehaviour23VirtualRedirectTransferER18StreamedBinaryReadILb0EE()
    7.     at com.unity::UnityNative$/_ZN14SerializedFile10ReadObjectEli18ObjectCreationModebPP8TypeTreePbPP6Object()
    8.     at com.unity::UnityNative$/_ZN17PersistentManager26LoadFileCompletelyThreadedERKSsPlS2_ibP12LoadProgress()
    9.     at com.unity::UnityNative$/_ZN21PreloadLevelOperation7PerformEv()
    10.     at com.unity::UnityNative$/_ZN14PreloadManager26UpdatePreloadingSingleStepEb()
    11.     at com.unity::UnityNative$/NativeExt_LoadFirstLevel()
    12.     at com.unity::UnityContentInternal/loadFirstLevel()
    13.     at com.unity::UnityContent/onFrameInitStep()
     
  10. cannon

    cannon

    Joined:
    Jun 5, 2009
    Posts:
    751
    Sorry for the delay, just got a chance to look at this.

    At first I thought it was an API change from 3.5.0f1 to 3.5.0f5, or a change in the UnityShared.swc, but I've just confirmed that the sample still works even if I just recompile the project with 3.5.0f5.

    From looking at the stack trace, I suspect what's happening here is a name collision between your Unity swf and the Flash preloader swf.
    Can you check and see if there's a Main class defined in your Unity project? If two classes with the same name are loaded into the same domain, the first loaded class (in the preloader) will override the second loaded class (in your Unity swf).

    Unity when compiled to Flash shares the same namespace as the Flash preloader unless loaded into another ApplicationDomain, which I don't think the Unity content loader does.
     
    Last edited: Feb 19, 2012
  11. agustinc23

    agustinc23

    Joined:
    Feb 19, 2012
    Posts:
    1
    Hi, I have a question.
    When tested at a html works fine, but I can not function in

    AIR Desktop (3.1), error:
    Fatal Error : Error: Stage3D Error : Error #3702: Context3D not available. (did you set a correct wmode?)
    at com.unity::UnityContent/onStage3DError()

    and FlashPlayer 11 / 11.1 error:
    SecurityError: Error #2000: No active security context.

    I'm using the latest version of flex sdk (4.6)
    Any ideas?

    Thank you!
    Agustin
     
  12. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    Just spent most of my day trying to get Kongregate's AS3 APIs working through Unity export. My problem was that their API example (QuickKong.as) needs a Stage object. It would have been really, REALLY nice for Unity to expose the Stage object through their top-level UnityApp class or something since it's needed to register for callbacks.

    I had to instead hack around the issue by using the provided preloader example to register an API which uses QuickKong. This method requires uploading two .swf files though, the preloader plus the actual swf. It would be a million times easier if we were somehow able to override the startup code or expose the Stage object.

    If I've missed something obvious, please point it out! Thanks.
     
  13. cannon

    cannon

    Joined:
    Jun 5, 2009
    Posts:
    751
    @Jodon

    +1 and an upvote for a reference to the Stage.

    @agustinc23

    I've updated the example to include an Air workspace.
     
    Last edited: Feb 20, 2012
  14. tripknotix

    tripknotix

    Joined:
    Apr 21, 2011
    Posts:
    744
    you can embed the games swf inside of the preloader if your using flash builder, right?
     
  15. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    @tripknotix not sure, I haven't tried. I got a bit worried that the API to load takes in a file name. That along with my total inexperience with flash made me leave it as-is.

    Either way, Unity was so close because it has a really nice setup by putting your files in the ActionScript folder, but then just stopped short because of no access to Stage. I spent all day looking to see if I could hack around it to do it that way and started playing with all the code in C:\Program Files (x86)\Unity\Editor\Data\PlaybackEngines\flashsupport\BuildTools but couldn't figure out where the initial reference to the Stage came in. Tried just sticking it on UserBuild_AS3\UnityApp.as but no dice:(. Really cool that Unity gives you all the code like that though.
     
  16. akasurreal

    akasurreal

    Joined:
    Jul 17, 2009
    Posts:
    442
    Yeah, that was the issue, thanks =)
     
  17. tripknotix

    tripknotix

    Joined:
    Apr 21, 2011
    Posts:
    744
    to manipulate the stage, all i did was talk to the as3 classes, that had pre defined stage actions.

    this allows manipulations such as anti alias in flash.

    things that arent natively supported yet by unity
     
  18. gormanj

    gormanj

    Joined:
    Oct 20, 2010
    Posts:
    3
    I am trying to create a simple hyperlink on an object in Unity for publishing to the Flash Player. I cannot get JavaScript or AS3 to work using Application.ExternalCall to either AS3 or Javascript. I can understand why call the browser doesn't work if you are in the Flash Plugin, however, I don't understand why the AS3 code below is not working. Nor can I understand why Application.OpenURL works fine. I would use that, but I cannot find a way to open the page within the same page and not a _blank. I even tried the recommended call a function to the browser.

    function OnMouseUp() {
    Application.ExternalCall("var url:URLRequest = new URLRequest(“http://www.mtv.com”);navigateToURL(url, “_self);");
    }
     
  19. tripknotix

    tripknotix

    Joined:
    Apr 21, 2011
    Posts:
    744
    The way i used to do it, was to use as3 to call to javascript, then from javascript call any url you want, including calling php urls or bookmarks.
     
  20. RalphH

    RalphH

    Administrator

    Joined:
    Dec 22, 2011
    Posts:
    592
    Actually, ExternalCall is rerouted to actionscript as a function call, and doesn't work like Eval, so this way of trying to call as code won't work, nor is it intended to.

    However, flash opening a blank window instead of exhibiting the same behaviour as the webplayer is a bug, and we'll fix it.

    For now, here's a workaround using our UnityEngine.Flash api's, that will also work for normal openurl calls. Make sure you have using UnityEngine.Flash in your C# script, and add this code.

    Code (csharp):
    1.  
    2.     void OpenUrlFlash(string url){
    3. #if UNITY_FLASH
    4.         ActionScript.Import("flash.net.URLRequest");
    5.         ActionScript.Import ("flash.net.navigateToURL");
    6.         ActionScript.Statement("navigateToURL(new URLRequest({0}), '_self');",url);
    7. #else
    8.         Application.OpenURL (url);
    9. #endif 
    10.     }
    11.  
     
  21. gormanj

    gormanj

    Joined:
    Oct 20, 2010
    Posts:
    3
    Thanks, that was great, now it works!

    using UnityEngine;
    using System.Collections;
    using UnityEngine.Flash;

    public class MouseOpenWebpageSingleClick : MonoBehaviour {

    public string hyperlink = "http://www.exampleurl.com/";

    // Use this for initialization
    void Start () {
    }

    // Update is called once per frame
    void Update () {
    }

    // OnMouseUp is used to open the URL
    void OnMouseUp () {
    OpenUrlFlash(hyperlink);
    }

    // This fixes the bug so that OpenUrlFlash opens in the same window
    void OpenUrlFlash(string url){
    #if UNITY_FLASH
    ActionScript.Import("flash.net.URLRequest");
    ActionScript.Import ("flash.net.navigateToURL");
    ActionScript.Statement("navigateToURL(new URLRequest({0}), '_self');",url);
    #else
    Application.OpenURL (url);
    #endif
    }
    }


    Note- Replace OnMouseUp with this for double-clicking to open url:

    // OnMouseUp is used to open the URL
    float doubleClickStart = 0;
    void OnMouseUp() {
    if ((Time.time - doubleClickStart) < 0.3f) {
    this.OnDoubleClick();
    doubleClickStart = -1;
    }
    else {
    doubleClickStart = Time.time;
    }
    }

    void OnDoubleClick() {
    OpenUrlFlash(hyperlink);
    }
     
    Last edited: Feb 23, 2012
  22. manuelv

    manuelv

    Joined:
    Feb 24, 2012
    Posts:
    14
    Thks Gorman :)

    i used it now
     
  23. GlitterWad

    GlitterWad

    Joined:
    Feb 24, 2012
    Posts:
    4
    Has anybody managed to pass a texture between flash and unity?
    at the moment Im trying to get the webcam texture from flash with the actionscript function:
    Code (csharp):
    1.     public static function GetVideo(o:String):ByteArray
    2.         {
    3.             var bitmapData:BitmapData = new BitmapData(640, 480);
    4.             bitmapData.draw(_vid);
    5.             return bitmapData.getPixels(new Rectangle(0, 0, 1, 1));
    6.         }
    and parse it in unity with this function:
    Code (csharp):
    1.     void updateVideo () {
    2.         #if UNITY_FLASH
    3.             string message = "";
    4.             byte[] value= ActionScript.Expression<byte[]>("FlashProxy.GetVideo({0})",message);
    5.         #endif
    6.         Log(BitConverter.ToUInt32(value, 0).ToString());
    7.     }
    but im getting the error col: 15 Error: Definition System:BitConverter could not be found.
    Which pops up in the .as file not the c# file which leads me to believe flash doesnt support the ToUInt32() function.

    Can anyone point me in a better way to parse this data, ive tried loads of different ways and keep on running into walls , any help would be appreciated.

    Thanks,
    GlitterWad
     
  24. gormanj

    gormanj

    Joined:
    Oct 20, 2010
    Posts:
    3
    Thanks, I am looking to eventually modify the openurl script to work with a single click if an object was NOT rotated (using the script below). The double click is not so intuitive.

    You might also find this useful. I modified this script so as not to have dependencies (it was made by another, maybe here first http://forum.unity3d.com/threads/63698-FPS-input-controller). Be careful if you also have a character controller if using this script (I haven't noticed anything bad, but who knows...). Also notice I commented out //directionLength = directionLength * directionLength;. I also added var yAxisMove = 1.0; (change to zero for horizontal rotation only).

    #pragma strict

    var rotationSpeed = 10.0;
    var lerpSpeed = 20.0;
    var yAxisMove = 1.0;

    private var speed = new Vector3();
    private var avgSpeed = new Vector3();
    private var dragging = false;
    private var targetSpeedX = new Vector3();

    function OnMouseDrag()
    {
    dragging = true;

    // Get the input vector from keyboard or analog stick
    var directionVector = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));

    if (directionVector != Vector3.zero) {
    // Get the length of the directon vector and then normalize it
    // Dividing by the length is cheaper than normalizing when we already have the length anyway
    var directionLength = directionVector.magnitude;
    directionVector = directionVector / directionLength;

    // Make sure the length is no bigger than 1
    directionLength = Mathf.Min(1, directionLength);

    // Make the input vector more sensitive towards the extremes and less sensitive in the middle
    // This makes it easier to control slow speeds when using analog sticks
    //directionLength = directionLength * directionLength;

    // Multiply the normalized direction vector by the modified length
    directionVector = directionVector * directionLength;
    }
    }

    function Update ()
    {

    if (Input.GetMouseButton(0) dragging) {
    speed = new Vector3(-Input.GetAxis ("Mouse X"), Input.GetAxis("Mouse Y"), 0);
    avgSpeed = Vector3.Lerp(avgSpeed,speed,Time.deltaTime * 5);
    } else {
    if (dragging) {
    speed = avgSpeed;
    dragging = false;
    }
    var i = Time.deltaTime * lerpSpeed;
    speed = Vector3.Lerp( speed, Vector3.zero, i);
    }

    transform.Rotate( Camera.main.transform.up * speed.x * rotationSpeed, Space.World );
    transform.Rotate( Camera.main.transform.right * speed.y * yAxisMove * rotationSpeed, Space.World );

    }
     
  25. manuelv

    manuelv

    Joined:
    Feb 24, 2012
    Posts:
    14
    i try too to pass texture between flash and unity

    i use Base64.decode to pass byte[]
    but without success....


    byte[] b64_bytes = ActionScript.Expression<byte[]>("SerializationUtils.readObjectFromStringBytes({0})" , message );

    tex = new Texture2D(1,1);
    tex.LoadImage( b64_bytes);
    renderer.material.SetTexture("_MainTex",tex);



    because Convert.FromBase64String not support by flash export

    sniff sniff
     
  26. otaviosoato

    otaviosoato

    Joined:
    Apr 30, 2010
    Posts:
    2
    Does anyone know how I do to pass a string or number to sendMessage as parameter to a function in unity?

    Results in unity: [object Object], but I need the string.

    Anyone help me? thanks.

    I do not write English very well so it was translated by google. I'm sorry.
     
  27. ccj

    ccj

    Joined:
    Jul 2, 2010
    Posts:
    18
    in unity

    Code (csharp):
    1.  
    2. string get_asname;
    3. public void SendMsgToUnity(object s)
    4. {
    5.   FlashHelper.EmitAsm("ClassName$get_asname$={0}.name;",s);
    6.   Log(get_asname);
    7. }
    8.  
     
  28. Brad-Keys

    Brad-Keys

    Joined:
    May 1, 2006
    Posts:
    161
    Ah awesome, thanks for that tip. That fixed the white content problem for me as well.
     
  29. Brad-Keys

    Brad-Keys

    Joined:
    May 1, 2006
    Posts:
    161
    For anyone interested I just wrote an article on all the tiny gotchyas when it comes to displaying a Unity SWF in a Flash application. I'm no Flash expert, so there were a number of them for me. Hope this helps someone.

    http://bradkeys.com/index.php?articleId=22
     
  30. ilkeryuksel

    ilkeryuksel

    Joined:
    Apr 15, 2011
    Posts:
    13
    IE not error:


    FireFox Error:
    Fatal Error : ReferenceError: Error #1056: Cannot create property x on flash.display.Stage3D.
    at com.unity::UnityContent/resizeStage()
    at com.unity::UnityContent/setupStage()
    at com.unity::UnityContent/initStage()
    at com.unity::UnityContent/init()
    at com.unity::UnityContent()
     
  31. laurent-clave

    laurent-clave

    Joined:
    Jul 18, 2011
    Posts:
    280
    Thank you Brad for this article ;)
    Missing too much information from Unity for communication between Flash / unity and an external service ....
    I'm still wondering how you load an image
     
  32. laurent-clave

    laurent-clave

    Joined:
    Jul 18, 2011
    Posts:
    280
    I am a bit disappointed by the export of flash unity.
    The possibilities are limited
    If you can not upload images (or other) dynamically, even when it's a problem!
     
  33. Superflat

    Superflat

    Joined:
    Mar 19, 2009
    Posts:
    354
    Scaling is a huge issue. Using as3 Loader() to load the unity.swf solves the problem except that i dont know how to talk to the unity swf anymore. I cant use SendMessage()

    Idea's?
     
  34. dgutierrezpalma

    dgutierrezpalma

    Joined:
    Dec 22, 2009
    Posts:
    404
    Hi everybody,

    I need to call an asynchronous Flash method from Unity (done), wait until I receive an Event (done) and call an Unity method from Flash once I've received the Event (not implemented yet). I have downloaded the files from this post and I've seen that I can call Unity methods from Flash using this._unity_loader.unityContent.sendMessage("Startup", "SetHost", {host:this}); from the Main.as file. However, the problem is that I want to call the Unity method from an ActionScript file called FlashWWW.as and I don't know how to retrieve the _unity_loader property from the Main.as class so I can call the sendMessage() method.


    First, I want to be sure I've understood how this Unity <-> Flash communication system works:

    • The Main.as script shouldn't be included into the Unity project, so it should be compiled into a *.swf file using an external IDE, such as FlashDevelop, Flash Builder or FDT. We must put this *.swf file in the HTML code instead of the *.swf file generated by Unity.
    • Only ActionScript files inside the Unity project folder can be accessed from the UnityEngine.Flash API.
    • As I want to call the asynchronous method from Unity, the FlashWWW.as file must be inside the Unity project... but I need to access to the _unity_loader property from the Main.as in order to execute the sendMessage() method.
    • As the Main.as file has been compiled outside the Unity Project folder, I can't access to the _unity_loader property even if I declare it as "public" and "static".


    So... how can I implement that asynchronous method if the FlashWWW.as file must remain inside the Unity project folder and can't access to the _unity_loader in the Main.as script?
     
  35. cannon

    cannon

    Joined:
    Jun 5, 2009
    Posts:
    751
    There are a couple of strategies available.

    One is to use the _unity_loader's sendMessage; this will be sent to your specified GameObject, from where you can redirect to your Unity-included AS3.

    The other is to take advantage of the fact that you can define the same class in both your preloader swf and your Unity swf. The definition compiled in your preloader swf will override the one defined in Unity, and Unity will end up accessing the methods (and static members) of the class defined in your preloader. You just need to make sure that all members of the AS3 class defined in Unity actually also exist in class defined in the preloader.
     
  36. dgutierrezpalma

    dgutierrezpalma

    Joined:
    Dec 22, 2009
    Posts:
    404
    I think the first strategy wouldn't work because the asynchronous method should be called from Unity (not the preloader) but if the preloader classes override the ActionScript classes defined in Unity, the second strategy would be perfect for me. I will define some "stub classes" in the Unity project folder and will re-implement those classes (adding the method implementation) in the preloader.

    Thanks for your help :)
     
  37. cannon

    cannon

    Joined:
    Jun 5, 2009
    Posts:
    751
    Ah, I misunderstood the direction of your methods.

    There's also the third option btw, which is almost like UnityRalph's initial communications sample.
    Flash sends a MovieClip object to unity using the _unity_loader's sendMessage. Unity then stores a reference to the MovieClip.

    You can then call any method signature on the MovieClip from either side as it's a dynamic class. Less verbose than the others, but I like to maintain type safety.
     
  38. Juan

    Juan

    Joined:
    May 21, 2009
    Posts:
    142
    Hi all!!

    I'm using the below demo for doing a custom preloader.

    Right now it's working in FlashDevelop except for two things:

    1.- I can't find a way to get the loading progress

    2.- My swf is compiled and works at 1920x1080, but when i use the preloader compiled with Main.as it loads in a small square, i'm able to change the CommunicationTest project size, but my compiled unity is showing as a small square, i'm a bit lost in this.

    Apart from that i have the project finished, so, this two things separate me from finishing a tedious project i've just finished.

    Thanks!!!!

     
  39. Nolex

    Nolex

    Joined:
    Dec 10, 2010
    Posts:
    115
    Thank you!
    This code is fine, but I want to use fscommand("fullscreen", "true"); for fullscreen mode.

    Code (csharp):
    1. package {
    2.  
    3. public class test {
    4.  
    5.     public function test() {
    6.    
    7.     }
    8.  
    9.     public static function testFn(count:int):int {
    10.         fscommand("fullscreen", "true");   // my code
    11.         return count + 1;
    12.     }
    13.  
    14.  
    15. }
    16.  
    17.  
    18. }
    This sample is not works:
    O:\gamedev\AS3Communication\Assets\ActionScript\test.as(8): col: 2 Error: Call to a possibly undefined method fscommand.
     
    Last edited: Apr 24, 2012
  40. Nolex

    Nolex

    Joined:
    Dec 10, 2010
    Posts:
    115
    I added:
    import flash.system.fscommand;
    and unity3d created this swf-file succesfully, but fullscreen doesn't work!
     
  41. RalphH

    RalphH

    Administrator

    Joined:
    Dec 22, 2011
    Posts:
    592
    fscommands are Flash api's only for the standalone player, so this will not work. Since the current version doesn't give you a reference of the stage in any way (this is fixed in the next build), you'll need to use unityshared.swc to embed unity and set fullscreen from the wrapper.
     
  42. DcTurner

    DcTurner

    Joined:
    Feb 17, 2012
    Posts:
    1

    I have been using;

    stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;

    which seems to work ok, not sure if it's an AIR-specific thing though.
     
  43. tripknotix

    tripknotix

    Joined:
    Apr 21, 2011
    Posts:
    744
    stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
    works on web sites with the embed tag required, but it breaks if the web site doesnt have it, even if they have fullscreen allowed, it still breaks.

    Unity 3.5.1 doesnt grab the MovementX and MovementY for mouselock from flash yet tho. they said theyre working on it.
     
  44. starkos

    starkos

    Joined:
    May 21, 2010
    Posts:
    7
    I've got our Unity movie loading into a Flash wrapper now (thanks for all the help and advice in this thread!), BUT only for certain content. Adding some models or animated characters gives us this error when the wrapper tries to load the Unity movie: "Class flash.display3D.textures::TextureBase could not be found."

    I saw the mention of the Flex 4.6 SDK earlier in this thread, but I'm not sure how this would apply to our project, which is not Flex but Flash-only (built in Flash Professional CS5.5). Has anyone else run into this problem and/or found a workaround?

    Many thanks—I'm stumped!
     
    Last edited: May 1, 2012
  45. starkos

    starkos

    Joined:
    May 21, 2010
    Posts:
    7
    I knew as soon as I posted I would figure it out—I had Hardware Acceleration set to "Level 2 - GPU" instead of "Level 1 - Direct" in the Publishing settings of Flash. I had modified it in the wrapper HTML and thought that would do it, but apparently not.
     
  46. Boff

    Boff

    Joined:
    May 2, 2012
    Posts:
    11
    Hi,

    I'm an average Flash programmer and as of lask week I'm new to Unity and C# in general.
    I'm investigating the usage of unity into normal flash production work, because lets face it, unity is a tad handy for 3d development.
    So my workflow idea is to have a flash project and have unity as sort of a 3d repository.


    I've got Flash Builder 4, flex sdk 4.5, I've used Flare3D before so I got my flash project set up and can very quickly swap out the example swf file for my own with out a problem.




    My big issue is, pulling the example c# code into another unity file without the FlashHelper coming up as a compile error even without the script being attached to any object.
    As I stated I'm new to unity and C# and so far I have been doing my unity examples in javascript, and just been messing around building a simple room with lightmapping and triggers (respawn and my future ambition play a movie file).

    I guess there is no JS code example to connect to flash for inexperiences unity noob such as myself?
    if not I'll grind through the example files given a few pages back.



    A question to the unity team.
    Dynamic textures?
    I understand the movie-to-text may not work -even if flash does already natively support flash movie's rotated round in 3D space.
    But with mobile platforms needing a fade to black, and being able to import in the unity.swf file into a flash project it's my intention to call up a flash movie overlay, so all platforms would theoretically run the same way.
    So I'm currently on the "call a flash function" from unity.

    However my prior experience with Flare3D had me doing spritesheets (or Texture atlases as you guys call it) in flash.

    I tried testing and failing at UV animations via the flash export.


    Is this on the back-burner or is this a high-priority, because there are a number of 2D animators within the flash branch who's skill set could be easily transfered over to Unity(3rd party plugins) for GUI's etc etc, if we could get texture atlases to work within Flash export.
    We could build damn near everything in unity, otherwise we have to start building around a flash solution for web deployment.
    and then re-creating the whole gui in unity...again...if the customer wants to go to mobile.
     
  47. RalphH

    RalphH

    Administrator

    Joined:
    Dec 22, 2011
    Posts:
    592
    This thread is a bit older and started with a previous version of the Flash preview; now we have a different API, which is more flexible. Please check it out here.

    http://unity3d.com/support/documentation/ScriptReference/ActionScript.html

    This thread contains an example of marshalling a bitmapdata into unity;
    http://forum.unity3d.com/threads/128057-Flash-Simple-AS3-Bridge-Demo-Loading-textures-from-web.
     
  48. Boff

    Boff

    Joined:
    May 2, 2012
    Posts:
    11
    Thanks Ralph for your speedy reply,

    well back to reading, learning and testing - sadly those are easy - it is the understanding what I am reading/learning which is the hard part. Lots to take in at one time with trying to get to grips with unity AND a flash bridge. The hard bit is trying to sift through and categorise everything in it's relative importance and relevance - I will get there though :)
     
  49. Boff

    Boff

    Joined:
    May 2, 2012
    Posts:
    11
    I've been attempting to play around with this new method of actionscript code within unity.

    I've got my trace and my actionscript compiling, and even managed to call an wrongly named function
    ActionScript.Statement("FlashProxy.trigger({0})",v);
    when infact i had Trigger in my actionscript.
    The demo worked within unity, and died on the export, giving me a wealth of error messages within the unity console.

    But that method is to be used when you have actionscript that needs to be called within the unity project, right?

    but if I have an flash GUI overlay, with film etc etc?
    Then I need to have the original the swc solution (although it's old and invalidates the FlashHelper function right with the current 3.5.1f version of unity?)
    and that's the one I am having difficulty with.
    When importing the resulting unity.swf and swc into my flash Builder project, the original code example works, All the log(s) reported in nicely to Flash builder's console, but throws up an error on my custom code, as I try to call to a function in my flash builders main.as from my custom .as file in unity.
    I'm getting the classic , TypeError: Error #1009: Cannot access a property or method of a null object reference.
    to be honest, ever since AS3 came out, I've been meaning to physically harm the adobe developer who dismissed the idea of not reporting the property or method you attempted to access.

    I think I am being a little slow in all of this.
     
    Last edited: May 4, 2012
  50. Boff

    Boff

    Joined:
    May 2, 2012
    Posts:
    11
    monday morning and I crushed my issue.

    It was with unity and my in-experience with it.

    startup script needs to be on a gameobject on the scene. Job done. A little embarrassing :)