A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: hover captions problem

  1. #1
    Senior Member
    Join Date
    Mar 2002
    Location
    richmond, va
    Posts
    139

    hover captions problem

    Ok so I have some code that is from Kirupa's site.. for the hovering captions, and I can get it to work when it is on the root level, but I want to use it a few down, the address would be _root.main.cal_mc

    it doesn't work.. here is the code, I'm sure it is simple to fix, address problem or something but I can't get it to...
    help if you can thanks

    b1.onRollOver = function() {
    captionFN(true, "May 15", this);
    this.onRollOut = function() {
    captionFN(false);
    };
    };
    b2.onRollOver = function() {
    captionFN(true, "Portable Devices", this);
    this.onRollOut = function() {
    captionFN(false);
    };
    };

    captionFN = function (showCaption, captionText, bName) {
    if (showCaption) {
    _root.createEmptyMovieClip("hoverCaption", 1);
    cap.desc.text = captionText;
    cap._width = 7*cap.desc.text.length;
    cap._alpha = 75;
    //
    if ((bName._width+bName._x+cap._width)>Stage.width) {
    xo = -2-cap._width;
    yo = -17;
    } else {
    xo = 2;
    yo = -17;
    }
    hoverCaption.onEnterFrame = function() {
    cap._x = _root._xmouse+xo;
    cap._y = _root._ymouse+yo;
    cap._visible = true;
    };
    } else {
    delete hoverCaption.onEnterFrame;
    cap._visible = false;
    }
    };

  2. #2
    Can't Re-Member madzigian's Avatar
    Join Date
    Apr 2004
    Location
    Boston MA
    Posts
    2,662
    well just at first glance... in this section of your code
    Code:
    _root.createEmptyMovieClip("hoverCaption", 1);
    cap.desc.text = captionText;
    cap._width = 7*cap.desc.text.length;
    cap._alpha = 75;
    What is cap?... It appears that "desc" is a TextField.. but it is never created. Also it seems odd that you would set the mc's width to 7X the length of the text?..

    i think making these changes might get you there
    Code:
    cap = _root.createEmptyMovieClip("hoverCaption", 9999);
     // place the mc on a high depth so it is always on top of other elements on stage
    
    cap.createTextField("desc", 1, 2, 0, 0, 0);
    // create the text field
    
    cap.desc.autoSize = true;
    cap.desc.text = captionText;
    
    cap._width = cap.desc.textWidth + 4;
    // make cap mc width equal to the width of the text field + 10.. which allows 2 px
    // of empty space on each side of text field
    
    cap._alpha = 75;

    Make those changes and see how you do.... if that's not working, I wrote some code for tooltips a few months back that is much easier to use/understand. I'll post it for you if you decide you want to give it a shot.

    hope that helps
    Please DO NOT PM me simply for individual help. Post in the public forums...that's what they are for, and they allow others to benefit as well. - Thx
    OS X 10.3.9 || Flash MX04 Pro
    | del.icio.us || furl || Helpful Source Files || Free Pixel Fonts |

  3. #3
    Media Developer CJElven's Avatar
    Join Date
    Jan 2002
    Location
    San Antonio, TX
    Posts
    298
    You're so close, I can almost taste it. The problem lies in that you're not always referencing the _root. You create _root.hoverCaption, but you never refer to _root.hoverCaption. You're trying to access hoverCaption as if it's on your current level. Either create hoverCaption in the current level, or be sure to refer to it as _root.hoverCaption at all times.

    The reference to "cap" may have the same problem. I'm not certain, since you're not creating "cap" dynamically. I assume it's an established clip.

    But, this is a really common problem when you're just porting the same code to different levels. I've done it myself many times.

    Edit: This comment was actually typed concurrently with your post, Madzigian. I'm not commenting on your response. But...I would guess that "cap" is the background for the tooltips, rather than just the textField name.
    Last edited by CJElven; 05-16-2006 at 01:06 AM.
    Dragontech Media
    Magic.Fire.Content

  4. #4
    Can't Re-Member madzigian's Avatar
    Join Date
    Apr 2004
    Location
    Boston MA
    Posts
    2,662
    the same thing is accomplished with : cap = _root.createEmptyMovieClip("hoverCaption", 9999);
    from then on, using 'cap' is the same as _root.hoverCaption

    just FYI.. i avoid all the extra typing i can...
    Please DO NOT PM me simply for individual help. Post in the public forums...that's what they are for, and they allow others to benefit as well. - Thx
    OS X 10.3.9 || Flash MX04 Pro
    | del.icio.us || furl || Helpful Source Files || Free Pixel Fonts |

  5. #5
    Senior Member
    Join Date
    Mar 2002
    Location
    richmond, va
    Posts
    139
    well the cap and desc are all already created...
    even when i change the _root.createEmptyMovieClip() to be exactly where the movie is, it doesn't work... if anyone has a better way for me to do this pleaes please let me know... basically i have what is a calender that is a MC that is embedded in a few others... I want captions to pop up when each 'day' is moused over... I can get it to work if I put it on the _root level, but even when i change the address and embed it it won't work....

  6. #6
    Media Developer CJElven's Avatar
    Join Date
    Jan 2002
    Location
    San Antonio, TX
    Posts
    298
    I think that I would have to see the files to help any more. I'm confused about what you're referring to at any particular level. If you could post, I'm sure someone could help out.
    Dragontech Media
    Magic.Fire.Content

  7. #7
    Senior Member
    Join Date
    Mar 2002
    Location
    richmond, va
    Posts
    139
    just imagine it one level down from root... I can't get it to work even one level down, even after i have changed the address on the _root.createEmpty line..

  8. #8
    Media Developer CJElven's Avatar
    Join Date
    Jan 2002
    Location
    San Antonio, TX
    Posts
    298
    But, are you still referring to "cap" as if it were on the local level? "cap" (as far as I can tell) is also on the _root level, and probably should be referred to with _root.cap as well.
    Dragontech Media
    Magic.Fire.Content

  9. #9
    Banned NTD's Avatar
    Join Date
    Feb 2004
    Posts
    3,438
    Removing any helpful previous posts I mistakenly contributed to these forums.

    See ya FK'ers
    Last edited by NTD; 10-19-2006 at 09:04 AM.

  10. #10
    Senior Member
    Join Date
    Mar 2002
    Location
    richmond, va
    Posts
    139
    yup, i have changed it everywhere for everything cap and all

  11. #11
    Can't Re-Member madzigian's Avatar
    Join Date
    Apr 2004
    Location
    Boston MA
    Posts
    2,662
    here you go.. try this. Put this code on the first frame of your main timeline (all of this code is frame code BTW... you'll have to alter it slightly if you like using object code):
    Code:
    MovieClip.prototype.toolTip = function(str:String) {
    	
    	var tf = new TextFormat();
    	tf.font = 'Verdana'; 
    	tf.size = 10;  
    	tf.color = 0x000000; 
    	
    	this.onRollOver = function() {
    
    		tTip = _level0.createEmptyMovieClip('tip', 9999);
    		tTip.createTextField('tipText', 1, 0, 0, 0, 0);
    
    		tTip.tipText.text = str; 
    		tTip.tipText.autoSize = 'left';
    		tTip.tipText.background = true;
    		tTip.tipText.border = true;
    		tTip.tipText.selectable = false;
    		tTip.tipText.backgroundColor = 0xFFFFE1;
    		tTip.tipText.borderColor = 0x000000;
    		tTip.tipText.setTextFormat(tf);
    		
    		tTip.onEnterFrame = function() {
    			this._x = _level0._xmouse;
    			this._y = _level0._ymouse-20;
    			updateAfterEvent();
    		};
    
    	};
    	
    	this.onRollOut = function() {
    		tTip.removeMovieClip();
    	};
    };
    
    //------------------- USAGE ----------- >>
    // create a movie clip on the main timeline and give it the instance name 'mc'
    mc.toolTip('[ Tool Tip Test ]');
    
    // if you have mc's which require tooltips that are nested in other mc's...
    // you just to adjust the path accordingly for ex:
    // my_mc.another_mc.calendar.day1.toolTip("Something's is happening today");
    hope that helps
    Please DO NOT PM me simply for individual help. Post in the public forums...that's what they are for, and they allow others to benefit as well. - Thx
    OS X 10.3.9 || Flash MX04 Pro
    | del.icio.us || furl || Helpful Source Files || Free Pixel Fonts |

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center