-
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
-
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.
-
just a short hind:
PHP Code:
myLoader.addEventListener(Event.COMPLETE, xmlLoaded);
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
-
Have you tried doing
myLoader.close();
-
Originally Posted by AfternoonDelite
Have you tried doing
myLoader.close();
Yeah i did but it didn't work unfortunatelly but thanks for suggestion anyway.
-
Originally Posted by renderhjs
just a short hind:
PHP Code:
myLoader.addEventListener(Event.COMPLETE, xmlLoaded);
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.
-
ah cool so now I know that,- perhaps mixed some things up I alraedy read somewhere else/ before - thx
-
-
Bearded (M|G)od
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.
-
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.
-
Bearded (M|G)od
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|