0
votes

So I've been following this tutorial on AS3 and Flash. Its been going well until, note I have tried to contact the writer of the tutorial and had no reply. Here's what it tells me to do;

Right-click PlayScreen in the library, select Properties, and check Export for ActionScript. This time, instead of accepting the default value, enter the name of your document class. Click OK.

So it pops up an error, first we’ll have to make a new document class, since no two different objects can share the same class. Cancel the Properties box.

Hit File > New and select ActionScript File. Enter the (by now familiar) code.

Save this in the Classes directory as DocumentClass.as. (There’ll be no confusing the purpose of this file!) Now, back in your FLA, change the document class to DocumentClass.

Check everything’s fine by clicking that pencil icon — if it’s all OK, that should bring up the AS file that you just created.

// So this bits all fine, its the next that i'm stuck with:

Now you can set the PlayScreen‘s class to AvoiderGame. So do so!

// So I go ahead into the properties and change the name but then it pops up with the same error as before: 'Please enter a unique class name that is not associated with other library symbols'

What does this mean!? How do I resolve this!?

Full tutorial here:Flash Tutorial

1
What IDE are you using?Pier
Flash Professional CCSpook811

1 Answers

0
votes

Its hard to tell what you are trying to accomplish without knowing what all the parts you are referring to actually do, which are objects in the library and which are classes, but maybe this can help:

First of all, document class in AS3 typically refers to the project's main set of code that initializes the app. This class can be called anything but is often called Main, and is entered in the property panel that is displayed when you click the projects main stage in the field called class.

enter image description here

Now, when linking a class to an object in the library, its a little different. In the library object's property panel, tick the box for Export for Actionscript, and put a unique name in the top box. This is what you reference in your code to call it, like new somethingOrOther() or using the pic below as an exaample, new Ball(). The second box is the base class, pathed to where it lives in your code base. This is the class you will write that actually controls the object you've linked the class to. Giving a linked object a base class and a unique identifier allows you to use the same base class for multiple linked objects.

enter image description here

Note that when you do this approach, Flash will warn you that there is no class associated with Ball and one will be created for you. Don't worry, this is normal behavior. If you set this up properly, your object will still be controlled by its base class.