PDA

View Full Version : AS3 newbie need your help


shunryusuzuki
10-09-2006, 01:37 PM
Hello there!

I'm having some trouble trying to make classes with the flash 9 alpha release.

Can someone explain me why this very simple thing isn't functionning in actionscript 3:

I wrote a simple.as file with only that:

class simple{
var txt:String = "blabla";
}


and try to use in my sketch with that:

var test:simple = new simple();


where is the problem???

thank for any idea it's a bit urgent.

senocular
10-09-2006, 02:25 PM
classes need to be in a package block
package {
class simple{
var txt:String = "blabla";
}
}

shunryusuzuki
10-09-2006, 02:31 PM
thank you, I appreciate your help.

I tried to add the package stuff but it give me this error message :

**Error** C:\Documents and Settings\me\Desktop\simple test\loading2\as3 test\simple.as: Line 1: Syntax error.
package {

**Error** C:\Documents and Settings\me\Desktop\simple test\loading2\as3 test\simple.as: Line 5: ActionScript 2.0 class scripts may only define class or interface constructs.
}

Total ActionScript Errors: 2 Reported Errors: 2


I hope you understand what's the problem.

senocular
10-09-2006, 02:37 PM
Did you read your errors? I think the "ActionScript 2.0 class scripts..." is a pretty clear indication of one problem.

shunryusuzuki
10-09-2006, 02:44 PM
wow! sorry dude.

But I don't know how to create an ActionScript 3.0 file. Is it possible to do it without using Flex?

senocular
10-09-2006, 03:12 PM
ActionScript files are just text files. You can use any text editor to make them, even notepad. You don't need Flex.

There are some resources here that you might find helpful:
http://www.kirupa.com/forum/showthread.php?t=223798
(the bottom of the first thread has some links to tutorials etc)

shunryusuzuki
10-09-2006, 04:25 PM
It's why I hadn't understood the error message.

Thanks a lot for always beeing there.

I'll take a look to your as3 tips on kirupa before boring you again ;-) .

Best regards.
Simon.