Saturday, September 08, 2007

Very Important Event in AS3: Event.ADDED_TO_STAGE

Event.ADDED_TO_STAGE is SO important it's ridiculous I took me so long to find it.
If you're creating a swf that will be loaded by an external loader, you need this event to be trigger before even thinking about accessing any of the stage properties.
With this event you can access the stage from the loaded movieclip.

If you don't check this event, stage will only return null.


Loader:

var request:URLRequest = new URLRequest("yourConstructor.swf");
loader = new Loader();

loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);

function loadProgress(event:ProgressEvent):void {
var percentLoaded:Number = event.bytesLoaded/event.bytesTotal;
percentLoaded = Math.round(percentLoaded * 100);
trace("Loading: "+percentLoaded+"%");
}
function loadComplete(event:Event):void {
trace("Complete");
addChild(loader); // when this is done this will fire the Event.ADDED_TO_STAGE event
}


Loaded content class:


public function yourConstructor(){
this.addEventListener(Event.ADDED_TO_STAGE, init);
}

public function init(event:Event):void{
trace(stage.quality)
}

Labels: , ,


Comments:
OMG YOU R A LIFESAVER THANK YOU! I've been searching high and low for exactly this!
 
I am trying to load mySWF into a MC on my stage. I can't seem to get it to work properly.

I used a simple loader
// Simple Loader
var n = new Loader();
n.load(new URLRequest("CommercialJet_MC.swf"));
importMC.addChild(n);

But i was unable to get interaction between that to the root.
 
Thanks!! Looking all over for this piece of sage advice that seems to be missing from everyone's pre-loader tutorials. I'm so glad i found this page.
 
nice work!
 
Thank you for this post!
Got my complicated .swf with lots of classes also preloaded!
 
Hey!
You just saved my *ss! I
I had to delivery a huge project today and... I really looked around really the whole night...
Believe me, I was going to give up! This is a worldwide "THANK YOU!"

Sometimes things go wrong for such a little thing (well, only "after" you can tell was such a "little" thing... :-) )
 
Ran into this problem almost two years after your post! Thank you, this is apparently very overlooked given the number of hits I got on this issue while searching it on Google. It worked great and now I'm back on track :)
 
YOU ROCK!!! It really is an easy but MUST KNOWN event... I've searched for this for 3 days...
 
Typhoon in to the subhuman with two backs casinos? seal of submit on this advanced [url=http://www.realcazinoz.com]casino[/url] run and shtick evasively online casino games like slots, blackjack, roulette, baccarat and more at www.realcazinoz.com .
you can also stay our news [url=http://freecasinogames2010.webs.com]casino[/url] orientate at http://freecasinogames2010.webs.com and be the winner in lordly folding readies !
another corresponding unreservedly [url=http://www.ttittancasino.com]casino spiele[/url] purlieus is www.ttittancasino.com , during german gamblers, stretch over and beyond freed online casino bonus.
 
jewish dating web site [url=http://loveepicentre.com/]dating site in usa[/url] older women dating young guys http://loveepicentre.com/ church of christ singles
 
houston medical examiner [url=http://usadrugstoretoday.com/products/casodex.htm]casodex[/url] molecule stress ball http://usadrugstoretoday.com/categories/cholesterol.htm borderline personality disorder support group http://usadrugstoretoday.com/products/brand-viagra.htm
the hawaiian drug court program [url=http://usadrugstoretoday.com/categories/cardio-vasculaires.htm]cardio vasculaires[/url] cholesterol nad grapefruit [url=http://usadrugstoretoday.com/categories/control-de-la-natalidad.htm]urinary tract female[/url]
 
blood pressure medicine and aspirin [url=http://usadrugstoretoday.com/categories/perte-de-poids.htm]perte de poids[/url] herpes match washington http://usadrugstoretoday.com/categories/herz-kreislauf.htm teenage drug and alcohol abuse http://usadrugstoretoday.com/products/lanoxin.htm
illinois health insurance online quote [url=http://usadrugstoretoday.com/products/cleocin.htm]cleocin[/url] recommended cholesterol levels [url=http://usadrugstoretoday.com/products/differin.htm]involuntary mental health admission[/url]
 
how do doctors help create medicine [url=http://usadrugstoretoday.com/products/naprosyn.htm]naprosyn[/url] durable medical walkers http://usadrugstoretoday.com/categories/perdida-de-peso.htm cialis lawyer http://usadrugstoretoday.com/products/singulair.htm
diaco dental [url=http://usadrugstoretoday.com/products/generic-imitrex.htm]generic imitrex[/url] good nutrition pancreatic health [url=http://usadrugstoretoday.com/catalogue/m.htm]civil war reenacting ladies tea activities[/url]
 
http://newrx.in/bisoprolol/bisoprolol-5mg
[url=http://newrx.in/carbohydrate/advantages-of-low-carbohydrate-diet]find assistance for prescription drugs[/url] compare levitra and cialis [url=http://newrx.in/olanzapine/olanzapine-lawyers-los-angeles]olanzapine lawyers los angeles[/url]
gratten lake drug bust cananda http://newrx.in/erythromycin/uti-erythromycin
[url=http://newrx.in/restlessness/co-sleeping-and-restlessness]delta medicine cabonets[/url] athlete that got charge for using band drugs [url=http://newrx.in/glucophage/glucophage-ed-interactions]glucophage ed interactions[/url]
suboxone drug strip test http://newrx.in/warfarin/warfarin-and-coumadin-and-switch
[url=http://newrx.in/antabuse/antabuse-dosage]effects of using drugs[/url] levitra fedex [url=http://newrx.in/remeron/remeron-elevated-thyroid-levels]remeron elevated thyroid levels[/url] dot certified doctors and drug collection sites in georgia [url=http://newrx.in/letrozole/letrozole-in-treatment-of-elevated-levels]letrozole in treatment of elevated levels[/url]
 
http://www.behot.com.au/behotforum/viewtopic.php?f=2&t=71959 http://www.tsv-nord-bogensparte.de/phpbb/viewtopic.php?f=9&t=2521 http://www.ho-nehaso.com/forums/viewtopic.php?f=4&t=228420 http://www.bigleaftropicals.com/blt/viewtopic.php?f=2&t=49604
http://www.ekornes-racing.com/forum/viewtopic.php?p=258036#258036 http://www.evps.dk/forum/viewtopic.php?f=14&t=4408 http://winchesteryouthbaseball.com/forum/index.php?topic=159951.new#new http://200.68.89.81/openlate/foro/index.php?topic=88488.new#new
http://wiped-guild.co.uk/phpBB3/viewtopic.php?f=4&t=101894 http://sedonaustralia.com/forum/index.php?topic=313063.new#new http://www.amplifiedwebdesign.com/darktowerforum/viewtopic.php?f=2&t=237806
 
Seriously! I've been searching forever for a solution for this -- and after all that, it's so simple. Thanks for posting!
 
lottery winnersnorthcoralina http://wqm.in/casino-online_highest-paying-online-casino encore lottery
[url=http://wqm.in/casino-online_alton-bell-casino]illegal items in a casino[/url] casino niagara ray charles [url=http://wqm.in/lottery_florida-lottery-payment-field-office]florida lottery payment field office[/url]
national lottery results uk http://wqm.in/casino-playing-cards_detroit-playing-cards
[url=http://wqm.in/online-casinos_juegos-de-casinos]poker tour casino chips set[/url] resumes for casino professionals [url=http://wqm.in/betting_online-football-betting]online football betting[/url]
peppermill casino in wendover coupns http://wqm.in/joker_kids-joker-halloween-costumes fountainebleau casino las vegas [url=http://wqm.in/online-casinos_free-cash-casinos-no-deposit-required]free cash casinos no deposit required[/url]
 
space cowboys movie [url=http://moviestrawberry.com/films/film_stop_or_my_mom_will_shoot/]stop or my mom will shoot[/url] movie film http://moviestrawberry.com/hqmoviesbycountry/country_australia/?page=1 rocket launcher in movie commando
live free or die movie hard [url=http://moviestrawberry.com/films/film_next_avengers_heroes_of_tomorrow/]next avengers heroes of tomorrow[/url] fore play movie http://moviestrawberry.com/films/film_the_monolith_monsters/ caravan movie tibet
movie monologues for women [url=http://moviestrawberry.com/films/film_no_man_s_land_the_rise_of_reeker/]no man s land the rise of reeker[/url] lego brick movie
watch superbad the movie for free [url=http://moviestrawberry.com/films/film_the_it_crowd/]the it crowd[/url] gait cycle movie http://moviestrawberry.com/films/film_soylent_green/ across the universe movie forumz
movie players avi [url=http://moviestrawberry.com/films/film_traffic/]traffic[/url] myan movie mel http://moviestrawberry.com/films/film_the_lion_king_ii_simbas_pride/ beauty and the beast disney movie
 
lone star state of mind movie bloopers [url=http://moviestrawberry.com/films/film_faithful/]faithful[/url] classic movie http://moviestrawberry.com/films/film_hold_that_ghost/ cia movie pics
automator workflow quicktime movie convert [url=http://moviestrawberry.com/films/film_play_dead/]play dead[/url] science fiction movie tobor http://moviestrawberry.com/films/film_the_three_musketeers/ free 3gp anomal porn movie clips
lonely hearts movie review rating [url=http://moviestrawberry.com/films/film_my_super_ex_girlfriend/]my super ex girlfriend[/url] creampie movie gallery
casper van dien in gay porn movie [url=http://moviestrawberry.com/films/film_now_and_then/]now and then[/url] date movie trailer wedding http://moviestrawberry.com/films/film_jump_offs/ masque of the red death movie
movie about diana ross and supremes [url=http://moviestrawberry.com/films/film_jack_frost/]jack frost[/url] free music and lyrics movie torrent file http://moviestrawberry.com/films/film_breakfast_on_pluto/ movie schedule at camp humphreys
 
ninja turtle movie costumes [url=http://moviestrawberry.com/films/film_howard_the_duck/]howard the duck[/url] soundtrack for judie forsters new movie http://moviestrawberry.com/films/film_frankenstein/ movie still
movie dennis quaid [url=http://moviestrawberry.com/films/film_kisses_and_caroms/]kisses and caroms[/url] angelina jolie movie sex scenes http://moviestrawberry.com/films/film_ice_age_dawn_of_the_dinosaurs/ halloween movie nude scenes
harry potter and the order of the phoenix movie [url=http://moviestrawberry.com/films/film_human_instinct/]human instinct[/url] mona lisa smile full movie download
sunshine movie [url=http://moviestrawberry.com/films/film_pride_and_glory/]pride and glory[/url] vintage sci fi movie posters http://moviestrawberry.com/films/film_demonlover/ circus boy movie
hitman movie trailor [url=http://moviestrawberry.com/films/film_three_days_to_vegas/]three days to vegas[/url] relivance of the title cadet kelly to the scrip of the movie http://moviestrawberry.com/films/film_santa_s_slay/ steppin out movie
 
Don't forget to remove the listener in the init function. :)

Brilliant code.
 
to buy [URL=http://jacket-dresses.net/]moncler[/URL] to your friends qMhTqJEp [URL=http://jacket-dresses.net/ ] http://jacket-dresses.net/ [/URL]

 
At the [url=http://www.jordango2013.com/Wholesale-air-jordan-shoes-8_c8]wholesale Air Jordan Shoes 8[/url] rally in Tehran, thousands of opposition supporters turned out, shouting [url=http://www.jordango2013.com/Wholesale-air-jordan-4-high-heels_c29]wholesale Air Jordan 4 High Heels[/url] slogans [url=http://www.jordango2013.com]nike jordan wholesaler[/url] in support of defeated presidential candidate Mir-Hossein Mousavi. Reports say there were [url=http://www.jordango2013.com/Wholesale-air-jordan-2012_c16]wholesale Air Jordan 2012[/url] clashes between police and protesters as the march progressed, with some arrests. Stones were thrown, and police [url=http://www.jordango2013.com]wholesale nike jordan[/url] used tear gas


 
lk9bjjwl

mi42ze1i

f39s020t9d

qq1tcgt6

pka38r65
 
Hi, guantanamera121212
 
ft xaorwqfmh[url=http://www.shopnorthface.co.uk/#94815]North Face Outlet[/url]
[url=http://www.shopnorthface.co.uk/#North-Face-jacket]North Face jacket[/url]
 
get MojhzPsE [URL=http://www.replica-handbags2013.com/]replicas handbags[/URL] and get big save GhRdCxDJ [URL=http://www.replica-handbags2013.com/ ] http://www.replica-handbags2013.com/ [/URL]

 
buy grImGvTg [URL=http://www.prada-outlet2013.net/]prada outlet[/URL] with confident Ihvqvgoc [URL=http://www.prada-outlet2013.net/ ] http://www.prada-outlet2013.net/ [/URL]

 
I am sure you will love RRfplTLl [URL=http://www.replica-handbags2013.com/]replica bags[/URL] for more detail yqKLlxdP [URL=http://www.replica-handbags2013.com/ ] http://www.replica-handbags2013.com/ [/URL]

 
must look at this WMQJZQTg [URL=http://www.uggs-outlet2013.com/]uggs outlet store[/URL] to get new coupon frVsKTUr [URL=http://www.uggs-outlet2013.com/ ] http://www.uggs-outlet2013.com/ [/URL]

 
check qMNKeNIK [URL=http://www.spyder-jackets2013.com/]spyder outlet[/URL] for promotion code aQeMpvkH [URL=http://www.spyder-jackets2013.com/ ] http://www.spyder-jackets2013.com/ [/URL]

 
[url=http://www.bestnikeaustore.com]http://www.bestnikeaustore.com[/url] [url=http://www.lovenikenz.com]http://www.lovenikenz.com[/url]
fpvwii jxuf , jdybn pzquz pfoxh ptqqggmb mqsqiis .
49 [url=http://www.lovenikenz.com/#Nike-NZ]Nike NZ[/url]
 
the golden compass free ebook http://audiobooksworld.co.uk/D-Alessandro/m23366/ death note another note ebook [url=http://audiobooksworld.co.uk/Music-Power-and-Politics/p159477/]sql 101 ebook[/url] iphone overdrive ebook
 
billige uggs bsjpdffy ugg norge obygeies ugg sko kiwzlyso ugg pugseclz uggs australia mwjhaclc uggs norge mancxunq uggs p? nett kkndgtlg uggs sko hratlxcm uggs azwnsnce

 
Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?