A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: pop up tooltips

  1. #1
    Sonic the FlashHog geoffp08's Avatar
    Join Date
    May 2002
    Location
    Orlando
    Posts
    237

    pop up tooltips

    Hey, 'evenin' to ya! Having some issues with getting this to work... I cant get the tooltip to appear. I have a feeling its something simple (but complicated enough to give me fits @ 12am LOL).

    Now, Ive assigned the variable "tooltip" to the dyn.txt.box, and named what instances I need named... And I have these tooltips nested in the third frame of myMovieClip which is on the second frame of my main timeline. I have this code on that third frame inside myMovieClip:

    ========================================
    function tooltip (string) {
    xmouse = getProperty("", _xmouse);
    ymouse = getProperty("", _ymouse);
    duplicateMovieClip ("_root.tooltip", "tooltip1", 1);
    tooltip1.tooltip = string;
    setProperty (tooltip1, _x, xmouse);
    setProperty (tooltip1, _y, ymouse);
    startDrag ("_root.tooltip1");
    tooltip1.gotoAndPlay(2);
    }
    function remove_tooltip () {
    stopDrag ();
    removeMovieClip ("tooltip1");
    }

    ====================================
    and this code for each tooltip (with different text for each button)
    ====================================

    on (rollOver) {
    _root.tooltip("heres my use for this popup");
    }
    on (rollOut, dragOut) {
    _root.remove_tooltip();
    }

    ====================================

    Now, It is 12am, so I know Ill probably be embarrassed by the fix, but, I know it has to do with the path to which its played on. I know what youre thinking, but Ive tried several different variations of _root.myMovieClip.tooltip, or myMovieClip.tooltip, etc. Something tells me the path isnt identical throughout... or is it? 8P Or maybe Im just labeling it wrong. where/how would I fix this to get these sweet tooltips to work. any help would be greatly appreciated.
    Thanks
    geoff

  2. #2
    HELP>>>ACTIONSCRIPT DICTIONARY
    Join Date
    Feb 2000
    Location
    In the Present Moment
    Posts
    1,041
    Code:
    function tooltip (thisTip) {//IMO better to not use the word string
    	attachMovie ("tooltip", "tooltip1", 1);//attachMovie allows you the use of removeMovieClip
    	//make sure to give the tooltip movieClip "linkage" properties
    	//open up the Library and rightclick on the the proper movieClip
    	//Select "linkage", check the "export for ActionScript" checkbox and give it a name
    	//in the case of this edit I chose "tooltip"
    	_root.tooltip1._x=_root._xmouse;//setting this upon creation otherwise the tip will jump
    	//and nobody likes a jumpy tip
    	_root.tooltip1._y=_root._ymouse-_root.tooltip1._height;//I offset the tip by it's height because the registration
    	//point is in the upper left corner and the pointer was covering the text
    	_root.tooltip1.tooltip.text = thisTip;//make sure to add the .text, trust me 
    	//I built a movieclip with a dynamic text field called "tooltip", make sure that the textfield is NOT selectable, 
    	//(turn off the Ab checkbox in the text field properties)
    	_root.tooltip1.onEnterFrame = function () {//this function handles the tooltip's location
    		_root.tooltip1._x = _root._xmouse;
    		_root.tooltip1._y = _root._ymouse-_root.tooltip1._height;//again the offset so the text appears above the pointer
    	};
    	//_root.tooltip.startDrag();//you don't need the drag statement as the placement is based on mouse location
    	//tooltip1.gotoAndPlay (2);//I don't have a frame 2 so you may still want/need this?
    }
    function remove_tooltip () {
    	//_root.tooltip1.stopDrag ();//removed as I am not using the startDrag() code
    	removeMovieClip (_root.tooltip1);//gets rid of the "attached" movieClip
    }
    The button code works fine as is.

    Good Luck!

    P.S. The code above will probably read easier when you cut and paste into Flash
    Antibody
    "Our deepest fear is not that we are inadequate.
    Our deepest fear is that we are powerful beyond measure." - N. Mandela

  3. #3
    Sonic the FlashHog geoffp08's Avatar
    Join Date
    May 2002
    Location
    Orlando
    Posts
    237

    heres what I got

    First, thanks for the reply! Ok, I gave it a shot, and still a no go. I recreated an exact example of my movie, the exact way I have it set up. This should make it alot easier to spot my blunder (whatever/wherever it may be)
    Geoff
    Attached Files Attached Files

  4. #4
    ask me one on fish..not flash
    Join Date
    Oct 2002
    Location
    southern u.k.
    Posts
    495
    hi guys, i actually came in to ask how to make the text box dynamically fit the text...however....

    i had a quick look at your file (nosey, nosey..)

    here is what i found.

    1. the paths in your movie are wrong. antibody assumed that your buttons were on the main timeline (and not in the movieclip) so...

    where you have got _root.tooltip1 you actually need to have _root.mymovieclip.tooltip1 etc.

    2. now the tooltip displays but not in the correct place! (i think this is actually being referenced to the "origin" point of your "mymovieclip") so....

    i simply changed the math and made the _x -320 and _y 300 (i think)
    (yes i know it's dirty but it is effective...lol)

    3. now it was in the right place but no text appeared.. so....

    i changed your dynamic text field deleted the "variable" assignment and made the instance name "tooltip"

    i also removed the second layer of the "tooltip_mc" and the first frame as i didnt see any need for them (sorry)

    yahoooooooo it seems to work now.

    (and i really should be working but this was more fun)

    hope this has helped a little

    Gary_bydesign
    Attached Files Attached Files
    I bought a Ouija board. The pointer spelled out 'You don't actually believe in this crap, do you

  5. #5
    Sonic the FlashHog geoffp08's Avatar
    Join Date
    May 2002
    Location
    Orlando
    Posts
    237

    Too kool!

    Hey Gary, youre a funny guy! Yeah, I just checked out the fla and it worked like a charm. I see what Antibody (thanks for your help too!) was trying to do, and hence (my still learning) wasnt quite able to figure out what was going wrong... Well, Thanks for the time out from work to mess with my fla. I really appreciate it, it has/will help(ed) alot! Now I get to go tear it apart and figure it all out for myself!
    NOW GET BACK TO WORK!
    Geoff
    Moving at the speed of Flash

  6. #6
    HELP>>>ACTIONSCRIPT DICTIONARY
    Join Date
    Feb 2000
    Location
    In the Present Moment
    Posts
    1,041
    Good job Gary! I'm glad that you could help geoffp out.

    I took a look at the .fla and this is how I changed it:

    1) Removed the reference to _root out of the functions for use in it's current location. Removed the _x and _y offsets. (the way you have your tooltip clip setup is perfect for the offseting)

    Code:
    function tooltip (thisTip) {
    	attachMovie ("tooltip", "tooltip1", 1);
    	tooltip1._x=_xmouse;
    	tooltip1._y=_ymouse;
    	tooltip1.tooltip.text = thisTip;
    	tooltip1.onEnterFrame = function () {
    		tooltip1._x = _xmouse;
    		tooltip1._y = _ymouse;
    		//tooltip1.gotoAndPlay (2);
    	};
    }
    
    function remove_tooltip () {
    	removeMovieClip (tooltip1);
    }
    2)changed the code on the buttons by removing the references to the _root timeline:

    Code:
    on (rollOver) {
        tooltip("Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing had happened");
    }
    on (rollOut, dragOut) {
        remove_tooltip();
    }

    3) Changed the text field from have a var name to the instance name, as Gary suggested (sorry making fields in this way is still new to some. I forget that as I take it for granted now )

    4) Removed the instance of "tooltip" sitting on the stage, it is not needed. The attachMovie code grabs it out of the library, which is why we assigned "linkage" to the clip.

    5) Also inside the tooltip movieClip I made the point of the tooltip box touch the center registration point. You won't need to do any offset's for the pointers location.

    6) Took out frame 1 of the tooltip, like Gary also suggested. There is no need for it. This makes the tooltip.gotoAndPlay() statement also obsolete. (by the way it should have been gotoAndStop(2), otherwise you would have gotten a blinking tooltip )

    In any event, whatever it takes to make it work is goood!

    Happy Flashing!
    Antibody
    "Our deepest fear is not that we are inadequate.
    Our deepest fear is that we are powerful beyond measure." - N. Mandela

  7. #7
    ask me one on fish..not flash
    Join Date
    Oct 2002
    Location
    southern u.k.
    Posts
    495
    wow, now it works for real.

    thanx for the pointers, being the flashnewbie i find it easier to see what is happening if i reference everything to the root. (does it make any difference in filesize or execution time if i do reference evrything, as it helps me see what is happening?)

    i didnt know i didnt need to (duh).

    antibody, thanx for takin the time to help both of us out

    i am now a wiser person for today

    cheers guys

    Gary_using less references_bydesign
    I bought a Ouija board. The pointer spelled out 'You don't actually believe in this crap, do you

  8. #8
    Sonic the FlashHog geoffp08's Avatar
    Join Date
    May 2002
    Location
    Orlando
    Posts
    237
    -cleaning up the debris- from the fallout of all those knowledge bombs y'all just dropped on me!
    both worked good! Im flippin the coin to see whose Ill use... heads/tails anyone?
    Moving at the speed of Flash

  9. #9
    HELP>>>ACTIONSCRIPT DICTIONARY
    Join Date
    Feb 2000
    Location
    In the Present Moment
    Posts
    1,041
    Well any actionscript, no matter it's location, adds to filesize. As to where code goes, that is entirely up to you. Personally I put most of my functions on the _root. That way they can be accessed from inside any number of nested movieClips with a simple _root.thisFunction();

    Sometimes I build movieclips that contain their own specific functions so that I can drag and drop them into multiple projects and they work no matter what movie or what timeline in that movie I drop them into.

    It is all personal preference I think. Maybe the real programmer types know better.

    Have a good day and I was glad to help out.
    Antibody
    "Our deepest fear is not that we are inadequate.
    Our deepest fear is that we are powerful beyond measure." - N. Mandela

  10. #10
    ask me one on fish..not flash
    Join Date
    Oct 2002
    Location
    southern u.k.
    Posts
    495
    thanx n thanx anti

    n

    have fun geoff
    I bought a Ouija board. The pointer spelled out 'You don't actually believe in this crap, do you

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