• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Tooltip as3 explaination

Community Beginner ,
Dec 05, 2017 Dec 05, 2017

Copy link to clipboard

Copied

Hye guys,

I currently want to learn how to make tooltip via as3.

Hoping you guys can help me to explain what the code function in the code;

import fl.transitions.easing.*;

import fl.transitions.*;

mc.addEventListener("mouseOver", mouseRollOver);

mc.addEventListener("mouseOut", mouseRollOut);

mc.addEventListener("mouseMove", mouseMove1);

var tooltip:Tooltip = new Tooltip();

tooltip.txt.text = "This is a tooltip";

tooltip.x = stage.mouseX;

tooltip.y = stage.mouseY - mc.height;

function mouseRollOver(e:MouseEvent):void {

    addChild(tooltip);

    var myTween:Tween = new Tween(tooltip, "alpha", Regular.easeIn, 0, 1, 0.5, true);

}

function mouseRollOut(e:MouseEvent):void {

    removeChild(tooltip);

}

function mouseMove1(e:MouseEvent):void {

    tooltip.x = stage.mouseX;

    tooltip.y = stage.mouseY - mc.height;

}

Thank you

cc: RandomlyFish​, just.emma​,

Views

479

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 05, 2017 Dec 05, 2017

Copy link to clipboard

Copied

do you have a Tooltip class?  (just  movieclip with a textfield (named txt) is sufficient.)

is that your code?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 05, 2017 Dec 05, 2017

Copy link to clipboard

Copied

Yes I have create a Movie Clip with instance & class named "Tooltip" with empty Dynamic Text in it.

This is not my own code, i just copied & pasted from a tutorial (i forgot where).

But I have no idea the function of the code & need someone to help me to explain it so later I can made my own.

and I want make a multi tooltip.

Thanks.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 06, 2017 Dec 06, 2017

Copy link to clipboard

Copied

iezqandarzulqarnaen

import fl.transitions.easing.*;

import fl.transitions.*;

mc.addEventListener("mouseOver", mouseRollOver);  // adding mouseevent listeners

mc.addEventListener("mouseOut", mouseRollOut);  //   ""   ""

mc.addEventListener("mouseMove", mouseMove1);  //  ""  ""

var tooltip:Tooltip = new Tooltip();  // create a new Tooltip instance

tooltip.txt.text = "This is a tooltip";  // assign the help text

tooltip.x = stage.mouseX;  // assign position

tooltip.y = stage.mouseY - mc.height;  //  ""   ""

function mouseRollOver(e:MouseEvent):void { 

    addChild(tooltip);  // add to the display when mc is rolledover

    var myTween:Tween = new Tween(tooltip, "alpha", Regular.easeIn, 0, 1, 0.5, true);  // tween its alpha so it fades in

}

function mouseRollOut(e:MouseEvent):void {

    removeChild(tooltip);  // remove the tooltip on mouse out

}

function mouseMove1(e:MouseEvent):void {

    tooltip.x = stage.mouseX;   // move the tooltip when the mouse moves

    tooltip.y = stage.mouseY - mc.height;

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 07, 2017 Dec 07, 2017

Copy link to clipboard

Copied

Thanks for the reply @kglad

So if I put it to more changeable view:

import fl.transitions.easing.*;

import fl.transitions.*;

<movieClip>.addEventListener("mouseOver", <mouseOver function>);  // adding mouseevent listeners

<movieClip>.addEventListener("mouseOut", <mouseOut function>);  //   ""   ""

<movieClip>.addEventListener("mouseMove", <mouseMove function>);  //  ""  ""

var <instance>:<class>= new <class>();  // create a new instance

<instance>.<dynamicText instance>.text = "This is a tooltip";  // assign the help text

<instance>.x = stage.mouseX;  // assign position

<instance>.y = stage.mouseY - <movieClip>.height;  //  ""   ""

function <mouseOver function>(e:MouseEvent):void { 

    addChild(<instance>);  // add to the display when mc is rolledover

    var myTween:Tween = new Tween(<instance>, "alpha", Regular.easeIn, 0, 1, 0.5, true);  // tween its alpha so it fades in

}

function <mouseOut function>)(e:MouseEvent):void {

    removeChild(<instance>);  // remove the tooltip on mouse out

}

function <mouseMove function>(e:MouseEvent):void {

    <instance>.x = stage.mouseX;   // move the tooltip when the mouse moves

    <instance>.y = stage.mouseY - <movieClip>.height;

}

is this correct?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 07, 2017 Dec 07, 2017

Copy link to clipboard

Copied

that's not valid actionscript.  if it's meant to something else, i don't understand it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 10, 2017 Dec 10, 2017

Copy link to clipboard

Copied

So sorry,

forget my previous post.

What i need to change if i want to make another tooltip in the same stage.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 10, 2017 Dec 10, 2017

Copy link to clipboard

Copied

LATEST

import fl.transitions.easing.*;

import fl.transitions.*;

var tooltip:Tooltip;

var ttObj:Object={};

//call toolTipF and pass whatever displayobject and tooltip string you want

function toolTipF(dobj:DisplayObject,s:String):void{

tooltip = new Tooltip();  // create a new Tooltip instance

tooltip.txt.text = s;  // assign the help text

tooltip.x = stage.mouseX;  // assign position

tooltip.y = stage.mouseY - mc.height;  //  ""  ""

ttObj.dobj=tooltip;

obj.addEventListener(MouseEvent.MOUSE_OVER,mouseRollOver);

obj.addEventListener(MouseEvent.MOUSE_OUT,mouseRollOut);

}

function mouseRollOver(e:MouseEvent):void {

tooltip=ttObj.e.currentTarget

    addChild(tooltip);  // add to the display when mc is rolledover

    var myTween:Tween = new Tween(tooltip, "alpha", Regular.easeIn, 0, 1, 0.5, true);  // tween its alpha so it fades in

}

function mouseRollOut(e:MouseEvent):void {

    removeChild(ttObj.e.currentTarget);  // remove the tooltip on mouse out

}

function mouseMove1(e:MouseEvent):void {

    tooltip.x = stage.mouseX;  // move the tooltip when the mouse moves

    tooltip.y = stage.mouseY - mc.height;

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines