Hello there
I have this class:
class TestButton
extends Button
{
public function onRollOver()
{
trace("onRollOver");
}
}
I want to create an instance of this class by using the flash 8 environment. Nevertheless, when I choose convert to symbol, I just can choose among Graphic, Button and MovieClip. Does anyone know how could I create a shape like a square and make it an instance of TestButton?
Thanks in advance
[SOLVED]action script 2.0 flash 8 extend button
Moderator: General Moderators
-
thosecars82
- Forum Commoner
- Posts: 94
- Joined: Thu Apr 03, 2008 6:31 am
- Location: Arganda, Madrid
- Contact:
[SOLVED]action script 2.0 flash 8 extend button
Last edited by thosecars82 on Thu Jun 12, 2008 7:07 am, edited 1 time in total.
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Re: action script 2.0 flash 8 extend button
Dealing with the built-in Flash objects that are represented by symbols isn't as simple as just extending the class. I forgot exactly how it's done, but kirupa.com probably has a tutorial that can help you figure it out.
-
thosecars82
- Forum Commoner
- Posts: 94
- Joined: Thu Apr 03, 2008 6:31 am
- Location: Arganda, Madrid
- Contact:
Re: action script 2.0 flash 8 extend button
I haven't found the answer yet. I have worked with objects in javabuilder and c++ builder. I guessed it would be the same. In those languages, all the objects you put on the stage had their corresponding classes but it seems that action script 2.0 is not that good. Might I be doing something that cannot be done in as2 but in as3?
Thanks
Thanks
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Re: action script 2.0 flash 8 extend button
No, I did it in AS 2.0. I did so with the MovieClip class. All I remember was that the method of changing the class of the MovieClip was very unorthodox, in my opinion.
-
thosecars82
- Forum Commoner
- Posts: 94
- Joined: Thu Apr 03, 2008 6:31 am
- Location: Arganda, Madrid
- Contact:
Re: action script 2.0 flash 8 extend button
Thanks superdezign.superdezign wrote:No, I did it in AS 2.0. I did so with the MovieClip class. All I remember was that the method of changing the class of the MovieClip was very unorthodox, in my opinion.
To assign a class to a movie clip symbol:
1. Select File > New and then select ActionScript File, and then click OK.
2. Select File > Save As, name the file Animal.as, and save the file on your hard disk.
3. Type the following code into the Script window:
class Animal {
public function Animal() {
trace("Animal::constructor");
}
}
This ActionScript creates a new class called Animal that has a constructor method that
traces a string to the Output panel.
4. Save your changes to the ActionScript file.
5. Select File > New and then select Flash Document to create a new FLA file, and then
click OK.
6. Select File > Save As, name the file animal_test.fla, and save the file to the same folder as
the Animal.as file you created in step 2.
7. Select Insert > New Symbol to launch the Create New Symbol dialog box.
8. Enter a symbol name of animal, and select the Movie Clip option.
9. Click the Advanced button in the lower-right corner of the Create New Symbol dialog box
to enable more options.
The Advanced button is available when you are in the basic mode of the Create New
Symbol dialog box.
10. Click the Export for ActionScript check box in the Linkage section.
Enabling this option allows you to dynamically attach instances of this symbol to your
Flash documents during runtime.
11. Enter an identifier value of animal_id, and set the ActionScript 2.0 Class to Animal (to
match the class name specified in step 3).
12. Select the Export in First Frame check box and click OK to apply your changes and close
the dialog box.
13. Save the Flash document and select Control > Test Movie.
The Output panel displays the text from your Animal class’s constructor function.