Flash Template, with external file input

flash

#1

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…


#2

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?


#3

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?


#4

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


#5

(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.


#6

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?


#7

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


#8

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!


#9

What is the idea behind the line:
addChild(l3Title);
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.


#10

Ok, you where right,
addChild(l3Title)
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!


#11

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


#12

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?


#13

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.


#14

Damn!
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!

Xavi