# Creating a symbol within a class

**URL:** <https://forum.kirupa.com/t/creating-a-symbol-within-a-class/281822>\
**Category:** flash\
**Created:** [February 13, 2009, 2:07pm UTC](https://forum.kirupa.com/t/creating-a-symbol-within-a-class/281822 "2009-02-13T14:07:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ersk](https://avatars.discourse-cdn.com/v4/letter/e/a9a28c/32.png) [@Ersk](https://forum.kirupa.com/u/Ersk)\
**Post date:** [February 13, 2009, 2:07pm UTC](https://forum.kirupa.com/t/creating-a-symbol-within-a-class/281822/1 "2009-02-13T14:07:34Z")

</div>

I have a class called “playerClass” which I want to create multiple players from. I have made a movie clip symbol called “soldierOrange” and exported it for actionscript. I have also removed it off the stage. I have tried various bits of code to add it to a child and then the stage, read many tutorials but nothing has worked so far.

Here is my code below with the unrelevent code taken out.

```auto
[COLOR="Blue"]package[/COLOR]{

[COLOR="blue"]import flash.display.*[/COLOR];

[COLOR="blue"]public class[/COLOR] playerClass{  

        [COLOR="blue"]public var [/COLOR]playerName:[COLOR="blue"]String[/COLOR] = [COLOR="Green"]"playerName"[/COLOR]; 
	[COLOR="DimGray"]//other variables[/COLOR]

	[COLOR="Blue"]public function[/COLOR] playerClass(playerName:[COLOR="blue"]String[/COLOR] = [COLOR="Green"]""[/COLOR], ...){
		[COLOR="Blue"]this[/COLOR].playerName = playerName;  
		...
		[COLOR="blue"]var[/COLOR] hero:soldierOrange = [COLOR="blue"]new[/COLOR] soldierOrange();
		[COLOR="blue"]stage.addChild[/COLOR](hero);
	}

	[COLOR="DimGray"]//other functions[/COLOR]
	
}[COLOR="DimGray"]//end playerClass[/COLOR]

}[COLOR="DimGray"]//end package[/COLOR]

```

In my main flash document I created a new playerClass called “player1” and I traced all the properties which worked fine. I tried to refer to the .x and .y properties of my new instance “hero” but this is what is giving me errors.

```auto
[COLOR="Blue"]var[/COLOR] player1:playerClass = [COLOR="blue"]new[/COLOR] playerClass([COLOR="Green"]"3RSK"[/COLOR], ...);

[COLOR="Blue"]trace[/COLOR](player1.playerName); [COLOR="DimGray"]//3RSK[/COLOR]
[COLOR="DimGray"]//other traces[/COLOR]

[COLOR="Blue"]this[/COLOR][player1.hero][COLOR="blue"].x[/COLOR] = 30;
[COLOR="blue"]this[/COLOR][player1.hero][COLOR="blue"].y[/COLOR] = 30;

```

Any help would be really appreciated, thanks in advance.
