30 posts
  • Has sold $100+ on Envato Market
  • Has collected 1+ items on Envato Market
  • Sells items exclusively on Envato Market
  • Located in Romania
+1 more
SharkStudio says
So i am loading a xml file and after that i initialize something with ADDED _TO_STAGE and the xml loads after the initialize, I want to load the xml before initialize how to do that? See this example to understand more clearly
LoadXML();///this loads after Initialize
addEventListener(Event.ADDED_TO_STAGE, Initialize);///this loads first

I want to keep ADDED _TO_STAGE because without it file doesn`t work properly.

1680 posts Envato Elite Author
  • Has referred 10+ members
  • Has sold $125,000+ on Envato Market
  • Has collected 1+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+6 more
Tean says

Listen for xml complete load and then call Initialize.

http://www.republicofcode.com/tutorials/flash/as3xml/
30 posts
  • Has sold $100+ on Envato Market
  • Has collected 1+ items on Envato Market
  • Sells items exclusively on Envato Market
  • Located in Romania
+1 more
SharkStudio says

Tryed that but it just give`s me a blank screen

767 posts
  • Has been part of the Envato Community for over 5 years
  • Has sold $1,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Sells items exclusively on Envato Market
+2 more
outandouter says

Instead of adding an event listener after the xml load complete, try to first see if the object has already been added to stage. If it is, just simply call the Initialize function and if not, add an event listener. Like this:

if (stage) Initialize(null);
else addEventListener(Event.ADDED_TO_STAGE, Initialize);
66 posts
  • Has sold $100+ on Envato Market
  • Has collected 1+ items on Envato Market
  • Contributed a free file of the month
  • Made it to the Authors' Hall of Fame
+3 more
yuanhao_viva says

don’t forget removeEventListener.if not,xml will load by twice when swf load another swf.

30 posts
  • Has sold $100+ on Envato Market
  • Has collected 1+ items on Envato Market
  • Sells items exclusively on Envato Market
  • Located in Romania
+1 more
SharkStudio says

thank you guys. fixed this

....
LoadXML();

private function LoadXML():void
{
  var loader:URLLoader = new URLLoader(new URLRequest("xml/test.xml"));
  loader.addEventListener(Event.COMPLETE, Initialize);
}

private function Initialize(event:Event):void
{
   xml = new XML(event.target.data);
}

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by