Hi there,
Just browsing around and thought I’d try help. Just create a new movie and put the code below into frame 1 and run it.
It shows you how you can target different clips and change the colours or perform an action of some sort. Notice they all start at the same colour. The first square changes colour automatically because of an interval that is used. The colours are all random that are generated.
The second square is controlled by the small square button below. Every time you roll over or out it changes colour at random. When you press on it it changes colour to an ugly pink. When you release the button it changes back to its original colour.
All you are doing is targetting something when the event is actioned. The MC method drawframe is whats used to create the squares to avoid you having to link a clip from your library.
Just trying to simplify for you.
I hope it can help.
//MC method to draw a square
MovieClip.prototype.drawframe = function(lineColour, fillColour,cw,ch,cx,cy, fillAlpha, linealpha) {
if (itsLalpha == undefined) {
itsLalpha = 100;
}
with (this) {
lineStyle(0, lineColour, linealpha);
beginFill(fillColour, fillAlpha);
moveTo(cx, cy);
lineTo(cx+cw, cy);
lineTo(cx+cw, cy+ch);
lineTo(cx, cy+ch);
lineTo(cx, cy);
endFill();
}
};
/*****************************************************************************/
function colourchangeMC(myMCobject) {
// Following is the code for a random colour transition effect
var incrRB = math.floor(math.random() *255) +1;
var incrGB = math.floor(math.random() *255) +1;
var incrBB = math.floor(math.random() *255) +1;
_global.mysquareTrans = {rb:incrRB, gb:incrGB, bb:incrBB};
myMCobject.setTransform(_global.mysquareTrans);
// end of the code for a random colour transition effect
}
//globals needed for this example
_global.depthlvl = 1;
_global.mysquareTrans = new Object();
/*****************************************************************************/
//sample using an interval and random colours
var teaserClip = this.createemptymovieclip("teaser", _global.depthlvl++);
teaserClip.drawframe(0xffffff, 0xa51439,100,100,75,100, 100, 0);
teaserClip = new Color(teaserClip);
clearInterval(teaserClip.itsIid);
teaserClip.itsIid = setInterval(colourchangeMC, 1000, teaserClip);
/*****************************************************************************/
//sample 2 create the clip that will change colour
var teaser1Clip = this.createemptymovieclip("teaser1", _global.depthlvl++);
teaser1Clip.drawframe(0xffffff, 0xa51439,100,100,200,100, 100, 0);
teaser1Clip = new Color(teaser1Clip);
//create the button to control the clip
var mybutton = this.createemptymovieclip("mybutton", _global.depthlvl++);
mybutton.drawframe(0xffffff, 0xa51439,100,25,200,300, 100, 0);
//change the colour using random colour
mybutton.onrollover = function() {
colourchangeMC(teaser1Clip);
};
//again change the colour using random colour
mybutton.onrollout = function() {
colourchangeMC(teaser1Clip);
};
//now change the colour using a non random RGB sequence
mybutton.onpress = function() {
_global.mysquareTrans = {rb:255, gb:40, bb:0};
teaser1Clip.setTransform(_global.mysquareTrans);
};
//lastly change the colour back to original colour
mybutton.onrelease = function() {
_global.mysquareTrans = {rb:0, gb:0, bb:0};
teaser1Clip.setTransform(_global.mysquareTrans);
//do whatever else you like here ...
};
stop();