actionscript - How to remove MovieClip by selecting a row and pressing a delete button? -


i have datagrid, rows added. whenever row added, movie clip added stage. added button remove row in datagrid if row , button clicked, , of works well.

however, when try remove movie clip relating row in datagrid, not work.

my code is:

function removeloaditem(event:mouseevent) { datagrid.removeitemat(datagrid.selectedindex); removechild(movieclip(datagrid.selectedindex); } 

removechild(movieclip(datagrid.selectedindex); 

you need understand line of code trying do.

datagrid.selectedindex 

this variable number. so, trying cast number movieclip.

movieclip(1) 

that not work. need reference actual movieclip object. wherever creating movieclip object, need store reference object. can have plain object store of references.

var objectlist:object = {}; 

and then, wherever creating movieclip, add line:

objectlist["reference_" + datagrid.selectedindex] = "movieclip variable"; 

replace "movieclip variable" reference movieclip object. after that, replace current removechild line these 2 lines:

var movieclip = objectlist["reference_" + datagrid.selectedindex] moveclip.parent.removechild(movieclip); 

Comments

Popular posts from this blog

Capture and play voice with Asterisk ARI -

java - Why database contraints in HSQLDB are only checked during a commit when using transactions in Hibernate? -

visual studio - Installing Packages through Nuget - "Central Directory corrupt" -