This content has been marked as final. Show 7 replies
First, why are you using rawChildren? That is preventing flex from laying out the children properly.
Perhaps Code1 works because there are
no children on the DisplayList, but Code2 has a button which does not play well with anything on the rawChildren list.
Also, why are you using Loader and not SWFLoader?
Hi, thanks for your answers, but, when I use addChild - normal method it throws an error that loader in not an UIComponent. Of course when I create new UIComponent, then add loader as a child to it and then add this ui component to the stage - the bahaviour is the same. code1 works and code2 doesn't.
And I have additional question - why schouldn't I use Loader to load swf - manual says,that we can use loader to load images etc and swf ... ?
"The Loader class is used to load SWF files or image (JPG, PNG, or GIF) files."
Additional when I use swfLoader - the error still is :( (code 5). - this doesn't simply work. When I press button, nothing happens :(
THESE CODES DON'T WORK: (here I use UIComponent, so everything schould be ok, but it's not :(
"w_danilo" <firstname.lastname@example.org> wrote in message
> Hi, thanks for your answers, but, when I use addChild - normal method it
> an error that loader in not an UIComponent.
I think that error is pretty informative, but it could be more specific.
What it means is that you're trying to add a component that doesn't
implement IUIComponent to a component that is set up to only take components
that implement that interface as children, most likely a Container subclass.
> Of course when I create new
> UIComponent, then add loader as a child to it and then add this ui
> component to
> the stage - the bahaviour is the same. code1 works and code2 doesn't.
It seems like a race condition...something you're trying to do is not ready
when you start the chain of events at initialize, but it is when you can see
the button on the screen, after creationComplete.
> And I have additional question - why schouldn't I use Loader to load swf -
> manual says,that we can use loader to load images etc and swf ... ?
> "The Loader class is used to load SWF files or image (JPG, PNG, or GIF)
Because swfLoader already implements IUIComponent...?
Do not use rawChildren.
There are rules for what can contain what:
1. navigator children must be containers
2. Container children must be IUIComponents
3. UIComponent children can be anything
Loader is not a UIComponent, so you can't add it to an Application. SWFLoader *is* a UIComponent, so you can use Application.addChild
Code5 is close.
You may have a tming issue, though I am not sure why the behaviors are different. Try rearranging the order of the calls. Can you addChild the loader in the completion handler?
Maybe try callLater to set the content.visible.
Note that "content" is not necessarily ready to be accessed in the SWFLoader Complete handler. You may need to listen for the applicationComplete event.
Here is a full example of using SWFLoader that might help:
Amy Blankenship :
Thank You for reply. I understeand everything, you've written, but this example, I've posted behaves not exactly as you mean. So CODE1 works (and this code addChild to the stage after loading is completed) and CODE2 doesn't work - BUT IT DOES THE SAME THINGS AS CODE1 - i press the button (which add loader to the stage) "a lot of time after" loading is completed (as trace method tells).
f.e - i start application - it traces (loading in progres.... loaded complete - then I wait a minute or tw, press the button and nothing happens, but when I add the same function to complete handler as to the button it works. (additional in both ways everything happens when the application is already initialized)
Thank You for your answer. Ok I won't use rawChildren any more ;] I've seen that article, you've posted, but I think it's saying nothing about addingloaded object to the stage (yes It says about progress methods etc, but I write here really simple codes because they are clean and easy to follow - additional I wont to write the all code for this loader in AS3 :) )
For some reasons I can't addChild the loader in the completion handler in my app. But, when I test this "CODE 5" application it traces "complete" when loading is completed (i get traced):
[SWF] lt.swf - 1 024 076 bytes after decompression
[SWF] test3.swf - 352 342 bytes after decompression
and I press the button really a lot of time after it's loaded. What is very interesting, that when I addChild the loader in the completion handler - it works (but in this application I won't do that)
AND when I addChild by button and then when I call load again (manual says that loading again is reloading) - after reload is complete this object appears on the stage (without addChild)! :(
(This happens with SWFLoader and Loader class too).
So concluding I really need to load this SWF and add it by pressing the button to the stage (not reload it) and I write everything in AS3. How schould this code look like? :(