all groups > flash actionscript > september 2004 >
You're in the

flash actionscript

group:

Rollover a bunch of MCs


Rollover a bunch of MCs Rothrock
9/8/2004 11:17:37 PM
flash actionscript: So I'm trying to create a menu type thing. I have used createEmptyMovieClip and
within the MCs createTextField. I have set up textFormat and applied it to the
TextFields.

I would like to have a rollover function that changes the Format when the
pointer rolls over the text. Additionally I want to have an onPress that will
then link/load the appropriate swf file.

Is there a way to easily apply the code to each of these movies? Would a
prototype be useful here? (Assume for the purposes here that I know how to set
up and apply a new textFormat and so forth.)
Re: Rollover a bunch of MCs kglad
9/9/2004 12:14:10 AM
myF1 = new TextFormat();
myF2 = new TextFormat();
ibox.setTextFormat(myF1);
for (ivar=0; ivar<10; ivar++) {
rclip = _root.createEmptyMovieClip("mc"+ivar, ivar);
rclip.createTextField("tbox", ivar+10, 0, 0, 100, 20);
rclip._x = 0;
rclip._y = ivar*30;
rclip.jvar = ivar;
rclip.tbox.text = "i'm number "+ivar;
rclip.tbox.setTextFormat(myF1);
rclip.onPress = function() {
trace("i'm button "+this.jvar);
};
rclip.onRollOver = function() {
this.tbox.setTextFormat(myF2);
};
rclip.onRollOut = function() {
this.tbox.setTextFormat(myF1);
};
}

just assign the properties you want to myF1 and myF2
AddThis Social Bookmark Button