next up previous contents
Next: Changing screen resolutions Up: Tutorials Previous: Sending and receiving emails   Contents

Creating multiple forms

With SWFKit Pro, you can create modal or modeless forms. The following code shows how to create a form in action script in Flash 8.
    import SWFKit.*;

    var form = new Form;
    form.movie = Global.getAdditionalFile("forform.swf");
    form.caption = "Hello, Form!";
    form.showCaption = true;
    form.canDrag = true;
    form.initVars = "formid=" + form.Identifier;
    form.show(true);
As you can see from the above code, a Form is a child window that displays another flash movie. The form object is created in the main movie, how can we programming the form object in another flash movie? This can be done by pass the identifier of the form object to the form movie: form.initVars = "formid=" + form.Identifier;. In this case, we can get the form object in the first frame of the form view. The following code is in the first frame of the "forform.swf"
    import SWFKit.*;

    var id = parseInt(formid);
    SWFKit.Global.trace(formid);
    var form = Form.fromID(id);
    SWFKit.Global.trace(form.Identifier);

After getting the form object, we can create an ActiveX control in the form, for example, the web browser control

    import SWFKit.*;

    var id = parseInt(formid);
    SWFKit.Global.trace(formid);
    var form = Form.fromID(id);
    SWFKit.Global.trace(form.Identifier);
    var ax = form.createControl("Shell.Explorer.2", 0, 0, 200, 200);
    var activex = ActiveXObject.fromID(ax.activex);

    activex.callMethod("Navigate2", "http://www.topcmm.com");

    // To fill the activex control in the entire form
    var width = form.window.clientRect.width;
    var height = form.window.clientRect.height;
    ax.window.move(0, 0, width, height);



Copyright ©2000-2007 Shanghai TopCMM Software Technologies. All Rights Reserved.