I’m trying to change the color of the attached clips I am using some oop coding where the color class is the child class and the Menu class is the parent everything is working in the class department the problem is the color object I think.
#include "scripts/menu.as"
MenuColor.prototype = new Menu();
// I place the orignal paremeters + the new paremeters in here
function MenuColor(clip, startx, y, alpha, b) {
super(clip, startx, y, alpha);
this.clip = clip;
this.b = b;
this.colArray = [0x636D87, 0x993366, 0xFF3300, 0x99CCFF, 0xFF99CC];
// this will forward the orignal paremeters to the parent class
}
MenuColor.prototype.update = function() {
super.update();
this.setColor();
};
Menu.prototype.setColor = function() {
this.col = new Color(this.clip);
for (var i = 0; i < this.colArray.length; i++) {
this.col.setRGB(this.colArray*);
trace("THE col :"+this.col);
}
};
var color = new MenuColor();
The setColor Function is where it is not working. can anyone please help thanks
Ok I did some tests in a seperate movie and the way I had it set up works fine
Anyone out there no about Classes in MX
what I see is happening is in my MenuColor class
I have an extended function called the setColor function()
now it wont recognise the line
this.col = new Color(this.clip);
When I do a trace on this it should trace as [object Object]
But mine traces as undefined
Can I have a new object inside my class stupid question but I am relatively new to class and inheritance.
i think that making MenuColor a class is a little overkill. do you have pressing reason to make it so? why not manage it all in a Menu method?
Menu.prototype.setColor = function() {
var i,col,colArray = [ /* rgb values */ ];
// i assume this.clip is a movie residing within Menu
col = new Color(this.clip);
// this is a little confusing ... why set it to every
// colour in the array? only the last one will stick.
for (i=0; i < colArray.length; i++) {
col.setRGB(colArray*);
trace("THE col :"+col);
};
};
if you want different menus to have different colArrays, you could use this.colArray, and set that somewhere … perhaps with another method.
I had no reason to have it as a class i’m using class more and nore and just wanted to set it up that way you mean place it in a function and then call it directly from a function.
///////////////////////////////////////////////////////////////////////////////
[COLOR=red]function setCol(clips) {
colArray = [0x636D87, 0x993366, 0xFF3300, 0x99CCFF, 0xFF99CC];
myColor = new Color(clips);
for (var i = 0; i < colArray; i++) {
myColor.setRGB(colArray*);
}
}[/COLOR]
///////////////////////////////////////////////////////////////////////
I tried this but it still would not work.
I was calling it from
the function that creates the clips.
no. i mean define it as a menu method. it’s difficult to make suggestions without knowing how you’ve structured your movie.
just what exactly are you trying to change the colour of? and why do you change it to five different colours in one for loop?
if tracing your Color object is coming up as undefined, it’s most likely because your tracing an undefined variable, not that your new Color() command is failing.
your code is getting cut by the board when you put a non-white space character after a < sign. make sure you put space around > or < .