Home Forums General XMetaL Discussion Read Flash (SWF) dimensions Reply To: Read Flash (SWF) dimensions

Derek Read

Reply to: Read Flash (SWF) dimensions

See the attached sample called swfExample.zip

I've made a self-contained customization that is as simple as possible to answer just this one question. You will ultimately take just those few relevent lines of code and adapt them to fit your own customization.

Legal:
* Licensed Materials - Property of JustSystems, Canada, Inc.
*
* (c) Copyright JustSystems Canada, Inc. 2011
* All rights reserved.
*
*-------------------------------------------------------------------
* The sample contained herein is provided to you "AS IS".
*
* It is furnished by JustSystems Corporation as a simple example and has not been
* thoroughly tested under all conditions. JustSystems Canada, Inc., therefore, cannot
* guarantee its reliability, serviceability or functionality.
*
* This sample may include the names of individuals, companies, brands and products
* in order to illustrate concepts as completely as possible. All of these names are
* fictitious and any similarity to the names and addresses used by actual persons or
* business enterprises is entirely coincidental.
*---------------------------------------------------------------------

Running the Demo:
1. Save the zip file (attached) and unzip it to an empty folder.
2. Confirm that you have the Adobe ShockWaveFlash ActiveX control installed on your system. This should be the case if you have installed the plug-in for Internet Explorer or perhaps other browsers. You need to obtain and install it if it is not installed already.
3. Launch XMetaL Author Enterprise or Essential and open test.xml. The file “lorem.swf” (generated from a sample included with Corel R.A.V.E.) should be rendered within the element. An alert dialog should also be displayed telling you what the width and height are. Further information is contained within test.xml

More Info:
Essentially what needs to be done is to integrate the two method calls discussed on http://blog.codefidelity.com/?p=14 into your own script(s). Provided you have access to the ActiveX control (as in this example) you should be able to access all of its properties and methods (for details on what those are refer to Adobe's documentation).

The most relevent portion of the demo is the event macro that calls the method TGetProperty (shown in blue) as follows:

 var IPC = Application.ActiveInPlaceControl;
 if (IPC != null) {
   var domnode = IPC.Node;
   // Tell ShockWave to open file from swf @href value, noting that it needs an absolute filepath
   attrnode = domnode.attributes.getNamedItem("href");
   if (attrnode != null) {
     var swfPath = "";
     swfPath = swfPath + IPC.Document.LocalPath;
     swfPath = swfPath + "\" + attrnode.value;
     var ShockWaveFlash = IPC.Control;
     if (ShockWaveFlash != null) {
       ShockWaveFlash.Movie = swfPath;
       ShockWaveFlash.Play();
       var msg = "Internal dimensions of " + swfPath +" (as reported by the ShockWaveFlash control) are: ";
        var w = ShockWaveFlash.TGetProperty("/", 8);
        var h = ShockWaveFlash.TGetProperty("/", 9);

       msg += "nnwidth:" + w + "nheight:" + h;
       Application.Alert(msg);
     } else {
       Application.Alert("Unable to load ShockWaveFlash ActiveX control.","swf_OnInitialize Macro Error");
     }
   }
 }
]]>

Reply

Products
Downloads
Support