So I thought I'd spend some time demonstrating how easy it is to use the Flash Activity Module and Flash to make highly interactive learning activities.
This tutorial assumes some knowledge of Flash.
So here we go :
- fire up Flash
- make a new doc
- save it to your web folder in mod/flash/movies/tutorial1/ as tutorial1.fla (You'll need to make a new dir).
- go to file->pubplish options and you can uncheck every format except .swf, we don't need to publish the html file.
- you must select to Publish for Flash version 6. I found during testing that the movie preloader doesn't seem to be working when publishing for Flash version 7.
- make a text field on the stage with name textfield1. Put in text 'uninitialised'
- put the code below on the first frame of the movie.
- click publish
// first request username
//this function responds to the return call from Moodle after init is called.
moodleService.onInit=function(){
_root.textfield1.text = moodleService.userFirstName;
}
//here we now call init
moodleService.init();
Code for service.php :
<?php class service { function service() { //this will allow you to access the first name of the user global $USER; $this->userFirstName=$USER->firstname; } } ?>
After the movie is loaded you will see your username displayed in the Flash movie.
What you are seeing here is Flash communicating with php. This is not so interesting to just fetch the username of a user- but imagine you can do anything you want to on the server with php and return the result to Flash. We can access all the functions in lib/datalib.php and other moodle functions since before the service function above is called we are running config.php which in turn runs up setup.php and sets up the normal moodle code environment.
We'll do some more complicated stuff later.
I've attached the zip file of all the files you should have in mod/flash/movies/tutorial1/ after you followed the steps in this tutorial.
Jamie