Tuesday, March 6, 2007

Error on adding FullScreenListener in creationComplete handler

This is an issue i hit upon while i was doing the Full Screen App (you can see it here). I wanted to add a listener to listen for the FullScreenEvent (package flash.events.FullScreenEvent) in my Application. So i put that onto my creationComplete handler on the Application, i.e.

mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" creationComplete="initStuff()"

and

private function initStuff():void{
stage.addEventListener(FullScreenEvent.FULL_SCREEN, handleFullScreen);
}

But, this threw a real time error (RTE) saying...

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at JustFullScreen/::initStuff()
at JustFullScreen/_Application1_creationComplete()

The above error means that the "stage" object is null when it is trying to set the listener. What perplexes me is that if i put this addListener code in a later part of the application, it works. Which means that the stage is getting intitialized between the Application's creationComplete and the place in the code where i'm calling it. Is this a bug or does the stage get initialized later, dispatching a different event? I'm still digging.

Addendum (half hour later): I observed now that including the SystemManager class (mx.managers.SystemManager) and then using the following code in the creationComplete handler works.

import mx.managers.SystemManager;

private function initStuff():void{
systemManager.stage.addEventListener(
FullScreenEvent.FULL_SCREEN, handleFullScreen);
}

So why is the systemManager object required if it is in the creationComplete handler and not if it is in a later part of the code... I'm confused now!!! Gotta tread back to the Flex Gurus :)
The code is here...
Addendum again (the next day) - Thanks Joan for the info. Thanks to her, i found the solution for the above problem...

It seems that the stage is available only after the updateComplete or applicationComplete Events. Read the post that demystified things for me...

4 comments:

Anonymous said...

It looks like some other people have run into this same problem. Here is the post:
http://www.wietseveenstra.nl/blog/?p=53

It looks like you should be able to the access the stage object after the updateComplete event or the applicationComplete event. I didn't even know there was an applicationComplete event! Anyways, good luck!

Anonymous said...

Thanks.Best Regards
Erotik Shop, Erotik Market, Erotic shop, Sex shop, Geciktirici, Seks shop, Penis Buyutucu, cialis, kamagra, viagra, sexshop, seksshop, erotic market, virility pills

sex shop -

sex shop -

sex shop -

seks shop -

seks shop -

seks shop -

erotik shop -

erotik shop -

penis buyutucu -

penis buyutucu -

penis buyutucu -

erotik shop -

seks shop -

sex shop -
erotik shop -
erotik market -

vidrom.com -

video share -

file upload -
free file -

image upload -

erotik market -
erotic market -
erotik market -
erotik market -
erotic shop -
erotic shop -
erotic shop -

alisveris -

12 taksit -

feromon -

Kozmetik
Shopseks.com
Hepzinde.com
penis buyutucu -
penis buyutucu -
virility pills -
elektronik sigara -
virility pills -
penis buyutucu -
penis buyutuculer -
bayan ic giyim -
virility pills -
elektronik sigara
feromon

Anonymous said...

Play Casino Games For Real Money With an Amazing $1,000! Enjoy the Roulette, Slots, Blackjack & all your Favorite Games. Download, Sign Up & Collect Your Bonus!
[URL=http://durakoff.net/gforum/link/online%20casino%20gambling/3_gambling2.html][IMG]http://durakoff.net/gforum/imggforum/online%20casino%20gambling/3_gambling2.png[/IMG][/URL]
[url=http://jqtuooi.angelcities.com/index.html]aldactone [/url]

Anonymous said...

Looking for the best Online Casino, Online Poker, and Online Bingo bonuses? These are the most current and best paying available. Start here and you won't be sorry. USA PLAY WELCOME!
[URL=http://ejlqilm.t35.com/casino-airy]casino airy[/URL] [URL=http://ejlqilm.t35.com/casino-air]casino air[/URL] [URL=http://ejlqilm.t35.com/casino-ads]casino ads[/URL] [URL=http://ejlqilm.t35.com/casino-ace]casino ace[/URL] [URL=http://ejlqilm.t35.com/casino-advertisements]casino advertisements[/URL]
[URL=http://durakoff.net/gforum/link/online%20casino%20gambling/1_gambling1a.html][IMG]http://durakoff.net/gforum/imggforum/online%20casino%20gambling/1_gambling1a.png[/IMG][/URL]
[URL=http://durakoff.net/gforum/link/online%20casino%20gambling/2_gambling1b.html][IMG]http://durakoff.net/gforum/imggforum/online%20casino%20gambling/2_gambling1b.png[/IMG][/URL]
[URL=http://ejlqilm.t35.com/casino-affiliates/atlantic-city-borota-casino.html]atlantic city borota casino[/URL] [URL=http://ejlqilm.t35.com/casino-advertisements/alan-samuels-casino-host.html]alan samuels casino host[/URL] [URL=http://ejlqilm.t35.com/casino-affiliates/american-casino-show.html]american casino show[/URL] [URL=http://ejlqilm.t35.com/casino-ako/casino-and-hotels-in-tunica-mississippi.html]casino and hotels in tunica mississippi[/URL] [URL=http://ejlqilm.t35.com/casino-air/la-center-or-casino.html]la center or casino[/URL]
------------------------------------------
[URL=http://ejlqilm.t35.com/casino-affiliates/american-casino-wa.html]american casino wa[/URL] [URL=http://ejlqilm.t35.com/casino-alicante/cadilac-island-casino.html]cadilac island casino[/URL] [URL=http://ejlqilm.t35.com/casino-ako/casino-bathroom-theme.html]casino bathroom theme[/URL] [URL=http://ejlqilm.t35.com/casino-ads/atlantic-city-resorts-casino-jobs.html]atlantic city resorts casino jobs[/URL] [URL=http://ejlqilm.t35.com/casino-air/casino-royale-actor.html]casino royale actor[/URL]
[URL=http://durakoff.net/gforum/link/online%20casinos/1_gambling2.html][IMG]http://durakoff.net/gforum/imggforum/online%20casinos/1_gambling2.png[/IMG][/URL]
[URL=http://ejlqilm.t35.com/casino-account/native-american-indian-casino-development-partners.html]native american indian casino development partners[/URL] [URL=http://ejlqilm.t35.com/casino-alicante/buy-wii-vip-casino-blackjack.html]buy wii vip casino blackjack[/URL] [URL=http://ejlqilm.t35.com/casino-acura/casino-machine-a-sous.html]casino machine a sous[/URL] [URL=http://ejlqilm.t35.com/casino-air/how-much-do-casino-dealers-make.html]how much do casino dealers make[/URL] [URL=http://ejlqilm.t35.com/casino-account/mortgage-loan-amazon-casino-online.html]mortgage loan amazon casino online[/URL]
[URL=http://ejlqilm.t35.com/casino-airy/casino-bus-tx-la.html]casino bus tx la[/URL] [URL=http://ejlqilm.t35.com/casino-advantages/belle-of-sioux-city-iowa-casino.html]belle of sioux city iowa casino[/URL] [URL=http://ejlqilm.t35.com/grand-victory-casino-indiana.html]grand victory casino indiana[/URL] [URL=http://ejlqilm.t35.com/casino-account/coushatta-indian-casino-grand-opening.html]coushatta indian casino grand opening[/URL] [URL=http://ejlqilm.t35.com/casino-account/new-frontier-hotel-and-casino.html]new frontier hotel and casino[/URL]