Flash template text manipulation


#1

I write custom controller app for a quiz in c# and can not find splition to change text color inside template from controler. Can somebody help? Thanx in advance


#2

textfields have a property called .textColor that you can set the color. Use a number in hex to set the color 0xFF0000 is red for instance.


#3

From the C# side it’s

String.Format("0x{0:X8}", Color.ToArgb)


#4

is there any good tutorial how to connect external .as file with .ft file, i am pretty new to ActiveScript programming. I use flash CC 2015. I understand that i need to pass custom parameter to AS and use that parameter to define correct or wrong answer, and in SetData(xmlData:XML):void override to change color of, example f2 dynamic text from white to green on red.


#5

Partfully you can read this While it only deals with dynamic images, the workflow is the same. To change colors for text, use the .textColor property. To change colors of rectangles and the like you need a ColorTransform You find plenty of examples via Google if you search for, as this is normal ActionScript and not xaspar specific.


#6

i have created this in as file, but now i do not get any data i send via AMCP in my template, when i remove reference to as file, i can pass data correctly. What is error here?

package
{
	import caurina.transitions.Equations;
	import caurina.transitions.Tweener;
	import flash.display.Loader;
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.events.TimerEvent;
	import flash.net.URLRequest;
	import flash.text.TextField;
	import flash.utils.Timer;
	import se.svt.caspar.template.CasparTemplate;
	
	public class ig1 extends CasparTemplate
	{
		
		private const customParameterDescription:XML = 	
														<parameters>
														   <parameter id="odgmark" type="int" info="markiranje odgovora" />
														</parameters>;
		
		override public function SetData(xmlData:XML):void 
		{
			for each (var element:XML in xmlData.children())
			{
				if (element.@id == "odgmark") 		
				{	if (element.data.@value == "1") this['f1'].f1.textColor = 0x00ff00;
					if (element.data.@value == "2") this['f2'].f2.textColor = 0x00ff00;
					if (element.data.@value == "3") this['f3'].f3.textColor = 0x00ff00;
					if (element.data.@value == "4") this['f1'].f1.textColor = 0xff0000;
					if (element.data.@value == "5") this['f2'].f2.textColor = 0xff0000;
					if (element.data.@value == "6") this['f3'].f3.textColor = 0xff0000;
				}
			}
		}
		//super.SetData(xmlData);
	}
}

#7

I normally add {} around the code in if statements. Don‘t know if that works. And also that this [‚f1‘] syntax I never saw before…


#8

if i just add f1.textColor = 0x00ff00; i get error:

Line 29, Column 39 1120: Access of undefined property f1.

With this i get no errors in exporting with template builder. I tried adding {} but it is same.


#9

And what is f1? A TexField? Is it inside of a MovieClip?


#10

yes, dynamic text, i used naming scheme from f0 to f5, and it is inside of movie clip symbol


#11

Then it needs to be called like so: “InstanceNameOfTheMovieClip.f1.textColor” other wise it wil not find it.


#12

i have this in my scene:

Scene 1 -> Tween 12 -> Symbol 3 -> f1 TextField, i tried tween 12.Symbol 3.f1 but also get error. And i did not touch f0 or f4 textfields with this code, but i do not get them also in template, i just get blank graphic


#13

Get rid of the spaces in names and try again. And also the objects must exist on frame 1 in the timelines.


#14

i gave them instance names, and now can export without error, but it is save, no text on output

here is archive with as and fla file, maybe someone can take a look and see what is problem. Graphic is just for testing, still waiting for a final design


#15

Grab1

You need to make ALL OBJECTS to be present at the first frame. They can have the alpha value be animated to 0 so that they are not visible, but the code will run in the first frame, and what is not there (the 4 objects I circled) will not be found and nothing will be setted.


#16

interesting, this template worked before i added as code, i tried that and i added key frames at begging, but still same result


#17

You use clasical tweens. I think they start a new object every time you start a new one. Use only one motion tween per object.


#18

well i recreated template with motion tweeing as you said, and still same. If i include .as file in fla, on output get no text, just graphic. Everything other works ok, just no text at all. As i remove as from template, text fields are displayed correctly. Something problematic is in those as file, i can not find.


#19

and btw when i uncomment live with code

super.SetData(xmlData);

i get error on exporting

|D:\OneDrive\CasparCG Server\Server\templates\ig1.as, Line 46, Column 9|1061: Call to a possibly undefined method SetData through a reference with static type flash.display:Sprite.|
|D:\OneDrive\CasparCG Server\Server\templates\ig1.as, Line 46, Column 17|1120: Access of undefined property xmlData.|

#20

see here a example of a scorebug , which has 4 fields for the player colors. .ft, .fla and.as file included.
Scorebug

here a example ot a speechtimer display where you can choose the color of the time…ft, .fla and.as file included.
Redetimer

here the Speechtimer, one Exe and on DLL, put it in the same folder.
Speechtimer Program