Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Flash preview and .NET XML

Discussion in 'Flash' started by Kencho, Dec 26, 2011.

  1. Kencho

    Kencho

    Joined:
    Dec 26, 2011
    Posts:
    14
    Hello everyone!

    I was working on a custom 2D sprites manager solution for the Flash in a Flash competition. Once I was happy with the results, have tried building it for Flash, and the error appeared :p
    Error: Definition System.Xml:XmlElement could not be found.​
    This refers to the .NET support library (System.Xml). It's my fault for not testing it before, but well, I have to get used to the idea.

    What shocked me is that XmlDocument seems to be supported, for instance, as no error surfaced with it. Any notes on this? Anyone guess an alternative to System.Xml?

    I won't be ready for the deadline, most likely, so I'm not in a hurry. Thanks for your ideas and suggestions in advance anyways!
     
  2. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,635
    From my experience pretty much nothing but System.Collections and System.Collections.Generic work currently works with flash (and even then stuff like Stacks<> don't work). Not even just System works.
     
  3. Cameron_SM

    Cameron_SM

    Joined:
    Jun 1, 2009
    Posts:
    915
    Considering all scripts, C# or UnityScript need to be compiled into ActionScript I wouldn't expect any classes outside of UnityEngine or System.Collection to work correctly yet.

    Early days though.

    There is an API Compatibility Level setting in PlayerSettings in the Flash tab but it's greyed out. I'm guessing eventually there will be multiple profiles to choose from just like the Desktop target so that Unity will simply use one of several Flash .SWC libraries (wee bit like DLLs) based on what .NET language features you're using.

    Still, I wouldn't hold out much hope for System.XML support any time soon. What Unity really needs is a fast internal XML parser rather than relying on .NET systems that kinda fall apart cross-platform, something that could just hand off from Unity's WWW or disk IO functions that is parsed into a simple DOM tree.
     
  4. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    I'm pretty sure there will never be multiple profiles.
    Like WebPlayer it will get a single one, thats the 'flash' one with exactly the stuff that UT ported to make work on Flash.
    Anything you need on top has to be done with whats offered or with AS3 code on the flash side.

    System.XML would be relatively unlikely as it requires many other things and adds over 1MB of pure binary data already. In flash code that would be a nightmare style amount of extra code and it would make much more sense if you make use of a flash xml / json library and pass the strings around.

    System.XML btw works everywhere beside flash (unlike the majority of the json libraries)
    There is a lightweight xml parser available here on the board for people that don't need something that sophisticated, unsure if it works though
     
  5. Kencho

    Kencho

    Joined:
    Dec 26, 2011
    Posts:
    14
    Hmm, then it's just as I expected. I knew the Android platform could rely on Mono, and for some reason thought that System.Xml calls may be wrapped and converted to AS3 Xml. Well, my bad for not doing some early testing, hahaha. Well, will keep this in mind if I release a WebPlayer/Flash/NaCl project in the future :)

    Thanks for the answers!
     
  6. Le-nain

    Le-nain

    Joined:
    Nov 26, 2012
    Posts:
    62
    Hi,
    I just noticed that Sytem.Xml isn't supported with the Flash build target. I find myself with a problem: the target HAS TO BE Flash, and I need to use some XMLs import. Any idea on how I could do that easily? My XMLs are quite simple, something along 4 different tags and 15 tag-attributes (total). Do I have to write my own text parser? If so, where should I look first?
    Thanks
     
  7. mtoivo

    mtoivo

    Joined:
    Jul 30, 2012
    Posts:
    274
    Hi Le nain.

    I stumbled to this problem myself too. First I decided not to use System.Xml at all, because I had the idea that .NET not very lightweight on the mobile side either. I used a simpler XML parser instead: UnityScript Lightweight XML Parser. At the time it didn't compile to Flash (don't know what the situtation is now, didn't work with pre-4.0 at least), so I wrote a simple wrapper-class for my XML queries, and made an AS3-version of it too, which uses the native XML parser of the Flash. That way, even if I'd be only targeting Flash, I get a working version in the editor too, which doesn't understand AS3. XML parsing in the AS3 is very easy, even if you haven't done much AS3 before.
     
  8. Le-nain

    Le-nain

    Joined:
    Nov 26, 2012
    Posts:
    62
    Thanks for your answer. I stumbled upon this lightweight XML parser aswell after posting. Didn't try it yet, as my workday was over, but I'll try tomorrow. I really hope it's compatible with Flash now, as I really don't have time to write a real XML parser on my own (especially since I've never done any AS...). The project I'm working on is supposed to be finished around the end of the week, so I guess my planning would be really crippled if I had to >_<
     
  9. GDesmoulins

    GDesmoulins

    Joined:
    Apr 26, 2013
    Posts:
    7
    Hello Le nain,
    Did you manage to use XML Parser with Flash export ? same problem for me ...
     
  10. Le-nain

    Le-nain

    Joined:
    Nov 26, 2012
    Posts:
    62
    Yes I did. I can't recall if I had to modify some things (but don't worry, if so, it wasn't much) ans I don't have access to the source, but I did use it successfully.
     
  11. RalphH

    RalphH

    Unity Technologies

    Joined:
    Dec 22, 2011
    Posts:
    592
    The best thing to do is to use the actionscript bridging functionality to use Flash's built in xml parser.