Closed GoogleCodeExporter closed 9 years ago
Thanks for the report. I'll have a look on the issue as soon as I have time to
discover what's up.
Original comment by zisfor...@gmail.com
on 14 Apr 2007 at 2:58
Acknowledged; I was able to reproduce it. Using a SWFLoader class on a Flex
project
(regardless of Apollo usage) seem to trigger the problem. The real issue is
that,
once inside the SWFLoader, the SWF movie itself can't start Tweener because it
doesn't have control of stage (the reference is lost); this happens regardless
of
whether the child SWF was made with the Flash 9 Alpha IDE, or the Flex SDK.
This is the debig error message when loading a SWF created with the Flash 9 IDE:
TypeError: Error #1009: Cannot access a property or method of a null object
reference.
at caurina.transitions::Tweener$/init()
at Timeline0_d0a2c817887e244094cf1d3c574c592c/::frame1()
Error message when loading a SWF created with the Flex SDK:
TypeError: Error #1009: Cannot access a property or method of a null object
reference.
at caurina.transitions::Tweener$/init()
at Main$iinit()
There's something fishy with SWFLoader, however. When using the
flash.display.Loader
class instead of mx.controls.SWFLoader, the movie loads and executes as
expected on
both SWF cases. So for some reason SWFLoader is the one who kills it.
I haven't used SWFLoader before, but the clues I gather are these:
1. SWFLoader actually embeds the movie on the final, compiled SWF; this means
the SWF
is ran before stage actually exists? I wasn't able to run the SWFLoader.load()
method
*after* initialization, so I don't know whether the problem would also show up
on
that kind of loading.
2. There's a chance running Tweener.init() on the original SWF will fix things
since
it'll initialize Tweener before it has a chance to fail. However, I wasn't able
to
properly test it (I couldn't get a Flex project with a SWFLoader component to
execute
my code before the SWFLoader loads the content) and in that case, it will also
pop up
a few more (non-fatal) debug errors as the SWF loading tries to overwrite the
classes
(which are "read-only").
I don't use Flex or Apollo much, I just came up with a few quick samples to test
these issues, so other test cases and clues would be great.
Anyhow, it all comes down to the fact that stage can't be accessed by the
Tweener.init(stage) code on the child SWF, so it could all be solved if we
managed to
add the frame listener without the need for the init(). This is something I
still
have to investigate to see if it's at all possible.
Original comment by zisfor...@gmail.com
on 14 Apr 2007 at 6:55
Heh I fixed this today
The problem is that you are init'ing the stage - which Apollo doesn't recognize
(
currently) in the same way - for Apollo the stage reference is objained via
this.window.stage . We did manage to init the stage for Apollo by going
Tweener.init(this.window.stage) - but that made it great for tweening items in
Apollo
/Flex framework - not for using it withtin a swf.
When I went into the code - I saw that the stage is just basically being used
to add
an item (sprite) to the displaylist. So I changed the codebase to accept a
displayObject and passed it a sprite rather than the stage to init. Seems a bit
more
flexible in the long run for me personally.
This works in apollo just dandy.
Original comment by stacey.m...@gmail.com
on 15 Apr 2007 at 3:54
That's very nice, thanks for the tip Stacey! Living and learning.
HOWEVER. I was under the impression the stage hack wasn't necessary, but never
had
enough time to test it. Today, after some testing, I managed to get it working
with
no stage at all. All you need to do is create the MovieClip/Sprite, attach the
onEnterFrame event to it, and that's it; the addChild line is not needed.
Duh.
Anyhow, as a result, Tweener, as of version 1.24.50, doesn't need the mandatory
init() anymore. It works like AS2: init() is called when needed, internally,
but it
be omitted from people's code.
Coding using older versions of Tweener will still work, as init() will properly
initialize Tweener, but it will ignore the first parameter entirely.
I've updated the version on the SVN repository now. Feel free to test. I've
tested
under Flash AS9, Flex SDK, and Flex SDK with SWFLoader, and it seems to be
working on
all cases with the same SWF/code.
Old SWFs embedded on SWFLoader will still spurt warnings as stage doesn't
exist, but
commenting out the init() line on such cases should fix it.
Let me know if it works for you guys.
Original comment by zisfor...@gmail.com
on 15 Apr 2007 at 2:15
Original issue reported on code.google.com by
mathew....@gmail.com
on 13 Apr 2007 at 9:58