# Still Some Problems with Classes!

**URL:** <https://forum.kirupa.com/t/still-some-problems-with-classes/59503>\
**Category:** Uncategorized\
**Created:** [August 1, 2004, 12:16pm UTC](https://forum.kirupa.com/t/still-some-problems-with-classes/59503 "2004-08-01T12:16:27Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sim085](https://avatars.discourse-cdn.com/v4/letter/s/dfb087/32.png) [@Sim085](https://forum.kirupa.com/u/Sim085)\
**Post date:** [August 1, 2004, 12:16pm UTC](https://forum.kirupa.com/t/still-some-problems-with-classes/59503/1 "2004-08-01T12:16:27Z")

</div>

Hi to all!!, I just got Macromedia Flash MX 2004 and started trying to make classes that build movies on my main screen (since this is the reason why I bouth it in the first place) … How ever I don know why it doesn’t want to create even a simple line!!!

I have **attached** the coding I have done so far, however below I placed the code of the function that is cousing the error:

[font=Courier New][color=slategray]/\*\*[/color][/font]  
[font=Courier New][color=slategray]_[/color][/font]  
[font=Courier New][color=slategray]_/[/color][/font]  
[font=Courier New][color=navy]public function[/color] LoadFrame(x:[color=navy]Number[/color], y:[color=navy]Number[/color], layer:[color=navy]Number[/color]){  
[color=slategray]// Refreshing global variables.[/color]  
frameXPos=x; [/font][font=Courier New][color=slategray]// Frame x co-ordinates.  
[/color]frameYPos=y; [color=slategray]// Frame y co-ordinates.[/color]  
frameLayerPos=layer; [color=slategray]// Frame layer position.[/color][/font]  
[font=Courier New][color=slategray]// Creating the emoty movie clip that  
// that will store the new frame objects.  
[/color][color=navy]\_parent[/color].[color=navy]createEmptyMovieClip[/color]([color=blue]“Frame”[/color], layer);

[color=navy]this[/color].Frame.[color=navy]createTextField[/color]([color=blue]“txtMessageArea”[/color], 1000, 20,20,100,20);  
[color=navy]this[/color].Frame.txtMessageArea.[color=navy]text[/color]=[color=blue]“Hello”[/color];  
[color=navy]this[/color].Frame.[color=navy]createEmptyMovieClip[/color]([color=blue]“container”[/color], 2);  
[/font]  
[font=Courier New][color=slategray]// Creating a simple line[/color]  
[color=navy]with/color{  
[color=navy]lineStyle[/color](0,0x000000, 100)  
[color=navy]moveTo[/color](0, 0);  
[color=navy]lineTo[/color](25, 0);  
}[/font]  
[font=Courier New][color=slategray]// Setting the frame settings.[/color]  
[color=navy]this[/color].Frame.width = [color=navy]this[/color].frameWidth;  
[color=navy]this[/color].Frame.height = [color=navy]this[/color].frameHeight;  
[color=navy]this[/color].Frame.\_x = [color=navy]this[/color].frameXPos;  
[color=navy]this[/color].Frame.\_y = [color=navy]this[/color].frameYPos;  
[color=navy]trace/color;  
}[/font]

The compiler tells me that the problem is with the [font=Courier New][color=navy]with[/color][/font] block (because can not find the [font=Courier New][color=navy]movieClip[/color][/font] container. However as you can see this movie clip is created exacttly before the [font=Courier New][color=navy]with[/color][/font] block. Also neither the text are created is being displayed.

I don’t know why there is the problem, all I know is that in the MX version it works ☹

I would be very greatfull to who ever know the answer for this problem. Thanks to all in advance!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 1, 2004, 12:26pm UTC](https://forum.kirupa.com/t/still-some-problems-with-classes/59503/2 "2004-08-01T12:26:10Z")

</div>

actually, isnt Frame a keyword already used by Flash?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 1, 2004, 1:18pm UTC](https://forum.kirupa.com/t/still-some-problems-with-classes/59503/3 "2004-08-01T13:18:45Z")

</div>

Usually Flash keywords are higlited in a dark Blue color, and Frame did not higlight for me!! I changed it to SFrame but it still gave the same problem … I dont think it’s the fault of the name!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 1, 2004, 1:35pm UTC](https://forum.kirupa.com/t/still-some-problems-with-classes/59503/4 "2004-08-01T13:35:42Z")

</div>

I could be wrong. Just seems like one :crazy:

You could try tracing the movieclip (that you’re creating the things in) to make sure it exists before you try making things in it. If that does exist, then trace what you make in it to see if they exist. You might be able to find the trouble maker then

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 1, 2004, 11:04pm UTC](https://forum.kirupa.com/t/still-some-problems-with-classes/59503/5 "2004-08-01T23:04:00Z")

</div>

Are you exporting in Flash 7 or Flash 6? Also in Flash MX 2004 (exporting AS 2.0 and player 7) all variables must be declared before using them. It was not so in MX using AS 1.0. Have you done that? I hope that helps.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 2, 2004, 1:24am UTC](https://forum.kirupa.com/t/still-some-problems-with-classes/59503/6 "2004-08-02T01:24:31Z")

</div>

try changing this:

[AS]  
\_parent.createEmptyMovieClip(“Frame”, layer);  
[/AS]

to this:

[AS]  
this.createEmptyMovieClip(“Frame”, layer);  
[/AS]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 2, 2004, 1:30am UTC](https://forum.kirupa.com/t/still-some-problems-with-classes/59503/7 "2004-08-02T01:30:22Z")

</div>

you should not be using **\_parent** and **this**. ask yourself what these refer to.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 2, 2004, 1:30pm UTC](https://forum.kirupa.com/t/still-some-problems-with-classes/59503/8 "2004-08-02T13:30:14Z")

</div>

First of all Thanks and sorry for not replying immediatlly, but I was at my aunties house and there aren’t any computers there ☹

I tried not to use the \_parent and this, but when I did that it gave me the following error: No function with name createEmptyMovieClip found!!

I don’t think the class is creating anything coz neither the first movie were I am placing the TextBox is being dispalyed in the movie.

I feel as if i need a cry :’(

Thanks to all again 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 2, 2004, 2:01pm UTC](https://forum.kirupa.com/t/still-some-problems-with-classes/59503/9 "2004-08-02T14:01:05Z")

</div>

ok, ok. let me take a closer look.

So… this is in a class I take it? What is the class called? Is it correctly extending MovieClip? Do you have a MovieClip associated with this class in the library and are you correctly attaching it in the timeline? Have you traced the instances of the clips you are trying to create to make sure they exist first? Making sure no conflicting depths?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 2, 2004, 5:21pm UTC](https://forum.kirupa.com/t/still-some-problems-with-classes/59503/10 "2004-08-02T17:21:49Z")

</div>

Hi This explnation should be correct: I want to create classes that when used will create objects on the different frame. I want that with my classes I can do the following coding in my .fla files to create new items:

[font=Courier New]var M:MessageBox = new MessageBox(“Say Hello”);[/font]  
[font=Courier New]M.show();[/font]

Which in the above code the first I would be creating a new instance of type [font=Courier New]MessageBox[/font] and then I by calling the method show() I would be painting the [font=Courier New]MessageBox[/font] on the current Frame of the movie were the instance is being created. Now I tried this in Flash MX with just creating a text box and a line (With a big thanks to Voetsjoeba for his help), however when i tired the same code (with only some modifications to be like Flash MX 2004 style) the code did not work!, example if i don’t use[font=Courier New] \_parent[/font] the flash compiler will not want to read the class file!!

Naturally the advantage of such code is reusibility, and since I liked Java and C alot I would really like to impliment this in Flash.

btw - Thanks for the interest, I really apreciate it by you guys 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 2, 2004, 5:26pm UTC](https://forum.kirupa.com/t/still-some-problems-with-classes/59503/11 "2004-08-02T17:26:22Z")

</div>

well, like that, you shouldnt be able to use \_parent at all. Class objects have no \_parent. Only movieclips do (unless you explicitly give your objects a \_parent property which I dont think you did).

If you’re not associating your class with a movieclip and creating an instance of that class by attaching the associated movieclip to some timeline, then you can forget about using \_parent. What you might consider instead is to pass in the timeline of choice as an argument and use your class to attach instances to that object (saved in your class as a property).

[font=Courier New]var M:MessageBox = new MessageBox(\_root, “Say Hello”);  
M.show(); // creates textfield in \_root to show “Say Hello”[/font]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 2, 2004, 6:12pm UTC](https://forum.kirupa.com/t/still-some-problems-with-classes/59503/12 "2004-08-02T18:12:56Z")

</div>

ok, i know i shouldn’t hijack this thread, but…  
what is this public function stuff all about? and the x:Number? I have never saw that before.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 2, 2004, 6:16pm UTC](https://forum.kirupa.com/t/still-some-problems-with-classes/59503/13 "2004-08-02T18:16:31Z")

</div>

Thats from ActionScript 2.0.

the public keyword is used in class definitions and defines a method as being “public” or accessible for use directly off the instance object. Those which are not public are private. Private methods cannot be used from the instance. Instead, they are for use only from within the class itself.

x:Number is a way of specifying variable type. Using a colon (🙂 and an Object type following a variable name when its declared or initially defined, you can dictate its type. This helps you prevent yourself from trying to assing a number to variable which should be a string. It isnt required, but its good to do.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 2, 2004, 9:37pm UTC](https://forum.kirupa.com/t/still-some-problems-with-classes/59503/14 "2004-08-02T21:37:58Z")

</div>

go to this website and download the classes under chapter 5. oh, buy this book too.

[http://moock.org/eas2/examples/](http://moock.org/eas2/examples/)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 2, 2004, 9:39pm UTC](https://forum.kirupa.com/t/still-some-problems-with-classes/59503/15 "2004-08-02T21:39:31Z")

</div>

first of all thanks Rosrag for the link … abouth the Parent thing: from how I could understand it [font=Courier New]\_parent[/font] would only means that it will create the new movie in the parent of the the movie being created!!

If I send the \_root it would always load the movie clip in the root movie and could create, problems when haveing different swf files loaded in each other.

Can I send instead in which movie clip to load it? example:

[font=Courier New]var M:MessageBox = new MessageBox(this, “SayHello”);[/font]  
[font=Courier New]M.show();[/font]

and in this cas how should in the constraucter the coding shoudl be something like this? :

[font=Courier New]public function MessageBox(parent:MovieClip, title:String){ [/font]

[font=Courier New]…[/font]

[font=Courier New]}[/font]

??

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 2, 2004, 9:52pm UTC](https://forum.kirupa.com/t/still-some-problems-with-classes/59503/16 "2004-08-02T21:52:56Z")

</div>

yes, that is what I meant, \_root was just an example - though, as a parameter of the constructor it is its purpose to allow any other argument to be passed, beit \_root or this.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 2, 2004, 10:07pm UTC](https://forum.kirupa.com/t/still-some-problems-with-classes/59503/17 "2004-08-02T22:07:33Z")

</div>

Yes that would be great, coz it’s the same thing I used in Java! … but what should be the instance of that variable, MovieClip???

I am refering to the parameters, they should be like this:

[left][font=Courier New]public MessageBox(parent:MovieClip, text:String){[/font][/left]  
[left][font=Courier New]…[/font][/left]  
[left][font=Courier New]}[/font][/left]

and then can I do this:

[font=Courier New]parent.createEmptyMovieClip(…);[/font]  
Thanks Man!! 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 2, 2004, 10:22pm UTC](https://forum.kirupa.com/t/still-some-problems-with-classes/59503/18 "2004-08-02T22:22:51Z")

</div>

yup

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 2, 2004, 10:35pm UTC](https://forum.kirupa.com/t/still-some-problems-with-classes/59503/19 "2004-08-02T22:35:49Z")

</div>

Ok … I’ll work on it tomorow and then tell you if it works! 🙂

Thanks for all the help!! … i was going to fire my head!!

Thanks again 🙂
