It is currently 28 Mar 2017, 11:03



Text autofollow

Videos, graphics, Flash templates – how to create and play them using CasparCG

Moderators: Macey, Jonas Hummelstrand, didikunz

Text autofollow

Postby Monden » 20 Mar 2017, 10:53

I am a beginner in using CasparCG, so please don't mind if I ask something that is elementary. I have a problem when running the flash template in CasparCG. The code presented below is suppose to create an autofollow effect for the text. The request is to have a Movie Clip (it has to be a Movie Clip for the fading effect) containing three dynamic text fields (which I created as a symbol) which should be centered inside of it. This works fine in Flash, but during flash template generating, it seems that text width becomes an absolute value, so when I input different text for the text fields in CasparCG, the text does not align correctly. I guess it has something to do with the definition of variables, functions and classes.


Code: Select all
 brojdresa.x = blanko.x + 438 - (brojdresa.textWidth + ime.textWidth + prezime.textWidth + 2 * blanko.textWidth)/2;
      ime.x = brojdresa.x + brojdresa.textWidth + blanko.textWidth;
      prezime.x = brojdresa.x + brojdresa.textWidth + blanko.textWidth + ime.textWidth + blanko.textWidth;
Monden
 
Posts: 4
Joined: 17 Mar 2017, 10:23

Re: Text autofollow

Postby didikunz » 20 Mar 2017, 12:32

Iguess the problem could be, that a fields textWidth property does NOT return it's contents size, but the size it has been created inside the designer. So if your field has a width of say 600px it will return 600px. The trick here is to make the field as small as possible and set the fields autoSize property to TextFieldAutoSize.LEFT; That makes the field adapt it's width to the containing text.
Didi Kunz
CasparCG Client-Programmer, Template Maker & Live CG-Operator
Media Support, CH-5722 Gränichen, Switzerland http://mediasupport.ch/
Problems? Guide to posting Bug reports & Feature requests
User avatar
didikunz
 
Posts: 3401
Joined: 10 May 2010, 09:08
Location: Aarau, Switzerland

Re: Text autofollow

Postby Monden » 20 Mar 2017, 13:52

I've tried what you've suggested, but it didn't work.

This is what it looks like in Flash and that is how it should be.
Image
This is what it looks like in the Screen consumer, after I've entered a different text than the one in the designer (longer, in this case).
Image
So, as you've said, the problem is that textwidth is taken from the designer (Flash) and is not recalculated for the new text that I've entered in CasparCG.
Monden
 
Posts: 4
Joined: 17 Mar 2017, 10:23

Re: Text autofollow

Postby didikunz » 20 Mar 2017, 14:53

No, you did not make the textfields as small as possible. In the designer put in a text like "1" (without the ") and then make the leght of the field as small as possible. So that the text (after switching on autosize) extend the field in any case, Then you will get the correct textWidth readout.
In the picture bellow you see 3 fields made very small and expanding while text is added.
Grab1.png
Grab1.png (4.78 KiB) Viewed 208 times
Didi Kunz
CasparCG Client-Programmer, Template Maker & Live CG-Operator
Media Support, CH-5722 Gränichen, Switzerland http://mediasupport.ch/
Problems? Guide to posting Bug reports & Feature requests
User avatar
didikunz
 
Posts: 3401
Joined: 10 May 2010, 09:08
Location: Aarau, Switzerland

Re: Text autofollow

Postby Monden » 20 Mar 2017, 17:06

I did as you said.
Image
And this is what I got (of course I entered longer text in CasparCG, but only the width of the field from the designer is visible)
Image
Monden
 
Posts: 4
Joined: 17 Mar 2017, 10:23

Re: Text autofollow

Postby didikunz » 20 Mar 2017, 19:18

Sorry, read carefully:
didikunz wrote: The trick here is to make the field as small as possible and set the fields autoSize property to TextFieldAutoSize.LEFT; That makes the field adapt it's width to the containing text.

You forgot to set the autoSize property. If you don't, the fields stay as small as they are.
Didi Kunz
CasparCG Client-Programmer, Template Maker & Live CG-Operator
Media Support, CH-5722 Gränichen, Switzerland http://mediasupport.ch/
Problems? Guide to posting Bug reports & Feature requests
User avatar
didikunz
 
Posts: 3401
Joined: 10 May 2010, 09:08
Location: Aarau, Switzerland

Re: Text autofollow

Postby Monden » 22 Mar 2017, 12:28

I've implemented AutoSize as seen in the picture below.

Image

The designer preview still works fine.

Image

CasparCG Screen Consumer shows this.

Image

The problem is that the text field widths are calculated using the text entered in the designer and, I presume, during generating template transformed into a constant and applied that way when I enter different text in CasparCG Client.
Monden
 
Posts: 4
Joined: 17 Mar 2017, 10:23

Re: Text autofollow

Postby didikunz » 22 Mar 2017, 12:38

Aha, you run your script from an action frame. That will not work, you need to have an extra .as script and run the code AFTER all fiels are populated with data.

See here: http://casparcg.com/wiki/Content_/_Media#Creating_Advanced_Flash_Templates
and here: http://casparcg.com/wiki/Content_/_Media#Tutorial:_Loading_Dynamic_Images_in_a_Flash_Template
Didi Kunz
CasparCG Client-Programmer, Template Maker & Live CG-Operator
Media Support, CH-5722 Gränichen, Switzerland http://mediasupport.ch/
Problems? Guide to posting Bug reports & Feature requests
User avatar
didikunz
 
Posts: 3401
Joined: 10 May 2010, 09:08
Location: Aarau, Switzerland


Return to Content

Who is online

Users browsing this forum: No registered users and 3 guests