Do not use on any
shared computer
September 7, 2008 09:55pm pdt
 
[x]
Attachment Details

Flash AS3 - can you help me associate a custom class with my .fla?

Tags: Adobe / Macromedia, Flash CS3, CS3 / 9
Hello,

I am a complete beginner with AS3 and OOLs but have been trying to read a lot and getting some help in developing a simple flash website.  BUT!  I still cant understand / find a clear explanation of how to associate my custom button class with my .fla.

I have six movieclip buttons each slightly different and am trying to communicate with them without writing a new function for each button.

A very helpful expert pointed me in the direction of the code attached below.  However when I try to link the class to each movie clip in the library Flash tells me I have to enter... a unique class name not associated with any other symbols!!?

Does this mean I have to create a class for every button after all?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
package{
        //KeyButton.as
        import flash.display.*;
        import flash.events.*;
 
        public class KeyButton extends MovieClip{
                public function KeyButton(){
                        addEventListener(MouseEvent.MOUSE_OVER,keyOver);
                        addEventListener(MouseEvent.MOUSE_OUT,keyOut);
                }
                private function keyOver(e:MouseEvent):void{
                e.currentTarget.gotoAndPlay('over');
                }
                private function keyOut(e:MouseEvent):void{
                e.currentTarget.gotoAndPlay('out');
                }
        }
}
Start your free trial to view this solution
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Question Stats
Zone: Software
Question Asked By: keybord
Solution Provided By: julianopolito
Participating Experts: 2
Solution Grade: A
Views: 12
Translate:
Loading Advertisement...
 
[+][-]Expert Comment by wildbrookmedia
Expert Comment by wildbrookmedia:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by keybord
Author Comment by keybord:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Assisted Solution by wildbrookmedia
Assisted Solution by wildbrookmedia:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by keybord
Author Comment by keybord:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by julianopolito

Rank: Wizard

Expert Comment by julianopolito:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Accepted Solution by julianopolito

Rank: Wizard

Accepted Solution by julianopolito:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by wildbrookmedia
Expert Comment by wildbrookmedia:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Open Discussion
Open Discussion
 
Comment by keybord
Thanks for your time here guys.  

Your last comment sealed this query for me I think Julian and is a nice way of using just the one class.  (Though I confess I dont quite understand how I can get away with subsituting the Base class 'flash.display.MovieClip' for my own class but I'm assuming thats cause my own class is an 'extension' of the Movieclip class?)

Anyway this has turned into a very nice primer on AS3 classes and I will keep on with the homework!

Dont be surprised to hear from me again in a few days. = )
 
 
Comment by julianopolito
You can change the base class because your class EXTENDS flash.display.MovieClip, so it means your class is a specialized version of MovieClip. That's why you can do that. Then when you specify an non existent class to be the symbol class, flash creates an empty class for automatically. This class extends the base class KeyButton
 
 
20080723-EE-VQP-34 / EE_QW_2_20070628