Flash Template, with external file input



Hi there!
I’ve been using flash Templates for a while now and I’m very happy with it! We launch our CG through bitfocus Companion app and it’s really nice just out of the box!
Trying to get more complicated CG, I’ve been working on a Template wich takes Text from an external file.
Everything works inside Animate but when calling It into Caspar it returns a “PARAMETER_MISSING: 402 CG ERROR”.

The code from animate is this:

import flash.net.URLLoader;
import flash.events.Event;
import flash.net.URLRequest;

var myTextLoader:URLLoader = new URLLoader();

myTextLoader.addEventListener(Event.COMPLETE, onLoaded);
myTextLoader.load(new URLRequest(“Titular.txt”));

function onLoaded(e:Event):void
_ l3Title.text = e.target.data;_
_ addChild(l3Title);_

As I said, the flash works perfect, but Caspar seems to miss something…


That is an error of the server, that does not get a parameter to the template. Is this code only a snippet of a larger code? Is it in a separate ActionScript file? It could be, that Caspar does not consider this as a valid template. Do you run TemplateGenerator from Animate?


That code is on the actions layer to load the content on the first frame. As I would do for a normal Animate project.
Then I buid using templateGenerator without errors, but when loading to Caspar is when I get the error.
Should I script on a separate file?
I’m really new to Caspar Scripting! Am I missing some tutorials?


Have you tried commenting out the code and see, if you still have the same error?


(What is this underscore shit about? There is the button </> to format code). I think it would make sense to have the i3Title dynamic textfield already on the stage, it could mess up everything when you add it later.


Sorry for t’he formatting, was my first code paste so i didn’t know and just messed up with the italics.

Tried to coment t’he code and worked the animation but no text appears.

What do you mean with having the dynamic text already on stage?


You add the field to the stage, do you? I guess this kills the code.


I think I don’t get It.
The field is on a text object from the stage.
The problem is that the Exporter doesn’t return any error to guess what’s happening.
If there’s a proper way to get a variable from an external file, or some documentation where I can search…
Thanks in advance!


What is the idea behind the line:
if the field is already on the stage?

That is sometimes the case, that the template can be compiled without a problem, but does not work in CasparCG Is there any other information displayed in the log, after you play the template? Sometimes there is an ActionScript error logged, that helps a bit.


Ok, you where right,
was useless. I took it from another project of mine and didn’t remember what it did…
Then I looked to the Caspar logs and found this:

flash-player[cg20.fth.1080p6000|1920x1080] [error]        <invoke name="OnError" returntype="xml"><arguments><string>@Runtime error on template &quot;file://C:\Users\LPE\Desktop\TESTING\casparcg-server-2.2.0\template\CHYRONS\CP_TITULAR_TEST.ft@1@Error #2032@</string></arguments></invoke>

So I’m still lost. But thanks for your time!


But there is more on this error line. There must be at least an error number, that you can google…


In the line I read this error:

A fast search on google throws me back to an entry on this forum:

Reading a live text file - FileStream

As it seems to be an error related to Flash URLLoader.

Any alternative for reading a file?


I quickly compared your code to one of my templates, were I also used the URLLoader. There is no error in the code. So, the only thing I can see is, that the template does not find the data file. Are you sure, that “Titular.txt” is in Caspar’s template folder? It’s there were the code expect it to be.

By the way: Have you see the DATA commands, that allow to send data sets to Caspar asynchronously? Could probably be a better way to achieve what you are trying to do.


You were totally right!
The txt file was located on the template folder (so Adobe Animate found could find it)
But when placed on templates folder directly it worked flawless!

Lots of thanks!