flash - Array elements (MovieClips) are being deleted as I add new ones. Why? -
i'm having trouble odd behavior in actionscript 2.0. i'm trying add number of pages (movieclips) stage, , @ same time store references in convenient array later access. here code (assume variables have been declared):
_adpages = new array(); _adpages[0] = adpagetrack.attachmovie("adpage", "adpage0" + 0, getnexthighestdepth()); _adpages[0].init( _aditems[0] ); _adpages[0]._x = 0 * 10; _adpages[1] = adpagetrack.attachmovie("adpage", "adpage0" + 1, getnexthighestdepth()); _adpages[1].init( _aditems[1] ); _adpages[1]._x = 1 * 10; _adpages[2] = adpagetrack.attachmovie("adpage", "adpage0" + 2, getnexthighestdepth()); _adpages[2].init( _aditems[2] ); _adpages[2]._x = 2 * 10; _adpages[3] = adpagetrack.attachmovie("adpage", "adpage0" + 3, getnexthighestdepth()); _adpages[3].init( _aditems[3] ); _adpages[3]._x = 3 * 10; trace(_adpages); (var i:number = 0; < 4; i++) { trace("ad page x coordinate: " + _adpages[i]._x); trace("ad page y coordinate: " + _adpages[i]._y); }
this loop, has been exploded can examine more closely. note trace statements. should output array of movieclip handles, followed list of x , y coordinates. instead, output this:
,,,_level0.main.adpagetrack.adpage03 ad page x coordinate: undefined ad page y coordinate: undefined ad page x coordinate: undefined ad page y coordinate: undefined ad page x coordinate: undefined ad page y coordinate: undefined ad page x coordinate: 30 ad page y coordinate: 0
where last item set have been deleted. if delete fourth item, third item intact while others disappear.
does know happening here? bug or missing language?
you need use adpagetrack.getnexthighestdepth() when attach movieclip otherwise every attachmovie call erase previous one.
_adpages[0] = adpagetrack.attachmovie("adpage", "adpage0" + 0, adpagetrack.getnexthighestdepth()); [...]
Comments
Post a Comment