Hi, I think the stage has not yet been initiated, hence the addChild is not working. Try to get hold of the stage first and then so an addChild.
if(stage){ }else{ addEventListener(Event.ADDED_TO_STAGE, onAddedToStage, false, 0, true); } private function onAddedToStage(e:Event):void { removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage); addChild(...); } Hope this helps. Warm Regards Deepanjan Das M: +91 9836582808 W: http://deepanjandas.wordpress.com "Think of the environment before printing this email" On Fri, Jul 16, 2010 at 8:26 AM, J.C. Berry <jcharlesbe...@gmail.com> wrote: > Dear Group, > I wondered if I could bother you a minute with a simple question. I have a > document class that extends MovieClip, but my problem arises when I use > addChild to add some popups (movieclips) to the stage. They are only > visible > when I attach my popups to an on-stage button: > mystagebtn.addChild(mypopup) but I get nothing when attaching using > addChild() or this.addChild or this.parent.addChild What reasons can > there > be for my clips not being visible? As I said, my document class does > extend > MovieClip and I have searched for a few days now and reading on the doc > class has not given me an answer. I wouldn't even mind a reference to a > tutorial that could help me. Thanks. > -JC > > On Wed, Jul 7, 2010 at 6:55 AM, allandt bik-elliott (thefieldcomic.com) < > alla...@gmail.com> wrote: > > > does this line work? > > > > > > > DynaBtn.addEventListener(MouseEvent.MOUSE_OVER,DynaBtnRollOverHandler(CityNum)); > > > > i wouldn't have thought it would (by using the brackets you are calling > > that > > function straight away) > > > > it should be > > > > > DynaBtn.addEventListener(MouseEvent.MOUSE_OVER,DynaBtnRollOverHandler); > > } > > > > private function DynaBtnRollOverHandler(e:Event):void > > { > > // handle event > > } > > > > and cityNum should be a property on DynaBtn so that you can use > > (e.target as DynaBtn).cityNum > > to recall the correct number > > > > best > > a > > > > On 7 July 2010 14:40, Kerry Thompson <al...@cyberiantiger.biz> wrote: > > > > > J.C. Berry wrote: > > > > > > > I wondered if I could bother you to review the code below and make > > > comments > > > > and suggestions. > > > > > > It's not bad at all, especially for your first class. I didn't go > > > through all your code, but one thing jumped out at me. These lines > > > might give you problems: > > > > > > for(var i=0;i<NumOfCities;i++){ > > > CityNum = i; > > > var DynaBtn = root['city'+CityNum+'_mc']; > > > DynaBtn.gotoAndStop(1); > > > > > > > > > > DynaBtn.addEventListener(MouseEvent.MOUSE_OVER,DynaBtnRollOverHandler(CityNum)); > > > DynaBtn.addEventListener(MouseEvent.MOUSE_OUT,DynaBtnRollOutHandler); > > > > > > First, you are going to have only one DynaBtn variable--the last one > > > declared in the for loop. Each time you create an instance, it > > > overwrites the last one. Fortunately for you, it works, but it won't > > > always. > > > > > > The second issue is adding an event listener from outside the object. > > > DynaBtn.addEventListener() will add the listener to the button, but > > > you won't be able to remove the listener from outside the button. > > > > > > Instead, you should have a DynaBtn class, and add the listener in the > > > constructor. Then you can remove the event listeners when you clean > > > up. > > > > > > This applies, of course, to all the buttons you created. > > > > > > Nice job overall, though. > > > > > > Cordially, > > > > > > Kerry Thompson > > > _______________________________________________ > > > Flashcoders mailing list > > > Flashcoders@chattyfig.figleaf.com > > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > > > > _______________________________________________ > > Flashcoders mailing list > > Flashcoders@chattyfig.figleaf.com > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > > > > > -- > J.C. Berry, M.A. > UI Developer > 619.306.1712(m) > jcharlesbe...@gmail.com > portfolio: http://Client:maz...@www.mindarc.com > > ------------------------------------------------------------------------------------------------------------------------------------------------ > > This E-mail is covered by the Electronic Communications Privacy Act, 18 > U.S.C. ?? 2510-2521 and is legally privileged. This information is > confidential information and is intended only for the use of the individual > or entity named above. If the reader of this message is not the intended > recipient, you are hereby notified that any dissemination, distribution or > copying of this communication is strictly prohibited. > > ------------------------------------------------------------------------------------------------------------------------------------------------ > _______________________________________________ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > -- _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders