Extension:Flashlets

From MediaWiki.org

Jump to: navigation, search
Manual on MediaWiki Extensions
List of MediaWiki Extensions
Flashlets

Release status: beta

Implementation Tag
Description A taghook which allows ActionScript to render as an embedded SWF movie by compiling it with the free open-source MTASC ActionScript compiler.
Author(s) User:Nad
Version 1.0.4 (2007-09-04)
MediaWiki All versions
Download see Extension:Flashlets article

Contents


[edit] Example usage

The simplest usage is just to embed an existing SWF in the page, as in the following example:

<swf src="/images/foo.swf" width="200" height="200" fps="50" caption="Click to download" bgcolor="#ff0070">

If you have the $wgFlashletsMTASC global set to the internal path of your MTASC compiler, then you can also directly include ActionScript code in the tags which will be compiled and embeded dynamically. Below is a syntax example, you can test it out in the Peerix Sandbox.

<swf width="200" height="200" fps="50" caption="Click to download" bgcolor="#ff0070">
class Ball {
        static var app : Ball;
        function Ball() {
 
                // Create a ball
                _root.createEmptyMovieClip('ball',1);
                var r = 50;
                var w = r*2;
                var k = 0.93;
                var colours = [0xffffff,0xffcccc,0xff0000,0x000000];
                var alphas = [100,100,100,100];
                var ratios = [0,5,50,250];
                var matrix = {matrixType:'box',x:-r*1.3,y:r*1.3,w:r*4,h:-r*4,r:0};
                with (_root.ball) {
                        lineStyle(0,0,0);
                        beginGradientFill('radial',colours,alphas,ratios,matrix);
                                moveTo(0,-r);
                                curveTo(r*k,-r*k,r,0);
                                curveTo(r*k,r*k,0,r);
                                curveTo(-r*k,r*k,-r,0);
                                curveTo(-r*k,-r*k,0,-r);
                        endFill();
                        x  = 0.0;
                        y  = 0.0;
                        vx = 2.0;
                        vy = 0.0;
                        mx = 2.0;
                        my = 12.0;
 
                        // Dynamics (called each frame)
                        onEnterFrame = function() {
                                with (this) {
                                        x += vx; y += vy; vy += 0.5;
                                        if (vy > my) vy = my;
                                        if (x < 0)   { x = 0; vx = mx; }
                                        if (x > 200) { x = 200.0; vx = -mx; }
                                        if (y > 200) { vy = -my; y = 200.0; }
                                        _x = x;
                                        _y = y;
                                        }
                                };
                        }
                }
 
        // entry point
        static function main(mc) {
                app = new Ball();
                }
        }
</swf>

[edit] Installation

First create a Flashlets directory in your wiki's extensions directory. Copy the Flashlets source code from OrganicDesign:Extension:Flashlets.php. Include the Flashlets.php file you downloaded in your LocalSettings.php file as usual, for example:

include("$IP/extensions/Flashlets/Flashlets.php");

To allow dynamic compiling of ActionScript into embeded SWF's, you need to download the Container.swf file and save in the your Flashlets directory. (you'll need to use right-click and "save as" to save Container.swf becasue it will open in your browser if you just click the link normally).

Also the free open-source MTASC ActionScript compiler from www.mtasc.org needs to be installed. They have pre-build packages for Linux, OS X and Windows, so download the appropriate version onto your system. The default settings for the Flashlets extensions assume that the mtasc files are unpacked into your Flashlets directory, but you can install it any way you like as long as you set the $wgFlashletsMTASC and $wgFlashletsCP globals to match your MTASC install. The directory structure should now look similar to the following example:

extensions/Fflashlets/
extensions/Flashlets/Flashlets.php
extensions/Flashlets/Container.swf
extensions/Flashlets/mtasc/
extensions/Flashlets/mtasc/CHANGES.txt
extensions/Flashlets/mtasc/Future.txt
extensions/Flashlets/mtasc/mtasc
extensions/Flashlets/mtasc/Readme.txt
extensions/Flashlets/mtasc/std
extensions/Flashlets/mtasc/std8

[edit] Global settings

Here are some global variables which affect the operation of the extension. These should be set in your LocalSettings file after the include of the Flashlets.php script.

Variable Default value Meaning
wgFlashletsMagic swf The tag name used to contain the ActionScript code to be compiled
$wgFlashletsMTASC flashlets-dir</mtasc Command used by the local system to launch the MTASC executable, set this to empty to disable SWF compiling ability
$wgFlashletsCP flashlets-dir/std Directory containing the MTASC class headers
$wgFlashletsPath $wgUploadPath The client-side path to the directory containing the SWF's
$wgFlashletsDirectory $wgUploadDirectory The server-side path to the directory containing the SWF's
$wgFlashletsExpandTemplates true If true, MediaWiki templates in the script will be expanded before compiling

[edit] Parameters

Name Default value Meaning
width 300 The width in pixels of the compiled SWF movie
height 200 The height in pixels of the compiled SWF movie
fps 25 The number of frames per second of the SWF
bgcolor #ffffff Specifies whether or not security directives in categories inherit to member articles
caption no caption If set, the SWF will have a caption below it which is a link to download the SWF
ver 6 The SWF version to use when compiling the ActionScript into a SWF binary

[edit] Change log

  • 1.0.4 (2007-09-04): Fixed location-dependence bug
  • 1.0.2 (2007-07-25): Allow embedding of existing SWF's and make compiling ability optional
Personal tools