# How to use classes to create/attach movieclip?

**URL:** <https://forum.kirupa.com/t/how-to-use-classes-to-create-attach-movieclip/205632>\
**Category:** flash\
**Created:** [October 31, 2006, 1:16pm UTC](https://forum.kirupa.com/t/how-to-use-classes-to-create-attach-movieclip/205632 "2006-10-31T13:16:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmukunth](https://avatars.discourse-cdn.com/v4/letter/j/94ad74/32.png) [@jmukunth](https://forum.kirupa.com/u/jmukunth)\
**Post date:** [October 31, 2006, 1:16pm UTC](https://forum.kirupa.com/t/how-to-use-classes-to-create-attach-movieclip/205632/1 "2006-10-31T13:16:06Z")

</div>

Hi,

I m new to Flash. I need to develop Flash application for mobile devices.  
I have created a class and using that class i created a movieclip.

I have created one more class. And whenever the enter key of the mobile device is pressed i need to create a movie clip using the second class.  
How to do this?

[COLOR=“Blue”]this.attachMovie(“PieChart\_mc”, “pie\_chart”+vPieChartDepth\_num+"\_mc", vPieChartDepth\_num, vPieChartProperties\_obj);  
var vThisPieChart\_mc= this[“pie\_chart”+vPieChartDepth\_num+"\_mc"];

keyListener.onKeyDown = function() {

switch (Key.getCode()) {  
case Key.UP :  
vThisPieChart\_mc.highlightPreviousWedge();  
break;  
case Key.DOWN :  
vThisPieChart\_mc.highlightNextWedge();  
break;  
case Key.LEFT :  
vThisPieChart\_mc.highlightPreviousWedge();  
break;  
case Key.RIGHT :  
vThisPieChart\_mc.highlightNextWedge();  
break;  
case Key.ENTER :  
vThisPieChart\_mc.removeMovieClip();

var newDepthNumber:Number;  
newDepthNumber = vPieChartDepth\_num + 1;  
trace("New depth Number : " + newDepthNumber);

this.attachMovie(“Displaydetails\_mc”, “display\_details”+newDepthNumber+"\_mc", 1);  
var vDisplaydetails\_mc= this[“display\_details”+newDepthNumber+"\_mc"];  
trace(vDisplaydetails\_mc);  
//// [COLOR=“Red”]This trace gives the result as ‘Undefined’[/COLOR]

default :

break;  
}  
};  
[/COLOR]

I dont know what’s the problem? I want to remove or unload the previous movie(Which shows a piechart) and to load another movie(which shows details in a table).

Can anyone please help me?

Thankfully,  
jmukunth
