No announcement yet.

AS3 - Setting up Non-CLIK TextFields

  • Filter
  • Time
  • Show
Clear All
new posts

    AS3 - Setting up Non-CLIK TextFields

    Setting up an AS3 text field to be dyanmically populated by UnrealScript is not much different than setting up an AS2 one.

    Stage Setup
    1. Create a standard Flash text field on the stage.
    2. Give it an instance name: myTextField
    3. Be sure to embed the font you use, and include the 'Basic Latin' character range.
    4. Now right click the text field, and choose Convert to Symbol.
    5. Name it, and press OK.
    6. Give the new Movie Clip an instance name: myTFMC

    ActionScript 3.0

    On the main timeline, add these two import statements:

    import scaleform.gfx.Extensions;
    import scaleform.clik.core.CLIK;
    Next, we need to tell the new text field widget to fire off a WidgetInitialized() event:

    if( Extensions.CLIK_addedToStageCallback != null)
        Extensions.CLIK_addedToStageCallback(, CLIK.getTargetPathFor(myTFMC), myTFMC);
    Save and Publish the movie, then import it into UDK.


    In UnrealScript, we need to declare two variables:

    var GFxObject	MyTFMC, MyTextField;
    Next, we create our WidgetInitialized() function, much the same way we do for AS2 widgets:

    event bool WidgetInitialized(name WidgetName, name WidgetPath, GFxObject Widget)
    	case ('myTFMC'):
    	    MyTFMC = Widget;
    	    MyTextField = MyTFMC.GetObject("myTextField");
    	    MyTextField.SetString("text", "123 - It works!");
    	return true;
    Last of all, we'll include a widget binding line in the default properties:
    Save the UnrealScript file, rebuild scripts, and test out your movie.

    I've been trying to set this up but for some reason the widgetInitialized event is not called at all in unreal script, even though in the flash file the command line which should trigger it, is accessed.
    Extensions.CLIK_addedToStageCallback(HighScore0_mc .name, CLIK.getTargetPathFor(HighScore0_mc), HighScore0_mc);
    It's pretty much like shown above, so, I'd guess my flash file is fine.
    should it trigger all instances of the widgetInitialized event?


      This sample code will only work for a single movieclip. And, the movieclip must exist at the time that the Extensions.CLIK_addedToStageCallback(, CLIK.getTargetPathFor(myTFMC), myTFMC); code is called. If the movieclip is on a different frame than this code, it won't work.


        the way I set it up , I'm accessing that line of code in the same frame as the object it relates to, both are on frame 10.
        I've read in another post that in some releases of UDK we needed to add a line similar to this to get WidgetInitialized to be fired
        [InspectableList("disabled", "visible", "textID", "password", "maxChars", /*"restrict",*/ "editable", "actAsButton", "defaultText", "enableInitCallback", "soundMap")]!

        yet..It doesn't seem to work for me