# Basics of classes

**URL:** <https://forum.kirupa.com/t/basics-of-classes/260190>\
**Category:** flash\
**Created:** [May 13, 2008, 12:15pm UTC](https://forum.kirupa.com/t/basics-of-classes/260190 "2008-05-13T12:15:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SasuS](https://avatars.discourse-cdn.com/v4/letter/s/a698b9/32.png) [@SasuS](https://forum.kirupa.com/u/SasuS)\
**Post date:** [May 13, 2008, 12:15pm UTC](https://forum.kirupa.com/t/basics-of-classes/260190/1 "2008-05-13T12:15:13Z")

</div>

I’m trying to figure out how to stop an external child swf from streaming. How ever it seems I’m not understanding the custom classes at all. I tried to have a simple Hello world application made, but it gives me this error:

1137: Incorrect number of arguments. Expected no more than 0

The code is straight from Flash help files. The Helloworld.swf has a small dynamic text field called mainText. Do I need to attach the class or what should I do?

Greeter.as:  
package  
{  
public class Greeter  
{  
public function sayHello():String  
{  
var greeting:String;  
greeting = “Hello World!”;  
return greeting;  
}  
}  
}

Helloworld.swf:  
var myGreeter:Greeter = new Greeter();  
mainText.text = myGreeter.sayHello(“Bob”);

---

<div class="post-metadata">

**Author:** ![Iamthejuggler](https://avatars.discourse-cdn.com/v4/letter/i/ecc23a/32.png) [@Iamthejuggler](https://forum.kirupa.com/u/Iamthejuggler)\
**Post date:** [May 13, 2008, 12:17pm UTC](https://forum.kirupa.com/t/basics-of-classes/260190/2 "2008-05-13T12:17:57Z")

</div>

You’ll need to tell us a bit more than that to help you. Like what is the content of your hello world class, and how are you instantiating it?

---

<div class="post-metadata">

**Author:** ![SasuS](https://avatars.discourse-cdn.com/v4/letter/s/a698b9/32.png) [@SasuS](https://forum.kirupa.com/u/SasuS)\
**Post date:** [May 13, 2008, 12:31pm UTC](https://forum.kirupa.com/t/basics-of-classes/260190/3 "2008-05-13T12:31:52Z")

</div>

This is how ignorant I am with classes… Is there something else I need to have, other than the as-file and the swf-file? Swf-file should instantiate the class with this:

var myGreeter:Greeter = new Greeter();  
mainText.text = myGreeter.sayHello(“Bob”);

At least that’s what I thought it would do…

---

<div class="post-metadata">

**Author:** ![Iamthejuggler](https://avatars.discourse-cdn.com/v4/letter/i/ecc23a/32.png) [@Iamthejuggler](https://forum.kirupa.com/u/Iamthejuggler)\
**Post date:** [May 13, 2008, 12:57pm UTC](https://forum.kirupa.com/t/basics-of-classes/260190/4 "2008-05-13T12:57:47Z")

</div>

Your problem lies here:  
public function sayHello():String  
It isn’t expecting anything passed to it, but you are passing it “bob”. I assume you want to use “bob”, like print out “Hello Bob” maybe?

If so, change the function to:

public function sayHello(name:String):String  
{  
var greeting:String;  
greeting = "Hello " + name;  
return greeting;  
}

---

<div class="post-metadata">

**Author:** ![SasuS](https://avatars.discourse-cdn.com/v4/letter/s/a698b9/32.png) [@SasuS](https://forum.kirupa.com/u/SasuS)\
**Post date:** [May 13, 2008, 1:17pm UTC](https://forum.kirupa.com/t/basics-of-classes/260190/5 "2008-05-13T13:17:28Z")

</div>

I thought I was missing out something cruzial in understanding classes… Well it was an error with the code.  
Thanks a lot guys!!!
