If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.


From MoodleDocs

SWF Activity Module

The module documentation on this page is out of date. Please see the SWF Activity Module project site for up to date downloads, documentation and help.

I've moved the project code and documentation to Google Code:

The most recent downloads and documentation are available there.

What is the SWF Activity Module?

The SWF Activity Module provides a comprehensive and flexible method for deploying Flash and Flex Framework learning applications as activities in a Moodle course.

How does is work?


The SWF Activity Module uses SWFObject as the default embed method for Flash and Flex Framework learning applications. The module also incorporates standard XHTML 1.0 strict object and embed code that functions if SWFObject fails for any reason, e.g. If the user has Javascript blocked in his/her browser.

Once installed, select SWF from an "Add an activity" list on a Moodle course page. The standard "Adding a new SWF to topic... " moodleform will appear. Help files are included in the SWF Activity Module in English and provide further details about the parameters. In this form you can set the following parameters:

Required Parameters

* As with all Moodle activities, name and intro.
* SWF file
* Height
* Width
* Version

Optional Parameters

* AMF Interaction (Not yet implemented)
* XML file URL
* FlashVars #1
* FlashVars #2
* FlashVars #3

Advanced Parameters

* API Key (SWF Activity Module custom parameter)
* Align
* Auto Play
* Loop Playback
* Menu
* Quality
* Scale Mode
* Stage Align
* Window Mode
* Background
* Use Device Font
* Seamless Tabbing
* Allow Full Screen
* Allow Script Access
* Allow Networking

You can find more details about these parameters in the SWFObject Documentation.

What features does it support?

The SWF Activity Module automatically provides a deployed SWF learning activity application with the following data:

* gateway - URL to gateway script for access to AMFPHP service library
* course - the current Moodle course that the user is accessing
* instance - Instance ID of the module
* swfid - The ID of the SWF learning activity application
* interaction - The ID of the SWF learning interaction data to consume (AMFPHP)
* moodledata - The URL to access the current moodledata course directory (file.php)

It also supports a number of features, specific to Flash and Flex applications. They are:

Flash Remoting (AMF)

Flash Remoting is a method for Flash or Flex applications to communicate directly with server-side applications written in .NET, Java, PHP, Cold Fusion and Ruby on Rails. There are a number of open-source libraries for handling communication via Flash Remoting:

See AMF3 for details on how to set up AMFPHP in Moodle and more information about Flash Remoting technologies.

XML Data Loading

XML is a native data type to ActionScript 3.0 therefore Flash and Flex Framework learning applications use E4X notation to manipulate XML data in a similar way to a multidimensional array. For more details, see Adobe Actionscript 3.0 Language and Components Reference. XML is also currently the most commonly used format for providing elearning data for learning interactions. The most commonly used format is IMS's standard QTI (Question and Test Interoperability specification) but basically any valid XML file with the appropriate data tree structure can be loaded into and consumed by a SWF file.


FlashVars is a method for passing string data into a SWF file. It is passed in from the printed HTML page that the SWF file is embedded in. It's ideally suited to very simple data sets such a vocabulary lists or series of numerical values. For learning activities such as hangman, crosswords, word searches, etc., FlashVars is simple, efficient and easy to use.

What's Next?

Moodle Grades

One of the most requested features for Flash and Flex Framework learning applications deployed in Moodle is for them to have the ability to record learners' activities in Moodle's Gradebook.


The most powerful and flexible way for Flash and Flex Framework learning applications to interact with Moodle APIs, databases and web services is via Flash Remoting AKA AMF3, a communication protocol which is similar to JSON but much faster. It allows Flash and Flex Framework learning applications to directly call PHP methods and pass a number of different data types back and forth seamlessly.

For more details about using AMFPHP in Moodle, see AMF3

Learning Interaction Data DB Structure

A standardised DB table structure to store learning interaction data with a variety of methods to populate the tables with data, including Moodle forms, dynamic Flash or Flex Framework on-line forms.

Also, standalone Adobe AIR desktop GUI applications, which can store data locally using SQLite, to create and edit learning interactions and then upload them. Using Adobe AIR will also provide convenient backup of interaction data and a means to easily transfer and distribute learning interactions.

swf_interactions fields

* id
* course
* name
* intro
* introformat
* amftable - Default is swf_interaction_data but this allows for further, more specialised tables to be used
* timecreated
* timemodified

swf_interaction_data fields

* id
* interaction - ID of interaction (id of swf_interactions)
* ordernum - Allow sequential ordering of rows
* amp3 - URL of answer MP3 file
* qmp3 - URL of quesition MP3 file
* smp3 - URL of additional MP3 file
* image - URL of image file
* video - URL of FLV file
* ptext - Paragraph text
* qtext - Question
* catext - Correct answers (for multiple choice, use pipe separator as delimiter)
* watext - Wrong answers (for multiple choice, use pipe separator as delimiter)
* timecreated
* timemodified

See Also

  • AMF3 Flash Remoting for Moodle.
  • Media Player Activity Module for deploying video in Moodle as an activity. Leverages the full range of functions of Jeroen Wijering's JW FLV Player.
  • Matt Bury's website and Moodle with demos of SWF Activity Module and Media Player modules.