Caspar Shared Data Module

howto
template
flash

#1

Hello guys!

What should I do to access the template data using the Caspar Communication Manager.
I am modifying the advanced template 2 (sample template).
Editing the field f0 in the client I am able to trigger the animations.
What if instead I would like to add more text instances and call them with different names.

I believe I need to access to the comm.manager to be able to do that.

The idea is to make a live data for a passing point at a sport event.

Thank you in advance!

Federico


#2

The Communication Manager is used to let two or more templates, loaded in the same layer (on different Flash layers) talk to each other. You don’t use it to send data to templates. That is done by overwriting the SetData function in the .as file, in case of advanced templates, or naming textField instances with the name you use to send the data in the client (like f0 etc.).

For the normal workflow “AdvancedTemplate1” would be a better example to use as the other one does not even have a SetData function.

To simply update a few points in a template you don’t need to use the advanced template workflow at all. Just name your textFields the way you want them and send new data via Update.


#3

Thank you as usual Didi!
My code on the action script side now it works!

I test it on the template generator and goes like a charm.

The weird thing is then when I try to use it with my little software seems like the “If” is not considered and my two shapes (insieme1 & insieme2) are still showned.

This is what I use to populate data:

tmpl.Fields.Add(New TemplateField("f0", row.Item("Firstname")))
_Caspar.CG_Add(10, frmTool.cboAthleteId.Items(frmTool.cboAthleteId.SelectedIndex), tmpl, True)

Is there anything else I should refer to?

Thanks!

Here the AS working code on the playout of the Template Generator:

package
{
	import flash.display.MovieClip;
	import se.svt.caspar.ICommunicationManager;
	import se.svt.caspar.IRegisteredDataSharer;
	import se.svt.caspar.template.CasparTemplate;
      
	public class TestLivescroll extends CasparTemplate
	{
		
		
		override public function SetData(xmlData:XML):void 
		{			
		   for each (var element:XML in xmlData.children())
		   {
			  
			  if (element.@id == "f0")
			  {
				  if (element.data.@value.toString() != "")
					 {  
						 insieme1.alpha = 1;
					 }
				  else
					 {  
						 insieme1.alpha = 0;
					 } 
				  			 
			  }
			  
			   if (element.@id == "f1")
			  {
				  if (element.data.@value.toString() != "")
					 {  
						 insieme2.alpha = 1;
					 }
				  else
					 {  
						 insieme2.alpha = 0;
					 } 

				 
			  }

		   }
		   super.SetData(xmlData);		
		}
	}
}

#4

Are you sure, that the .fla file refers to the .as file? There is a setting in Flash were you must a the name of the .as, so that it gets compiled in.

Grab1

It’s a German version of Flash, so, it will be called “Class” in English


#5

Yep class is referenced.


#6

…and these insieme objects are not inside a movieClip?


#7

only the shapes not the texts


#8

So, you say, the shapes are inside a movieClip?


#9

Yes I have done a little change now.
So the scene is this

Movieclip1 named insieme1 that includes shape1(no instance name) and text1(f0)
and
Movieclip2 named insieme2 that includes shape2(no instance name) and text2(f1)

It is working on the playback of the template generator, not by my commands… :frowning:


#10

I see, it works, when you enter text into the fields in Template Generator, but not when you send the text via your code. What I can see from your code snippet is, that you only set “f0” so the code inside if (element.@id == "f1") will never run, so the line insieme2.alpha = 0; will never execute. What could help is to add the lines:

override public function postInitialize():void
{
   insieme1.alpha = 0;
   insieme2.alpha = 0;
}

That will set them to be invisible beforehand. So regardless if you set the fields or not, it will work correctly.


#11

Thank you @didikunz !

You solved it! Really appreciated!