Was this page helpful?

Custom Forms - Scripting

    Since web version of form designer, custom forms bring custom scripting, which is pretty powerfull feature. It is evolving part of application, based on needs of our clients, so there is no definite state of this feature. Scripting is pretty straitforward and selfexplanatory (you just write an ActionScript to it), but you need to know some basic principles, like accessing the form elements, accessing the selected context value or interaction with the application itself. Those features are providet by scripting API - set of functions which enables these features.

    Accessing component in form

    If you want to acces some component in form, you ahve to set the identifier for this component. Then you can access it by method getComp. Then you can work this the component as you wish, access its methods and properties.

     

    The following example will sum values from components textInputA and textinputB into component textfieldC:

    var valueA:Number = Number(getComp("textInputA"));
    var valueB:Number = Number(getComp("textInputB"));
    
    getComp("textfieldC").text = valueA + valueB;

    You can find component properties on Adobe documentation, for example Textfield:

     http://help.adobe.com/cs_CZ/FlashPlatform/reference/actionscript/3/flash/text/TextField.html

    Triggering events

    When you know how to work with components, next step is define, when to run the event. The events are solved method createListener which takes 3 parameters - name of object where we listen, name of event and function to be triggered.

    Following function will show you how to trigger the functionality from previous example on change of bot inputs - textInputA and textInputB.

    this.createListener("textInputA", "change", sumInputs);
    this.createListener("textInputB", "change", sumInputs);
    
    function sumInputs(evt:Object):void
    {
        var valueA:Number = Number(getComp("textInputA"));
        var valueB:Number = Number(getComp("textInputB"));
        getComp("textfieldC").text = valueA + valueB;
    }
    

    You can find events on objects using classical ActionsScript reference, for example button events like click, mouseDown, mouseUp, rollOver, mouseOut and so can be found on link: 

    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fl/controls/Button.html

    An example how this works in OSSPO

    this.createListener("SmlouvaNaDobu", "change", updateSmlouvaNaDobu);
    this.createListener("SmlouvaNaDobu2", "change", updateSmlouvaNaDobu);
    this.createListener("SmlouvaNaDobu3", "change", updateSmlouvaNaDobu);
    this.createListener("DatumUzavreniSmlouvy", "change", updateSmlouvaNaDobu);
    this.createListener("DatumUzavreniSmlouvy2", "change", updateSmlouvaNaDobu);
    this.createListener("DatumUzavreniSmlouvy3", "change", updateSmlouvaNaDobu);
    this.createListener("SmlouvaNaDobuCelkem", "change", updateSmlouvaNaDobu);

    function updateSmlouvaNaDobu(evt:Object):void
    {
        if(getComp("DatumUzavreniSmlouvy").text != "")
        {
            getComp("SmlouvaNaDobuCelkem").text = getComp("SmlouvaNaDobu").text;
        }
        
        if(getComp("DatumUzavreniSmlouvy2").text != "")
        {
            getComp("SmlouvaNaDobuCelkem").text = getComp("SmlouvaNaDobu2").text;
        }
        
        if(getComp("DatumUzavreniSmlouvy3").text != "")
        {
            getComp("SmlouvaNaDobuCelkem").text = getComp("SmlouvaNaDobu3").text;
        }
    }

    Was this page helpful?
    Tag page (Edit tags)
    • No tags
    Page statistics
    761 view(s), 3 edit(s), and 4412 character(s)

    Comments

    You must login to post a comment.

    Attach file

    Attachments