-
(Very) weird error involving classes and loaded SWF
I had the following problem in my project:
My project is about a header.swf that calls a nav.swf (with a menu and other stuff) and also inits a slideshow through a Slideshow class.
This is in header.swf:
Code:
private function topLoaderHandler(e:Event):void
{
topContainer = e.target.content; // nav.swf is the loaded swf
topContainer.y = 10;
// topContainer.x = (stage.width - topContainer.width) /2;
addChild(topContainer);
new XmlParser("xml/slides.xml").addEventListener("XML_PARSED", initSlideShow);
}
private function initSlideShow(e:Event):void
{
slideshow = new Slideshow(e.target.myXML, 5000, 2, 0);
// xml, delay, fade, delayBetween
slideshow.addEventListener("LOADING_START", onStartLoading);
slideshow.addEventListener("LOADING_COMPLETE", onCompleteLoading);
slideshow.addEventListener("FIRST_IMAGE_LOADED", startAnimation);
slideshow.start();
ss_container.addChild(slideshow);
}
The slideshows loads correctly but the nav doesn´t show.
I tried lot of things and then discovered that if I remove the line
" new XmlParser("xml/slides.xml").addEventListener("XML_PARSED", initSlideShow);", the nav.swf would show perfectly.
So what did I do ?
I renamed the XmlParser class to "XmlParser2.as" (as well as other references to it) and then...it worked !!!
what the hell was going on here?
obs: I tried that also: I commented all the code inside the "initSlideShow" function, keeping the XmlParser instantiation, and the nav.swf didn´t show as well.
obs2 : i didn´t had XmlParser.as imported cause it was in the root directory. ( i explicitely imported it and tried to compile but same thing happened)
obs3: nav.swf uses the XmlParser.as to load two menus, however I don´t believe it has anything to do it since it´s a file that is already compiled, at the point I try to load it into header.swf, right?
Well I luckely solved the problem in about one hour but i would like to know was that all about . I got no clue.
Thanks a lot !
Last edited by ziriguidum; 01-28-2010 at 02:26 PM.
-
Why aren't you assigning the new XmlParser to a var? I'm guessing because you're doing the loading inside the constructor? IMO not a good idea.
Also, when you're loading an external swf, it's usually enough to just add the loader() object you're using.
PHP Code:
var l:Loader = new Loader(); l.load(new URLRequest("nav.swf"));
topContainer.addChild(l);
var xp:XmlParser = new XmlParser("xmlfile.xml"); xp.addEventListener("XML_PARSED", init);
//etc
I (Love | Hate) Flash.
----
Save a version back so others may help you!
-
Originally Posted by Phix
Why aren't you assigning the new XmlParser to a var? I'm guessing because you're doing the loading inside the constructor? IMO not a good idea.
Also, when you're loading an external swf, it's usually enough to just add the loader() object you're using.
PHP Code:
var l:Loader = new Loader();
l.load(new URLRequest("nav.swf"));
topContainer.addChild(l);
var xp:XmlParser = new XmlParser("xmlfile.xml");
xp.addEventListener("XML_PARSED", init);
//etc
I tried that - assigning the new XmlParser to a var and then adding the listener in a new statement. it didn´t change anything.
is that a bad practice to do it the way I did ?
I didn´t try to add just the loader instead of "e.target.content".... what´s the difference ? I´ll try that. Though I don´t think that will solve the problem.
cause I actually solved the problem in a very strange way (renaming the class). it was really intriguing for me. i don´t know if I explained it clearly...
thanks!
Tags for this Thread
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
|