Problem adapting Hover Captions tutorial

Hi all,

Need some desperate help here. I’ve been figuring with the hover captions for hours and I just can’t seem to make it work.

I’ve added in another dynamic text field because I need my captions to have 2 lines, formatted differently. I’ve tried my changes using Kirupa’s source file, and it works perfectly fine.

But when I copy and paste the codes into my actual file containing all my buttons, something goes wrong. The caption appears, but it does not change when I rollover onto a different button. (I’m trying to input captions onto different adjacent regions in a map.)

Is there something wrong with the code?


b1.onRollOver = function() {
    captionFN(true, "B1", "hello", this);
    this.onRollOut = function() {
        captionFN(false);
    };
};
b2.onRollOver = function() {
    captionFN(true, "B2", "goodbye", this);
    this.onRollOut = function() {
        captionFN(false);
    };
};
captionFN = function (showCaption, captionText, captionDesc, bName) {
    if (showCaption) {
        _root.createEmptyMovieClip("hoverCaption", this.getNextHighestDepth());
        cap.name.text = captionText;
        cap.desc.text = captionDesc;
        cap._width = 7*cap.name.text.length;
        cap._alpha = 95;
        // 
        if ((bName._width+bName._x+cap._width)>Stage.width) {
            xo = -2-cap._width;
            yo = +4;
        } else {
            xo = 2;
            yo = +4;
        }
        hoverCaption.onEnterFrame = function() {
            cap._x = _root._xmouse+xo;
            cap._y = _root._ymouse+yo;
            cap._visible = true;
        };
    } else {
        delete hoverCaption.onEnterFrame;
        cap._visible = false;
    }
};

Thanks for any help!