A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: How to delete/release XML object?

  1. #1
    Member
    Join Date
    Jun 2006
    Location
    Croatia
    Posts
    90

    How to delete/release XML object?

    I am loading xml file with following AS 3.0 code:

    Code:
    var myXML:XML = new XML();
    var myXMLURL:URLRequest = new URLRequest("input.xml");
    var myLoader:URLLoader = new URLLoader(myXMLURL);
                            
    myLoader.addEventListener(Event.COMPLETE, xmlLoaded);
    And afterward in "xmlLoaded()" function i am parsing loaded xml file and using apollo filesystem api for writing to that same "input.xml" file but when i do that i get this error:

    Code:
    Error #2158: File or directory is in use
    So my guess is that i have to destroy or release somehow my XML object which is connected to my "input.xml" file but i am not sure how to do that. I tried to delete it with "delete" keyword but then realized i can only use it for deleting properties. Can someone help me with this please?

    thank you

  2. #2
    Member
    Join Date
    May 2007
    Posts
    35
    Sorry, I'm not sure on the Apollo APIs, but I can tell you about delete real quick.

    In AS3 it is only used to remove dynamically added properties. You can not "delete" instance or class members with it.

    For example, to create a dynamic property your class defintion must have the dynamic keyword such as the MovieClip class.

    var mc:MovieClip = new MovieClip();
    mc.name = "My Clip";
    mc.name2 = "My Clip 2";
    delete mc.name;
    delete mc.name2;
    trace(mc.name); // traces "My Clip"
    trace(mc.name2); // traces "undefined"

    The difference between name and name2 is that name is an instance member of the class MovieClip (check it out: http://livedocs.adobe.com/flash/9.0/...riptLangRefV3/) but name2 isn't. So when we set it we are actually creating a dynamic variable.

  3. #3
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    just a short hind:
    PHP Code:
    myLoader.addEventListener(Event.COMPLETExmlLoaded); 
    if there is a event for init better use that one,- as complete not always mean ready to go as some data that is loaded still need to be initialized

  4. #4
    Senior Member
    Join Date
    Jan 2006
    Location
    USA
    Posts
    383
    Have you tried doing

    myLoader.close();

  5. #5
    Member
    Join Date
    Jun 2006
    Location
    Croatia
    Posts
    90
    Quote Originally Posted by AfternoonDelite
    Have you tried doing

    myLoader.close();
    Yeah i did but it didn't work unfortunatelly but thanks for suggestion anyway.

  6. #6
    Member
    Join Date
    May 2007
    Posts
    35
    Quote Originally Posted by renderhjs
    just a short hind:
    PHP Code:
    myLoader.addEventListener(Event.COMPLETExmlLoaded); 
    if there is a event for init better use that one,- as complete not always mean ready to go as some data that is loaded still need to be initialized
    Actually it's the other way around. INIT is called after all properties and methods are accessible and the required constructors have finished executing. COMPLETE is then called once all the data is finished loading. COMPLETE is always dispatched after INIT.

  7. #7
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    ah cool so now I know that,- perhaps mixed some things up I alraedy read somewhere else/ before - thx

  8. #8

  9. #9
    Bearded (M|G)od MyFriendIsATaco's Avatar
    Join Date
    Dec 2002
    Location
    Awesomeville.
    Posts
    3,045
    I doubt AS3's structure as far as calling init and complete has changed, but previously, Init was ALWAYS called AFTER the complete event.

    I don't see why that would have changed for as3.

    Basically, a clip or whatever is loaded in. It COMPLETE's it's load. Then it Initializes it to make the properties available. It's not possible for it to initialize properties until AFTER it's loaded fully.

  10. #10
    Member
    Join Date
    May 2007
    Posts
    35
    Lucky for us, I do all the AS3.

    Sorry, I posted the wrong links:

    http://livedocs.adobe.com/flash/9.0/...tml#event:init
    http://livedocs.adobe.com/flash/9.0/...event:complete

    "The init event always precedes the complete event."



    Take it up with Adobe.

  11. #11
    Bearded (M|G)od MyFriendIsATaco's Avatar
    Join Date
    Dec 2002
    Location
    Awesomeville.
    Posts
    3,045
    Haha, thanks Martin for the clarification.

    Yeah, I guess the model changed in AS3, sorry about that!


    Good thing he's working for me!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center