# Dynamic template with dynamic images - How?

**URL:** <https://casparcgforum.org/t/dynamic-template-with-dynamic-images-how/2786>\
**Category:** FAQ\
**Tags:** graphics, template, howto\
**Created:** [February 28, 2020, 5:39pm UTC](https://casparcgforum.org/t/dynamic-template-with-dynamic-images-how/2786 "2020-02-28T17:39:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ImSzergej](https://casparcgforum.org/letter_avatar_proxy/v4/letter/i/96bed5/32.png) [@ImSzergej](https://casparcgforum.org/u/ImSzergej)\
**Post date:** [February 28, 2020, 5:39pm UTC](https://casparcgforum.org/t/dynamic-template-with-dynamic-images-how/2786/1 "2020-02-28T17:39:48Z")

</div>

Hi,

I want to create a league table dynamic template for an esport event with logo changing options. I followed [this](https://github.com/CasparCG/help/wiki/Guide:-Loading-Dynamic-Images-in-a-Flash-Template) guide , but I can’t make it to work. 😃 I have 8 UILoader, and 8 image variable.

 ![image](https://casparcgforum.org/uploads/default/original/1X/8d81fc90caf818476f581163c5d7115e992e3409.png)

Anyone can help me out how can I do this? 8 image place for 8 image. 😃

---

<div class="post-metadata">

**Author:** ![didikunz](https://casparcgforum.org/user_avatar/casparcgforum.org/didikunz/32/7_2.png) [@didikunz](https://casparcgforum.org/u/didikunz)\
**Post date:** [February 28, 2020, 5:43pm UTC](https://casparcgforum.org/t/dynamic-template-with-dynamic-images-how/2786/2 "2020-02-28T17:43:33Z")

</div>

> [@ImSzergej](#):
>
> I followed [this](https://github.com/CasparCG/help/wiki/Guide:-Loading-Dynamic-Images-in-a-Flash-Template) guide

I would have pointed you on that guide. It seems that something is wrong. Can you share your .fla and .as files?

---

<div class="post-metadata">

**Author:** ![ImSzergej](https://casparcgforum.org/letter_avatar_proxy/v4/letter/i/96bed5/32.png) [@ImSzergej](https://casparcgforum.org/u/ImSzergej)\
**Post date:** [February 28, 2020, 5:47pm UTC](https://casparcgforum.org/t/dynamic-template-with-dynamic-images-how/2786/3 "2020-02-28T17:47:41Z")

</div>

Yes, I can, but it’s not a great work, because I have problems in the basics, i think. 😄

[https://drive.google.com/file/d/1bxOgccEsrcj-32V70KM\_wllzNrxhLoZ4/view?usp=sharing](https://drive.google.com/file/d/1bxOgccEsrcj-32V70KM_wllzNrxhLoZ4/view?usp=sharing)

---

<div class="post-metadata">

**Author:** ![sgs](https://casparcgforum.org/letter_avatar_proxy/v4/letter/s/85f322/32.png) [@sgs](https://casparcgforum.org/u/sgs)\
**Post date:** [February 28, 2020, 10:25pm UTC](https://casparcgforum.org/t/dynamic-template-with-dynamic-images-how/2786/4 "2020-02-28T22:25:52Z")

</div>

try this:

```auto
var instance1:UILoader;

var mainPath:String = "file:///C:/......"; // your path images

and next

override public function SetData(xmlData:XML):void 
		{			
		   for each (var element:XML in xmlData.children())
		   {
			  if (element.@id == "Team 1") 		
			  {
				instance1.source= mainPath + element.data.@value.toString() + ".png";// or jpg,png .. 
			  }
		   }
		   super.SetData(xmlData);
instance1.Visible = true;

```

if you want do this automatically, you must create array with 8 elements and then element.@id == array1[0]

[https://help.adobe.com/en\_US/FlashPlatform/reference/actionscript/3/Array.html](https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Array.html)

---

<div class="post-metadata">

**Author:** ![didikunz](https://casparcgforum.org/user_avatar/casparcgforum.org/didikunz/32/7_2.png) [@didikunz](https://casparcgforum.org/u/didikunz)\
**Post date:** [February 29, 2020, 11:21am UTC](https://casparcgforum.org/t/dynamic-template-with-dynamic-images-how/2786/5 "2020-02-29T11:21:30Z")

</div>

There are a few things going wrong:

- In your timeline you use classic tweens instead of motion tweens. Clasic tweens have that small vertical separator where ever you change a property. The problem is, that after each of these lines you have a new instance of your object. As the code sets the images at frame 0 the flags will not make it to the instance that you animate in.
- You need to set an instance name to the “UILoaders” movieClip to be able to set the source properties by code.
- That instance name must be referenced when you load the flags. So instead of  
`logo1.source = element.data.@value.toString();` it would read:  
`Instancename.logo1.source = element.data.@value.toString();`
- A perfomance suggestion: Until frame 38 nothing happens in the png animation. The same is true from frame 310 to the end. Get rid of these extra frames.
- What also can help is only render the area, that has something in it instead of the whole 1920x1080 pixels. But that is something for another post…
