Hi,
I don't know Flash MX2004 but I do know OOP.
The problem is that in your constructor function, your 2nd argument needs an
object of the type Color:
function myColor (myName:String, myValue:Color){
....
But you are not passing an OBJECT of the type color:
var myColor0:ChipColor = new ChipColor("Red",0xd90000);
0xd90000 -> is not a Color object, its just a color value. It would be a
string if your text had been in quotes, but it is not, so I don't know what
Flash will try to do with it ...?
To solve your problem change one of the two :
1. Pass a true color object when creating the object
OR
2. Change your constructor to accept and string and then inside the
constructor convert that string to true color object and use the arguments
string value (in this case: 0xd90000) as the argument when creating the
color object:
//Constructor Function
function myColor (myName:String, myValue:String){
colorName = myName;
//create color object here ...
colorValue = myValue;
}
I never used MX before, so I don't know what the color object constructor
is,otherwise I would show you ...:)
I think I may jump into MX soon though.
Stefan
www.killersites.com www.how-to-build-websites.com [quoted text, click to view] "Ticean Bennett" <ticean@oddvark.com> wrote in message
news:c065l4$2rf$1@forums.macromedia.com...
> Hi, I'm having some problems using a simple custom class I've created,
maybe
> somebody can help me out.
>
> Here is the class definition I've created:
>
> _______
> class ChipColor {
>
> var colorName:String;
> var colorValue:Color;
>
> // Method to return property values
> function getName():String {
> return(colorName);
> }
>
> function getColor():Color {
> return(colorValue);
> }
>
> //Constructor Function
> function myColor (myName:String, myValue:Color){
> colorName = myName;
> colorValue = myValue;
> }
>
> }
> _________
>
> I create an instance using:
>
> var myColor0:ChipColor = new ChipColor("Red",0xd90000);
>
> and then try tracing a property:
>
> thisColor = myColor0.getColor();
> trace(thisColor);
>
>
> I always get "undefined". This should be easy right? I'm getting no
> compile errors. Can somebody please lead me in the right direction?
>
> thanks,
>
> Ticean Bennett
>
>