been fixed, I just forgot to initialize the EventDispatcher. sorry for the stupid question. :(
2005/12/5, old9 <[EMAIL PROTECTED]>: > > Hi there, > I've wasted the whole afternoon with the event and listener thing, I know > it could be another basic question, > but I just cant figure it out.... > please help.. > > > //in ParaControl.as > //here I defined 3 functions to receive the events sent by the ParaHolder > instance > //but there is something wrong: > ... > public function onFirst(eventObj:Object){ > trace("onFirst received from "+eventObj.target);//------------- > not traced > } > public function onLast(eventObj:Object){ > trace("onLast received from "+eventObj.target); > } > public function onMiddle(eventObj:Object){ > trace("onMiddel received from "+eventObj.target); > } > ... > > > > > //in ParaView.as > //ParaView is used to hold them all and assign ParaControl as a listener > to ParaHolder. > ... > public function ParaView(timeline:MovieClip){ > tl = timeline; > pd = new ParaData(); > pd.loadData > ("data/1U01pBT.xml","data/normal.css","data/active.css"); > pd.addEventListener("onDataReady",this); > Stage.scaleMode = "noscale"; > pc = new ParaControl(tl); > pc.addEventListener("click",this); > } > > public function onDataReady(eventObj:Object){ > ph = MCE.attachMovie(tl,"paraHolder","mainph", > tl.getNextHighestDepth(),{},ParaHolder,[pd]); > ph._x=0; > ph._y=0; > ph.addEventListener("onFirst",pc); > ph.addEventListener("onLast",pc); > ph.addEventListener("onMiddle",pc); > //I've also tried to define the 3 funtions here(in ParaView.as), > and changed "pc" to "this", but it does not work, either. > } > ... > > > > //in ParaHolder.as > //this is where I dispatch my event. > .. > private function _checkStatus(){ > if(_currentPage == 1){ > dispatchEvent({type:"onFirst", target:this}); > trace("onFirst fired");//-------------this can be traced, so I > think the event is dispatched successfully > }else if(_currentPage == _pages.length){ > dispatchEvent({type:"onLast", target:this}); > trace("onLast fired"); > }else{ > dispatchEvent({type:"onMiddle", target:this}); > trace("onMiddle fired"); > } > } > .. > > hope those make sense, > any suggestion? > > Thanks > > > -- t.E.l : +8605513602273 m.o.B : +8613855184110 q.Q : 7387905 B.L.o.G : http://old9.wordpress.com E.m.A.i.L : qi.jiahui⊕gmail.com
_______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders