Flash panels and dialogs functions

The following APIs enable you to add SWF files in panels and dialogs.

dreamweaver.flash.newControl()

Availability

Dreamweaver CS4.

Description

This function enables you to create a Flash control. It is referred to later through the controlID parameter. The control displays the Flash file (.swf) specified by the SWF path. The control is positioned and has the size specified in the defaultGeometry parameter.

note: Dreamweaver displays the Flash controls when you call flash.requestStateChange. Dreamweaver displays the Dialog controls when you call newControl; you need not call flash.requestStateChange.

Arguments

controlID, controlType, controlData

  • The controlID argument is a string value.

  • The controlType argument specifies whether the panel is a standard extension ("standard"), a trusted standard extension ("trusted"), or a plus extension (any other value). If it is a plus extension, the value is an identifier known specially to the host application that indicates the type of custom integration required. If the application does not understand the custom integration type, it returns an error.

  • The controlData is an object. Some of the following are the key properties of this argument:

    Property

    Description

    Values

    controlData.swfUTF8Path

    Location of the SWF. This property is required and it is passed in as a string of Unicode characters, since all characters in JavaScript are in unicode.

    The possible values for controlData.windowType

    • PanelWindow.The table following this table lists the specifications for this value.

    • ModalDialogWindow

    {controlData.scriptPath}

    Path to .js file that contains the functions to execute from .swf using External Interface call. This property is optional. If you want to call back into JavaScript code of Dreamweaver from the .swf file using an External Interface. You can provide a .js file containing functions that you can then call from the .swf file. For more information, see the dw.flash.executeScript call.

    controlData.defaultGeometry

    The defaultGeometry values are represented as screen coordinates from the upper left of the screen. This property is required.Object /*!< default creation geometry, including positioning */ { topleftx: Number, toplefty: Number, width: Number, height: Number }

The following table lists the PanelWindow specifications:

Options

Type

Descriptions

name

String

The name of the panel that appears on the tab. If you don't specify it, it is named "UNDEFINED". All panel names appear in uppercase. You cannot change it to lowercase.

{controlData.minSize}

Object

minSize only applies to controls of type PanelWindow. This option controls the minimum size that the panel can be resized to. This option is optional. If minSize is not specified, it defaults to the width and height specified in defaultGeometry and the panel cannot be resized. { width: Number, height: Number }

{controlData.maxSize}

Object

maxSize applies to controls of type PanelWindow only. This option is optional. This option controls the maximum size that the panel can be resized to. If maxSize is not specified, it defaults to the width and height specified in defaultGeometry and the panel cannot be resized..{ width: Number, height: Number }

{iconPathNormal}

String

Path to icon that must be used in the floating panel when the panel is collapsed in icon mode. This option is optional.

{iconPathRollOver}

String

Path to icon that must be used in the floating panel when the panel is collapsed in icon mode and the user rolls over it. This option is optional.

{iconPathDisable}

String

Path to icon that must be used in the floating panel when the panel is collapsed in icon mode and it is disabled. This option is optional.

Returns

One of the following success or error codes:

  • The code PlugPlugErrorCode_success indicates that creating the control succeeded.

  • The code PlugPlugErrorCode_extensionRegistrationFailed indicates that you were unable to register the control.

dreamweaver.flash.requestStateChange()

Availability

Dreamweaver CS4.

Description

This function changes the state of the floating panel identified by uniqueID for the extension with extensionID.

Arguments

controlID, stateChange, stateData

  • The controlID argument is a string value.

  • The stateChange argument is a string with the following possible values:

    Value

    Description

    Move

    Change of origin but not the size

    Resize

    New size and possibly a new origin

    Show

    Visibility only, but no geometric changes

    Hide

    Visibility only, but no geometric changes

    Minimize

    Like hide, but explains why it is hidden

    Restore

    Like show, but explains why it is displayed

    Open

    The window is created and its extension is loaded

    Close

    The contained extension is unloaded

  • The values of the stateData argument are strings as shown in the following table:

    Value of stateChange

    Value of stateData

    Move

    eventData = { topleftx: Number, toplefty: Number }

    Resize

    eventData = { width: Number, height: Number }

Returns

The following table contains the return values, which are strings:

Value

Description

RequestPosted

An event or command to execute the request has been queued in the host application.

RequestComplete

The host application has successfully completed the request.

RequestFailed

The host application attempted to complete the request, but failed.

RequestDenied

The host application refused the request, typically because it doesn't support the action requested.

Example

controlData = {}; 
controlData.defaultGeometry = {topleftx : 100, toplefty : 100, width : 200, height : 200 }; 
controlData.minSize = {width : 100; height : 100 }; 
controlData.maxSize = {width : 300; height : 300 }; 
var swfPath = dw.getConfigurationPath(); 
swfPath += '/flash/PhotoAlbum.swf'; 
controlData.swfUTF8Path = swfPath; 
// open the window 
flash.requestStateChange("com.adobe.extension.foo","Open",controlData.defaultGeometry);

dreamweaver.flash.controlEvent()

Availability

Dreamweaver CS4.

Description

This function is used to pass events to a flash control. Event calls are passed as an XML string that captures the function and the relevant parameters. The XML string captures the function in the SWF files that must be started.

Arguments

inControlID, inXMLString

  • The inControlID argument is a string.

  • The inXMLString argument is a string. Pass the following inXMLString to call the function in the flashCallback flash file and pass a single string, 'Hello' as an argument.

    <invoke name="flashCallback" returntype="xml"> <arguments> <string>Hello</string> </arguments> </invoke>

Returns

Returns an XML string.

Example

The following example calls the flashCallback function from JavaScript. In this example, you pass the callback function name and its arguments as an XML string.var xmlString = '<invoke name="flashCallback" returntype="xml"> <arguments> <string>Hello</string> </arguments> </invoke>';In this example, you use dw.flash.controlEvent to call back into the flash file (.swf):dw.flash.controlEvent('Flickr', xmlString);

The following arguments are used in this function:

var xmlString = '<invoke name="flashCallback" returntype="xml"> 
<arguments> 
<string>Hello</string> 
</arguments> 
</invoke>';
dw.flash.controlEvent('Flickr', xmlString);
  • Flickr, which is the ID of the extension that is passed in when the .swf control was created with dw.flash.newControl.

  • The XML string containing call back function and arguments.

The following example is the implementation of the flashcallback function implemented in flashcallback.mxml. In the following example, add the flashcallback function. This function must be called from external applications. public function initApp():void { ExternalInterface.addCallback("flashCallback",flashCallback); } This function is called back from outside the flash file(.swf).

note: Ensure that you call the ExternalInterface.addCallback ("flashCallback",flashCallback) before trying to call this function.

public function flashCallback(inputStr:String):String { out.text += inputStr + " got flashCallback!\n"; return "it worked!"; }

public function initApp():void { 
ExternalInterface.addCallback("flashCallback",flashCallback); 
}
public function flashCallback(inputStr:String):String 
{ 
    out.text += inputStr + " got flashCallback!\n"; 
    return "it worked!"; 
}

dreamweaver.flash.setMenu()

Availability

Dreamweaver CS4.

Description

This function enables you to provide Fly Out commands for extensions of type "PanelWindow".

Arguments

inControlID, inMenuPosition, inMenu

  • The inControlID is an extension ID. Calling the function affects the Fly Out menu of an open panel housing the extension. If this argument is undefined, the call affects the main menus of the application.

  • The inMenuPosition is a string describing where the given commands must be placed.

    • If this string is undefined, an entire menu is replaced.

    • If this string is for a panel, the entire user-settable area of the Fly Out menu is replaced. (The application reserves some fixed flyout items.)

    • If this string is for the application, the entire default Controls submenu of the Windows menu is replaced.

    • If this string is an XML string in a to-be-determined schema for setting sections of menus, this form is provided for future compatibility.

  • inMenu is equivalent to MenuItem . This argument indicates a list of commands, which are added at the indicated menu position. It replaces any previous items that are added at that position by an earlier call.

Returns

One of the following success or error codes:

  • The code PlugPlugErrorCode_success indicates success.

  • The code PlugPlugErrorCode_extensionMenuCreationFailed indicates that the extension menu creation failed.

  • The code PlugPlugErrorCode_unknown indicates that the function failed for unknown reasons.

Example

The following example is used for setting up the menu:function initializeMenuItem(menuID, menuName,extensionID, submenu) { var menuItem = {}; menuItem.menuId = menuID; //!< unique menu ID, if NULL menu is disabled menuItem.nameUtf8 = menuName; //!< Item title, if "---" item is a separator menuItem.extensionId = extensionID; //!< optional extension ID, used for panels only menuItem.submenu = submenu; //!< if non-NULL, this is a submenu return menuItem; } function setupMenu() { var menuItems = new Array(); menuItems.push(initializeMenuItem('id1','Call .swf ActionScript',undefined,undefined)); menuItems.push(initializeMenuItem('id0','---',undefined,undefined)); menuItems.push(initializeMenuItem('id2','Call Dw JavaScript',undefined,undefined)); dw.flash.setMenu('Flickr',controlID,menuItems); }

function initializeMenuItem(menuID, menuName,extensionID, submenu) 
{ 
    var menuItem = {}; 
    menuItem.menuId = menuID; //!< unique menu ID, if NULL menu is disabled 
    menuItem.nameUtf8 = menuName; //!< Item title, if "---" item is a separator 
    menuItem.extensionId = extensionID; //!< optional extension ID, used for panels only 
    menuItem.submenu = submenu; //!< if non-NULL, this is a submenu 
    return menuItem; 
} 
function setupMenu() 
{ 
    var menuItems = new Array(); 
    menuItems.push(initializeMenuItem('id1','Call .swf 
                    ActionScript',undefined,undefined)); 
    menuItems.push(initializeMenuItem('id0','---',undefined,undefined)); 
    menuItems.push(initializeMenuItem('id2','Call Dw JavaScript',undefined,undefined)); 
    dw.flash.setMenu('Flickr',controlID,menuItems); 
}
Note:

Specify a function named "onSelectMenuItem" in the JavaScript file specified in the scriptPath in the object passed to newControl.

The onSelectMenuItem is a menu Item Handler. It gets called with the corresponding menu ID when a command is selected from the Floater's Fly Out menu.

The following example specifies the Callback handler definition in 'Configuration/flash/Flickr.js': function onSelectMenuItem(menuID) { if (menuID == 'id1') { var flashCallbackString = '<invoke name= " flash Callback" returntype="xml"> <arguments><string>Hello</string></arguments></invoke>'; dw.flash.control Event('Flickr', flashCallbackString); return("PlugPlugRequestCompleted"); } else { alert ( ' You selected: menuID = ' + menuID); return ( " PlugPlugRequestCompleted"); } }

function onSelectMenuItem(menuID) 
{ 
    if (menuID == 'id1') { 
                            var flashCallbackString = '<invoke name= " flash Callback" 
                            returntype="xml"> 
                            <arguments><string>Hello</string></arguments></invoke>'; 
                            dw.flash.control Event('Flickr', flashCallbackString); 
                                   return("PlugPlugRequestCompleted"); 
                        } else { 
                                alert ( ' You selected: menuID = ' + menuID); 
                                       return ( " PlugPlugRequestCompleted"); 
                                } 
}

dreamweaver.flash.evalScript()

Availability

Dreamweaver CS4.

Description

This function is used to call a JavaScript function for one of the following purposes:

  • To execute a JavaScript function defined in the script file associated with the extension (for CSXS extensions).

  • The .js file defined in the scriptPath parameter for non-CSXS based Extensions.

Arguments

controlID, javascript function call

  • The controlID argument is the ID of the extension to execute the script. This ID must match with the ID specified as the first parameter to the dw.flash.newControl().

  • The JavaScript function call argument enables the user to call a function with any number of parameters.

Returns

A Boolean value: true if the function executed successfully; false otherwise.

dreamweaver.flash.executeScript()

Availability

Dreamweaver CS4.

Description

The function is used to execute functions in a .js file. The ActionScript in the .swf file starts the dreamweaver.flash.executeScript() function.

Arguments

javascript function call

Note:

Specify a path to the .js file that contains the functions you want to call.

Returns

An XML string that serializes into an ActionScript object.

Example

The following example contains a sample file, Sample.mxml and a JavaScript function in a JavaScript file, Sample.js.

private function executeScript():void { if(ExternalInterface.available) { out.text += "SwfCalledHost\n"; var scriptText:String = "helloWorld('scott');\n"; var resultStr:Object = ExternalInterface.call("dw.flash.executeScript",scriptText); out.text += "Result: " + resultStr.strResult + '\n'; } } The following JavaScript file contains a JavaScript function helloWorld() that is called from the .swf. This function uses the dw.getAppLanguage() call to return a five-letter language code that Dreamweaver is running in Sample.js.function helloWorld(nameStr) { alert('hello ' + nameStr); var appLanguage = dw.getAppLanguage(); var returnStr = '<object><property id="strResult"><string>Language: ' + appLanguage + '</string></property></object>' alert(returnStr); return (returnStr); }

private function executeScript():void 
    { 
        if(ExternalInterface.available) 
        { 
            out.text += "SwfCalledHost\n"; 
            var scriptText:String = "helloWorld('scott');\n"; 
            var resultStr:Object = 
                ExternalInterface.call("dw.flash.executeScript",scriptText); 
            out.text += "Result: " + resultStr.strResult + '\n'; 
        } 
}
function helloWorld(nameStr) 
{ 
    alert('hello ' + nameStr); 
    var appLanguage = dw.getAppLanguage(); 
    var returnStr = '<object><property id="strResult"><string>Language: ' + appLanguage 
            + '</string></property></object>' 
    alert(returnStr); 
    return (returnStr); 
}

dreamweaver.flash.controlExists

Availability

Dreamweaver CS4.

Description

This function is used to check the existence of the controls. PanelWindow controls are saved between the launches of Dreamweaver.

Arguments

controlID

Returns

A Boolean value: true if the control has already been created, false otherwise.

Get help faster and easier

New user?