DynamicText controlling scaleX values in MovieClips issue?

Hey guys,

Been looking at this for some hours now and dont seem to find any sensible explanation.
Created a healthbar that calculates the health percentage and scales my movieclip accordingly with healthbar1.scaleX = percentHP;

But when i push the template from the client with any value on that instance the template does not load the MovieClip. Now, if i push the template without any values assigned it works perfectly.
the element.@id == “health1” and the animation is motion tween all the way with everything starting at frame 0 (1)

	import flash.display.MovieClip;
	import se.svt.caspar.ICommunicationManager;
	import se.svt.caspar.IRegisteredDataSharer;
	import se.svt.caspar.template.CasparTemplate;
	public class side_overlay3 extends CasparTemplate
		private const customParameterDescription:XML = 	
	   		<parameter id="health1" type="string" info="Health player 1" />

		override public function SetData(xmlData:XML):void 

		   for each (var element:XML in xmlData.children())
			  if (element.@id == "health1") 		
				  var maxHP:int = 100;
				  var health1:String = element.data.@value.toString();
				  var int_health1:int = int(health1);
				  if (int_health1 < 100){
					  var percentHP:Number = int_health1 / maxHP;
					  healthbar1.scaleX = percentHP;

				  if (int_health1 <= 0){
					  healthbar1.scaleX = 0;

				  if (int_health1 == maxHP){
					  healthbar1.scaleX = 1;

I am new to AS3 so be kind :slight_smile:

The line

Should probably read:
var int_health1:int = parseInt(health1);

And by the way: The scaleX (and scaleY) are not very accuarate for this kind of work. I normally use a bar with the full height and move a mask according to the value. Needs a bit of calculation, but is much more precise.

The int conversion is just something i read online parseInt function is maybe more precise?

Do you have any good leads where i could read some guides to using masks?

It is really strange when calling this instance when you push the template live the bar wont even load. But if you pass no values at all it works. And if one would delay the SetData function it would delay each parsing of new values aswell. Heh…

Thx for the reply @didikunz :slight_smile:

Might add that using width gives the same results. (health1.width)

Something with how the data is parsed at the beginning.

You make sure that the instance name (not the MoviClip name) is setted and with the right name you’re calling it (healthbar1 in this case)

Yes i am sure @dietgot, it works whenever i dont start the template with values on the DynamicText fields. If i push values through after the template is initiated it works perfectly.

I think the issue is that the healthbar gets a scaleX value before the motion is finished. Is it possible to send values only when the timeline is on a certain frame?

EDIT: if (currentFrame) did the trick, the values where pushed to the template from frame 1 thats the reason why the MovieClip also did not load. Helps taking some hours of :slight_smile: