TheTAZZone - Internet Chaos

Tutorial – ToolTips (flash MX)

ORIGINALLY POSTED BY NOKIA FOR THETAZZONE/TAZFORUM HERE

Do not use, republish, in whole or in part, without the consent of the Author. TheTAZZone policy is that Authors retain the rights to the work they submit and/or post…we do not sell, publish, transmit, or have the right to give permission for such…TheTAZZone merely retains the right to use, retain, and publish submitted work within it’s Network

Code: Select all
This is the original work of Valhallen, whom has allowed The TAZ to host his work on our site.
Please find the original here:
http://www.antionline.com/showthread.php?s=&threadid=246123

OK this is tutorial is written by me but has been adapted from script taken from ActionScript for Flash MX (book) by Friends of ED

Ok basically what I am going to show you is a way of creating a dragable movieclip in Flash MX that in conjuction with flash’s ability to record collisions can be used to create a help function type tooltip

Now yes I know it could be done using the on(Rollover) function as well but this is just to show a different way and also to give some people a taste of dragable movieclips (mc) and detecting collisions….

Ok first of all lets set up the movie

Open a new flash document and create 2 layers named Graphics & Actions

Ok the graphics layer is going to hold your dragable movieclip and the buttons and the top layer is going to be just for your actions.

Now your going to need two mc’s in your graphics area one will be your Hit area and the other your dragable mc

give your hitarea the instance name hitarea
and your dragable mc the instance name Ques01

The hit area mc can contain whatever you want – in the example .fla is just text but you can place a button anything in it

The Ques01 must have a dynamic text field in it to display your tooltip

ok now lets add your code to the top layer

tooltip = function () {
this.onPress = function() {
this.startDrag(“”);
this.onMouseMove = function() {
updateAfterEvent();
};
};
this.onRelease = function() {
this.stopDrag();
this.onMouseMove = undefined;
[color=green]};
this.onReleaseOutside = function() {
this.stopDrag();
};
this.onEnterFrame = function() {
this.coll = “”;
if (this.hitTest(“_root.hitarea”)) {
this.coll = “links”;[/color]
}
};
};
tooltip.apply(ques01);

ok the blue part of the code defines a new function called tooltip
the red sets up the dragable mc
the Green tells it to display the text links whenever a collision is detected over the hitarea
& the purple area of the code tells it to apply the rules set out in the function tooltip to the mc called Ques01

test your movie when you click and drag the mc Ques01 over the hit area it should display the text links

ok I know I aint gone into it into too much depth but it should be enough to get you started if you want to add multiple hit areas then you need to alter your code slightly

Code: Select all
if (this.hitTest("_root.hitarea")) {
this.coll = "links";
}

just alter this code and place it after the original for example if we had 3 hit areas labeled hitarea, hitarea2 & hitarea3 then our code would be…..

Code: Select all
if (this.hitTest("_root.hitarea")) {
this.coll = "links";
}
if (this.hitTest("_root.hitarea2")) {
this.coll = "links 2";
}
if (this.hitTest("_root.hitarea3")) {
this.coll = "links 3";
}

the _root tells flash that the mc it is looking for is on the main time line – if your movie clip was inside another which was on the main timeline the code would look something like _root.firstclip.yourclip

thanks

v_Ln

Leave a Reply

Your email address will not be published. Required fields are marked *

Advertise

If you'd like to advertise on The Mutt ( aka TheTAZZone.com ) feel free to contact us at: administration[at]thetazzone.com

TheTAZZone is a non-commercial entity. We do not sell any products or services ourselves. Our revenue comes from advertising and donations only.

We appreciate your support! Your advertising revenue ( or donations ) helps us to continue to upgrade, improve, and offset the costs of maintaining this site.

Donations can be made through the page ' Donate '.