Return to Starling Playback Library

GAF Textfield - Color not saving

Questions related to Starling playback library should be asked here.

GAF Textfield - Color not saving

Postby vanderweelesimon » January 21st, 2016, 2:41 pm

Basically I've got a fighting system, and on around 3-4 GafTextfields are created every 3 or so, the problem I'm having is that if I create two Gaf Textfields simultaneously the second Gaf Textfield takes the color of the first.

That's what I'm using to set the color -
textEditorProperties.textFormat.color = color;

Basically in short,

I create Textfield A with color 0xFFFFFF and Textfield B with color 0x000000.

Sometimes Textfield B ends up 0xFFFFFFF instead of 0x000000 and sometimes it works.
User avatar
vanderweelesimon
 
Posts: 20
Joined: November 24th, 2014, 5:00 am

Re: GAF Textfield - Color not saving

Postby Lê Huy Hùng » January 21st, 2016, 8:09 pm

You must set color before add the text to stage. I think it related to my question before
viewtopic.php?f=4&t=430&p=1648&hilit=color#p1648
User avatar
Lê Huy Hùng
 
Posts: 61
Joined: July 3rd, 2015, 8:32 pm

Re: GAF Textfield - Color not saving

Postby vanderweelesimon » January 21st, 2016, 10:35 pm

Thanks for the reply, although unfortunately it didn't work!

I traced to be sure, and the parent always returned null when setting the color..

Not sure what the problem can be honestly that's why I turned to the forum, if you need me to provide you with some code let me know because I don't know which would be relevant to the situation

Forgot to mention but I'm using the same bundle to recreate the textfields, but if there is a slight delay between each text it works so I don't know how to approach this
User avatar
vanderweelesimon
 
Posts: 20
Joined: November 24th, 2014, 5:00 am

Re: GAF Textfield - Color not saving

Postby Назар Левицкий » January 22nd, 2016, 2:02 am

Hi vanderweelesimon,
vanderweelesimon@gmail.com wrote:That's what I'm using to set the color -
textEditorProperties.textFormat.color = color;

Basically in short,

I create Textfield A with color 0xFFFFFF and Textfield B with color 0x000000.

Sometimes Textfield B ends up 0xFFFFFFF instead of 0x000000 and sometimes it works.


Try to use this code instead:
Code: Select all
var textFieldA: GAFTextField = ...;
var textFieldB: GAFTextField = ...;

var textFormat: TextFormat = textFieldA.textEditorProperties.textFormat;
textFormat.color = 0xFFFFFF;
textFieldA.textEditorProperties.textFormat = textFormat;

textFormat = textFieldB.textEditorProperties.textFormat;
textFormat.color = 0x000000;
textFieldB.textEditorProperties.textFormat = textFormat;

Thanks
User avatar
Назар Левицкий
 
Posts: 12
Joined: June 6th, 2014, 12:01 am

Re: GAF Textfield - Color not saving

Postby vanderweelesimon » January 22nd, 2016, 3:49 am

Unfortunately that didn't work either, it really doesn't make sense :( If I trace the color after setting it , it does return the right color uint, but it displays the previous one..

Code: Select all
public function setText(txt:String,textFormat:TextFormat):void
      {
         if(blockMC)
         {
         blockMC.txt.txt.dText.textEditorProperties.textFormat = textFormat;
         blockMC.txt.txt.dText.text = txt.toString().toUpperCase();
User avatar
vanderweelesimon
 
Posts: 20
Joined: November 24th, 2014, 5:00 am

Re: GAF Textfield - Color not saving

Postby Назар Левицкий » January 22nd, 2016, 5:37 am

The logic of usage the Feathers' TextInput.textEditorProperties implies that code sets new instance of TextFormat class to TextInput.textEditorProperties.textFormat property. We slightly changed this logic, so the code above will work correctly for now.

You can grab fixed version from our git - https://github.com/CatalystApps/StarlingGAFPlayer.

Thanks
User avatar
Назар Левицкий
 
Posts: 12
Joined: June 6th, 2014, 12:01 am

Re: GAF Textfield - Color not saving

Postby vanderweelesimon » January 22nd, 2016, 6:07 am

Code: Select all
dmgTF = new FightText();
         dmgTF.artDone =
         function():void
         {
            var textFormat = dmgTF.blockMC.txt.txt.dText.textEditorProperties.textFormat;
            textFormat.color = color;
            dmgTF.setText(txt,textFormat);
         }
         


Code: Select all
public function setText(txt:String,textFormat:TextFormat):void
      {
         if(blockMC)
         {
         blockMC.txt.txt.dText.textEditorProperties.textFormat = textFormat;
         blockMC.txt.txt.dText.text = txt.toString().toUpperCase();



I've updated to the version you sent but the problem still persists... it's getting frustrating, maybe you know another method I can use? I'm using a bundle, not sure if that should make a difference.

If I trace the.textEditorProperties.textFormat.color I do get the color it's supposed to show, but it's not shown.
User avatar
vanderweelesimon
 
Posts: 20
Joined: November 24th, 2014, 5:00 am

Re: GAF Textfield - Color not saving

Postby Назар Левицкий » January 22nd, 2016, 6:41 am

I have made demo for you - https://github.com/CatalystApps/Starlin ... elds_color

If you face any difficulties you can send to us your demo and we will try to fix your code.
User avatar
Назар Левицкий
 
Posts: 12
Joined: June 6th, 2014, 12:01 am

Re: GAF Textfield - Color not saving

Postby vanderweelesimon » January 22nd, 2016, 7:47 am

I've managed to recreate my problem with your demo, maybe you can shine some light on it now

I've attached a dropbox link to the project, just navigate over to the src folder and open text_field_demo.fla , once compiled press 'W' , both textfields end up with same color..

https://www.dropbox.com/s/zdbdizox3dv6y18/dynamic_textfields_color.rar?dl=0
User avatar
vanderweelesimon
 
Posts: 20
Joined: November 24th, 2014, 5:00 am

Re: GAF Textfield - Color not saving

Postby Назар Левицкий » January 22nd, 2016, 8:25 am

Oh, thank you for explanation! :)
Fix is already on github.
User avatar
Назар Левицкий
 
Posts: 12
Joined: June 6th, 2014, 12:01 am

Return to Starling Playback Library

Who is online

Users browsing this forum: No registered users and 1 guest