It is currently 25 Jun 2017, 21:49



as3 dynamic text field does not get input

Videos, graphics, Flash templates – how to create and play them using CasparCG

Moderators: Macey, Jonas Hummelstrand, didikunz

as3 dynamic text field does not get input

Postby tusa » 17 Mar 2017, 09:13

Hello.

I have a textfile wich formatted in as3 like this:
Code: Select all
   import flash.events.Event;
   import flash.events.TimerEvent;
   import flash.geom.Matrix;
   
   var scrolling_speed:int = 3;
   var format2:TextFormat = new TextFormat  ;
   f0.type = TextFieldType.DYNAMIC;
   f0.x = 1827;
   f0.selectable = false;
   f0.border = false;
   f0.multiline = false;
   f0.wordWrap = false;
   f0.autoSize = TextFieldAutoSize.LEFT;
   
   f0.setTextFormat(format2);
   
   var snapshot:BitmapData = new BitmapData(f0.width,f0.height,true,0x000000);
   snapshot.draw(f0, new Matrix());
   
   var bmp:Bitmap = new Bitmap(snapshot);
   addChild(bmp);
   
   bmp.x = 1827;
   bmp.y = 60;
   
   bmp.mask = crawl_mask_mc;
   
   bmp.addEventListener(Event.ENTER_FRAME,move_text);
   function move_text(myevent:Event):void
   {
      bmp.x -=  scrolling_speed;
      if (bmp.x < (300 - bmp.width))
      {
         bmp.x = 1827;
      }
   }

But it won't get the typed text in field f0
Howcome?
tusa
 
Posts: 49
Joined: 14 Nov 2014, 15:15

Re: as3 dynamic text field does not get input

Postby Jesper Stærkær » 17 Mar 2017, 09:54

Hi.

There's an automated process going on to achieve the "f0" mapping once you generate a template with the exporter. However, this only applies to text fields on the timeline.

So, in order to get data through to your text field you could either

a (recommended) register a component:
1) Wrap your text field in a new class, with MovieClip as base class.
2) Implement the interface ICasparComponent, which makes you set functions SetData(xmlData:XML):void and dispose():void. dispose() is just a convenience method to allow you clean up if the component gets removed.
3) In SetData, you will receive all the <componentData> with a @id matching your components (your MovieClip) name. So make sure to set a name, perhaps in your constructor, or on the timeline if you create it there.
4) Manually extract the @value attribute and update your textfield.



b (unfortunately the most common way, manually set data)
1) override public function SetData(xmlData:XML):void in your template's document class, extending the base class CasparTemplate.
2) Traverse throug all <componentData /> childs withint the <templateData /> received in SetData, and extract + update your text field from here.
3) The downsides of this method, which the proper component chain (brilliantly) solves are: you avoid race conditions, since the data buffers until the component is ready and your don't need to hold references to all components.

Remember: all object can be registered components and have data injected, not only TextFileds!
Jesper Stærkær
Independent Consultant at SuperFly.tv
User avatar
Jesper Stærkær
 
Posts: 853
Joined: 13 Apr 2010, 18:06
Location: Trondheim, Norway

Re: as3 dynamic text field does not get input

Postby tusa » 18 Mar 2017, 04:15

Now I tried something, but it stil don't work??
https://www.dropbox.com/sh/j1rphgzrcwka4x1/AAAAKVcAMnWjChF3OPvI-m12a?dl=0

There are 2 different versions...
tusa
 
Posts: 49
Joined: 14 Nov 2014, 15:15


Return to Content

Who is online

Users browsing this forum: No registered users and 2 guests