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

Show text on mouse click, hide on click

New Here ,
May 10, 2019 May 10, 2019

I'd like to show a block of text on a mouse click, but the add with wizard function for this doesn't seem to work. I'm guessing that's because I need to specify that it's hidden first, then comes the reveal on mouse click, then the hide on mouse click. I'm sure this is ultra simple. I'm brand new (clearly). Thanks!

951
Translate
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 ,
May 10, 2019 May 10, 2019

right click your text and click convert to symbol > movieclip and assign it an instance name.

what's the instance name of that text containing movieclip?

what do you want to click to show that t?

as3 or js?

Translate
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
New Here ,
May 10, 2019 May 10, 2019

There's no movie involved. I just want to click on something or press a button or symbol next to it, and show text. Javascript is preferable, in the HTML file. I need to use this on Squarespace, so I only get an add code box. Thanks.

Translate
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 ,
May 10, 2019 May 10, 2019

you need to convert your text to an object so it can be referenced with code.

Translate
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
New Here ,
May 10, 2019 May 10, 2019

I see convert to symbol or bitmap. I guess symbol?

Translate
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
New Here ,
May 10, 2019 May 10, 2019

I'm able to make it do other things, like move. I can have it hidden to begin, but the on mouse over or click doesn't do anything.

Translate
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
LEGEND ,
May 10, 2019 May 10, 2019

Here is a possible way to do it.

on off text.zip - Box

var root = this;

var change = true;

this.changeStatus.addEventListener("click", hideshow.bind(this));

function hideshow() {

    if (change) {

        root.myTxt.visible = false;

        change = false;

    } else {

        root.myTxt.visible = true;

        change = true

    }

}

Translate
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
Explorer ,
Jun 06, 2019 Jun 06, 2019

Using your script, how can I incorporate createjs to make text fade-in when it becomes visible and fade-out when text goes to hide?

Thanks in advance:-)

Translate
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 ,
Jun 06, 2019 Jun 06, 2019

this.text_movieclip.addEventListener("click", hideshowF); 

 

function hideshowF(e) { 

if (e.currentTarget.alpha>.5) { 

createjs.Tween.get(e.currentTarget).to({alpha:.01}, 1000)

} else { 

createjs.Tween.get(e.currentTarget).to({alpha:1}, 1000)

}

Translate
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
LEGEND ,
Jun 06, 2019 Jun 06, 2019
LATEST

resdesign  wrote

Here is a possible way to do it.

var root = this;

var change = true;

this.changeStatus.addEventListener("click", hideshow.bind(this));

function hideshow() {

     if (change) {

         root.myTxt.visible = false;

         change = false;

     }

     else {

         root.myTxt.visible = true;

         change = true

     }

}

Isn't your hideshow() functionally equivalent to this?

function hideshow() {

    root.myTxt.visible = !root.myTxt.visible;

}

Translate
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 ,
May 10, 2019 May 10, 2019

read message 1.

Translate
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
LEGEND ,
May 10, 2019 May 10, 2019

Your text needs to have an instance name then you can use the instance to hide it.

instance name: myTxt

var root = this;

// hide

root.myTxt.visible = false;

// show

root.myTxt.visible = true;

Translate
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 ,
Jun 06, 2019 Jun 06, 2019

Always make sure you refer to your code snippets. Screen Shot 2019-06-06 at 3.55.41 PM.png

Translate
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