2

I have a problem where I have some dynamic text which works perfectly fine, but the moment I add a button it disappears. I don't have any special fonts. I've searched for this problem everywhere but I can't Find anyone else with the same problem.

If it helps, the button consists of a rectangle and static text.

Here's my code, but it's so short I don't think it has anything with the code to do.

var counter:int = 0;

counter.toString();

myTextField.text = String(counter);

I'm very new to as3, so this might be a stupid question.

Before button:

Before

After button: (Borders around text to show box didn't disappear, only the text)

After

flash

  • 1
    That's ALL of your code?! So I take it you are adding the button in the IDE? Can you show a screen shot of that please? If you are adding it using as3, of course we need to a see more code to figure the mistake out – Neal Davis Nov 04 '16 at 22:41
  • Try adding `myTextField.embedFonts = true;` – Neal Davis Nov 05 '16 at 00:44
  • @NealDavis Thanks for the suggestion, but it didn't work – Johnny Two Shoes Nov 05 '16 at 10:01
  • @JohnnyTwoShoes You should see a Error or a warning in the compiler Errors tab. You didn't have a warning or an Error message? – tatactic Nov 05 '16 at 10:27
  • Try to select "show border around text" here, so You will see if the TextField has disappeared or not... I see that you don't have a Font in your library nor a TextField... Sounds strange... Could You edit Your question after that? – tatactic Nov 05 '16 at 10:38
  • If you didn't select "use device fonts", you should have this Error message : "Fonts should be embedded for any text that may be edited at runtime, other than text with the "Use Device Fonts" setting. Use the Text > Font Embedding command to embed fonts." – tatactic Nov 05 '16 at 10:44
  • 1
    @tatactic That works thank you very much. Now I have one more question... I'm new here so how do I mark your answer as the right one? – Johnny Two Shoes Nov 05 '16 at 11:06
  • @JohnnyTwoShoes if that really solved your issue yes. – tatactic Nov 05 '16 at 11:11
  • I really want to see what's the problem with the original .fla file. I just answered because it was logical. But your issue is not clear at glance... – tatactic Nov 05 '16 at 11:24

1 Answers1

3

I tried this :

import flash.display.SimpleButton;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.text.AntiAliasType;

var counter:int = 0;


var myTextField:TextField = myTextField;
myTextField.selectable = true;
myTextField.border = true;
myTextField.embedFonts = false;
myTextField.antiAliasType = AntiAliasType.NORMAL;
myTextField.text = counter.toString();

var someButton:SimpleButton = someButton;
someButton.addEventListener(MouseEvent.MOUSE_DOWN,incrementText);
function incrementText(me:MouseEvent):void{
    counter++;
    myTextField.text = counter.toString();
}

This shows :

No click After one Click

And so on on each MouseDown event...

1,2,3,4... Everything is working fine even if I have only a SimpleButton in my library.

So could you edit your question please? Best regards Nicolas

<edit>

To embed a Font without code, go to the Library and create a new Font! Then link it to the TextField and select the Fonts you want to embed in the Library (letters...) but remind that the weight of your file will be more important if you select some Fonts ans some characters that you don't need in your .swf

Select the Fonts you want to embed in the Library

</edit>

<edit>

< How to embed Fonts in the library>

</edit>

<EDIT> this is the .swf file if You want to test it : swf file example </EDIT>

tatactic
  • 1,379
  • 1
  • 9
  • 18
  • @JohnnyTwoShoes thank You for your feedback! It's a pleasure to help if the member appreciate it! I added another possibility that may help too. Add the font in the library to embedFonts without coding! – tatactic Nov 05 '16 at 11:48
  • Thank You to Neal Davis, Null, BadFealingAboutThis and some other users (Who I forget to mention here), who are open minded and don't hesitate to be clear with me when I'm wrong! This helps me to go further, even I'm out of the office since 10 years! Your comments are really appreciated! Bad or good, never mind! You're such people that I will never forget! And this will certainty help me to continue to hold on, even if I'm out the office since 10 years. Thank You all for Your help an comprehension! Best regards. Nicolas. – tatactic Nov 16 '16 at 17:12