Question:

Flash ActionScript 3.0 -- How to create a class???

by  |  earlier

0 LIKES UnLike

Hey guys, i have a really annoying problem,

so from a new Flash document (AS3) I put in the code:

class SampleClass

{

trace("hello world");

}

But this comes up with an error when it tries to compile,

'Classes cannot be nested'

This means that the class cannot be inside a function etc. doesn't it?

So I did some research, and apparently I have to make a Package as well, so:

Package

{

class SampleClass

{

trace("Hello World");

}

}

But nothing happens, It still says that 'classes cannot be nested'!?!?!?!

So

a. Why is this error happening? (in a new, blank file)

b. How can I fix it?

c. Can you please give me the exact code to place into a new flash file to create a class (EXACTLY)

Iv even tried using the adobe code examples, copying and pasting them in, with the same annoying error :(

Thanks in advance :)

 Tags:

   Report

1 ANSWERS


  1. package {

    import flash. display. Sprite;

    public class SimpleClass extends Sprite {

    public function SimpleClass(): void  {

    trace (" Hello World ");

    }

    }

    }

    you can find a source file here @

    http://anilonline.aokhost.com/Experiment...

    Anil

    anilkumarnd@gmail.com

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.