Ok, seem to be having a problem here. On my main stage I have a dynamic text box with the word “airsoft” in it. Now I also have a MC that has a button which is a graphic of an airsoft gun. I just dragged that MC from my library onto my main stage. On the button of the gun is where I put this actionscript…
on(rollOver){
linkFormat = new TextFormat();
linkFormat.size = 23
_root.airosft.setTextFormat(linkFormat);
}
on(rollOut){
linkFormat = new TextFormat();
linkFormat.size = 16
_root.airosft.setTextFormat(linkFormat);
}
What this should do is make the “airsoft” text get bigger on rollover, and go back to normal on rollout. For some reason this is not working, and I figured it is because the _root is not supposed to be used here. However, I have no idea if it is or is not. I am sure you guys should have this cracked in no time. Thank you
myformat = new TextFormat();
myformat.size = 10;
_root.airsoft.setTextFormat(myformat);
On a button…
on (rollOver) {
_root.myformat.size = 12;
_root.airsoft.setTextFormat(_root.myformat);
}
on (rollOut) {
_root.myformat.size = 10;
_root.airsoft.setTextFormat(_root.myformat);
}
Now create a dynamic text box with your text inside and call it “airsoft” (no quotes) in the <B>Instance</B> area, <U>NOT</U> in the var name area… this makes a difference
Or you could make it more dynamic for multiple clips and boxes by doing this (Only If you use MX, you never specified).
On a Frame…
//create new text format
myformat = new TextFormat();
//create default size
myformat.size = 10;
//apply format
_root.airsoft.setTextFormat(myformat);
//Create function called changeText
//mc = The clip you are using onRollOver and onRollOut on
//targetBox = The targeted text box for the change
//sizeTextOver = The size of the text on RollOver
//sizeTextOut = The size of the text on RollOut
function changeText(mc, targetBox, sizeTextOver, sizeTextOut) {
//Create the rollOver "button"
//We will really use a Movie Clip :)
mc.onRollOver = function() {
_root.myformat.size = sizeTextOver;
targetBox.setTextFormat(_root.myformat);
};
//Create the rollOut "button"
mc.onRollOut = function() {
_root.myformat.size = sizeTextOut;
targetBox.setTextFormat(_root.myformat);
};
}
On a MovieClip…
onClipEvent (load) {
//Call function (check function in Frame Actionscript to refer to what these do)
//this = mc
//_root.airsoft = targetBox
//12 = sizeTextOver
//10 = sizeTextOut
_root.changeText(this, _root.airsoft, 12, 10);
}
Thanks fellas, I will try both of these when I get home this afternoon. I think beta’s way will be better b/c I can use it multiple times for other boxes with less coding… I THINK. Thank you both for ;your help
The second method I posted actually does use less code. All the lines that start with // are just comments and can be removed, but were added to tell you what each of those things do.
With my second method you will just have to put that in a frame and you can call the change on any “button” (movie clip) with this…
Just got home and tried it out. Thanks a lot beta. Yeah for some reason I thought someone else posted that first one. This works perfect and it is very easy to change if I have to. You da man!