Imlpement Flash Application via Module?

Imlpement Flash Application via Module?

by Peter Wetz -
Number of replies: 4
Hello Dear Moodle Developers!

Recently I developed a standalone flash application. Now that it is finished my tutor wants the application to be implemented into our moodle-system.
the goal now is to make my application accessible for people who are logged in to the moodle system and that my flash-application can read the "currently logged-in username" to write this name into a text-field inside the flash application.

how is this done the easiest way? should i create a new module, which simply embeds my flash application?

thank you in advance for your help,
regards,
Peter
Average of ratings: -
In reply to Peter Wetz

Re: Imlpement Flash Application via Module?

by Matt Bury -
Picture of Plugin developers
Hello Dear Moodle Developers!

Peter contacted me via Skype and we sorted a few possibilities out.

Peter, could you post your experiments/solutions here? It'd be good to share what you've done with the Moodle + Flash community.

I look forward to seeing the results! smile
In reply to Peter Wetz

Re: Imlpement Flash Application via Module?

by Artem Andreev -
In reply to Peter Wetz

Re: Imlpement Flash Application via Module?

by Peter Wetz -
first of all: thanks for all of your replies and very special thx to matt and for the very helpful and interesting conversation yesterday via skype.

my "solution":
in my experimental moodle i created a new course => new resource and embeded my swf-application as matt already explained here some time ago: http://moodle.org/mod/forum/discuss.php?d=88006#p388897
be sure to allow embed/object-tags in your moodle installation (Site Administration > Security > Site Policies > Check the 'Allow EMBED and OBJECT tags').

if you want to embed swfs more frequently i strongly recommend using matt's swf activity module: http://code.google.com/p/moodle-swf/
i did not use it in my experimental environment, because embeding worked immediately. my swf-application also uses external php-scripts. be sure to make the paths absolute in your action script code.

to get the username of the logged-in user into a textfield in flash i wrote a very very tiny php-script which passes the username to flash (may not be the best/most elegant solution but it works):

php-code:
<?php
require_once('../moodle/config.php');
global $USER;
$username = fullname($USER);
$vars = "" ;
$vars .= "&username=" . $username."&";
echo $vars ;
?>

flash code:
loaduser = new LoadVars();
loaduser.load("http://direct/path/to/php/getuser.php");

loaduser.onLoad = function() {
nametxt.text = loaduser.username;
};


for the moodle-php-flash communication: also if you want to make heavier use of calling php-methods for moodle-flash communication matt recommended me to use AMFPHP ( http://www.amfphp.org/ ). after AMFPHP is up and running you can call php functions directly from your action script code!
In reply to Peter Wetz

Re: Imlpement Flash Application via Module?

by Matt Bury -
Picture of Plugin developers
Yes, AMFPHP is particularly easy to use with ActionScript 3.0 (Flash Player 9.0+) as it has the Flash Remoting class libraries already installed. With AS 2.0, as Peter is using, you need to download and install some extra libraries for Flash 6.0 - 8.0. Here's the download link: http://www.adobe.com/products/flashremoting/downloads/components/

There's more about AMFPHP in Moodle docs here: http://docs.moodle.org/en/Development:AMF3

Moodle 2.0 includes a different version of Flash Remoting called Zend_AMF by the same developer, Wade Arnold: http://wadearnold.com/blog/ The principles are the same but there's a little bit more to do on the PHP side but this also makes it a more flexible service library. The only disadvantage Zend_AMF has compared to AMFPHP is that it doesn't include a service browser - a brilliant Flex application that lists all your PHP service scripts and allows you to test and debug them. It speeds up development time enormously! If you're just getting started with Flash Remoting, I recommend using AMFPHP first, just to get the hang of how it works. smile