View Full Version : Loading Symbol in Constructor.

08-30-2008, 06:58 PM
hi there,
i just began to learn creating flash files. as i understood, symbols are some kind of graphical templates. when i am wrong, please teach me. so i added a person symbol with all the gfx and what ever is in there. then i made a person.as class. and added this to my person symbol props. then at my main action i do this

action in fla

import test.person;

var probant = new person();

and person do this.


package test
import flash.text.TextField;
import flash.display.MovieClip;

public class person extends MovieClip {

var name;

function person () {

function setName (setThis) {
name = setThis;


person is now an object stored in "probant" if i am right. so as i can see, it is done. but my symbol does not appear. i tried some things like "attachMovie()" but as i know this is not possible with ActionScript 3.0. how can i load my symbol on every object getting created?


var probant1 = new person();
var probant2 = new person();
var probant3 = new person();

... now i like to see 3 persons at my flash

sorry for my english

08-30-2008, 07:23 PM
Howdy and Welcome... :)

First of all, you will need to create a movieClip in your FLA file with its Class set to 'Person' and the ActionScript should be looking similar to this...
import flash.display.MovieClip;

public class PersonTest extends MovieClip
public function PersonTest()

private function init():void
for (var i:uint = 0 ; i < 3 ; i++)
var p:Person = new Person();
p.x = i * 100 + 100;
p.y = 100;

08-30-2008, 11:07 PM
wow thank you. this looks great. but i do not understand everything.
so. you created a movieclip called person. in props you entered person as class,
so it will use "person.as" as class, right?.
how can i access this as file in adobe flash?
when i look in persontest.fla actions, there is no code. when is that symbol called? where is it called? sorry for my stuido questions but flash seems to be very confusing. i will study your example tomorrow just to late right now. thanks so far.

08-31-2008, 12:06 AM
There is no Person.as file... Flash IDE automatically creates one and saves it inside the SWF file... So, you cannot really access it the way you mentioning it...

If you look at the stage property, there is one called Document class where I have specified the name of the as file that the FLA file will automatically open & compile when you test/publish the movie...

08-31-2008, 10:34 AM
that confuses me at all ;) sorry but i dont understand this.
as i learned OO i realized you can build classes and create object from them.
why does this not work?

person = new PersonTest();

but, more interessting for me is why the class PersonTest get created without a calling or creating an object from the type PersonTest.

and how can i add methods to Person?

i just tried to create a new project and wanted to add this document class, but all i get is a error with this caption http://www.chdir.de/_downloads/error.png. how did you create the document class?

08-31-2008, 10:49 AM
There is no Person.as file... Flash IDE automatically creates one and saves it inside the SWF file... So, you cannot really access it the way you mentioning it...

Umm... that's not correct. If you do create (it's not necessary, but you can do it) a Person.as file and give a linkage class of Person to a symbol, then that symbol IS linked to the Person.as file you created.

And yes, if you don't create a Person.as file then the IDE will create one for you.

08-31-2008, 02:36 PM
Yup... That's correct, but I was simply pointing it out specific to this case... ;)

What is the value you provided for the Document class??? 'PersonTest' or 'PersonTest.as'??? You should use 'PersonTest'...

08-31-2008, 08:32 PM
i make a new flash project. is save it called "newTest" then i type in "newTest" as document class. all what i get is a msg with this:
but i can not find to access this class. please help me at the other questions in post from "Today 10:34 AM". thank you so far