.swf file problem

.swf file problem

by Richard Wright -
Number of replies: 17

Hello all,

Linking to .swf files is working fine, apart from when the .swf file uses external .txt files - these .swf files will not work properly.  We're using Windows and Apache.

For example, one such file was a quiz, and pressing the submit button after the first question brought up the 'wrong answer' feedback no matter what answer was selected, preventing progression to the next question.

We've tried the file directly in Apache and this works fine, so the problem must be something with Moodle.

Any advice would be gratefully appreciated.

Thank you very much.

Average of ratings: -
In reply to Richard Wright

Re: .swf file problem

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
any chance of posting a very stripped down example that demonstrates the problem? I'd be happy to set it up myself, and see if I can work out a solution.
In reply to Richard Wright

Re: .swf file problem

by Mike McKee -
I too have come across this problem. I have a jeopardy game I made in flash and it loads the categories, questions and answers from an external file.  However it will not load this external file in moodle.  It looks like it needs the abolute moodle path for it to work... also if I create a html file and upload it to moodle and it has a flash .swf file embedded it won't load the swf file... The solution is to set the path to the text file it needs to load or swf file to the absolute moodle path.  So instead of it looking to load text.txt you would say load http://www.yourdomain.com/moodle/file.php?file=/somedirectory/text.txt the problem comes in that most users would not know how to do this.  So the question is how do you call this path in flash and get the correct directory that the file is in? I am guessing do some sort of check for the file if it can't find it then look in the moodle absolute path by including maybe the moodle config file and then using the absolute path from there along with the courses directory and then the file name.  I will try to do this with mine and let you know what I come up with.
In reply to Mike McKee

Re: .swf file problem

by Chardelle Busch -
Picture of Core developers

Hi,

I have a flash file that plays mp3s as well as loading a text file of the audio.

I have this in my script:

butTrack1.onRelease = function(){
      mSound = new Sound(this);
      mSound.loadSound("audio.mp3", true);// mSound.loadSound("url",true = stream on, false = stream off);
      mSound.start(pos, 1);//mSound.Start(Start position in seconds, number of repetitions);

and:

loadVariablesNum("text.txt",0);

If I then put the swf, mp3 and txt file in the same place in my course files, they open fine.  I posted these files some time ago on Moodle if you're interested.

Hope this helps

In reply to Chardelle Busch

Re: .swf file problem

by Chardelle Busch -
Picture of Core developers

By the way,

Strange thing--the X that appears in the above code (after Track1) isn't supposed to be there.  It appears the html editor justed added it for the heck of it.

In reply to Chardelle Busch

Re: .swf file problem

by Mike McKee -

Ok in my flash file I have:

var fieldnames_arr = [];
var loader = new LoadVars();

/*** load the file  ***/
loader.load("jeopardy.csv");

It works fine in a normal browser or running it from my computer.  The only place it does not work is in moodle because it never loads the csv file.  This is the same if I were to upload a html page with jpegs, etc.  Moodle can't find the files.

What do you have your slasharguments set to?

In reply to Mike McKee

Re: .swf file problem

by Jamie Pratt -
Hi,

I think the problem here is that the browser will look in the same folder as the html file for something it loads in from a relative address like this.

If you just specify the file name or something like images/jamie.jpg to load in a file then the browser through which the .swf requests the file looks for a file at the same address or in a location relative address to the address of the html file even though you are loading it from the swf. You wouldn't normally notice this perhaps as the html and swf are often in the same folder.

Here the fix might be to tell Flash the absolute file location eg.

This was something that had me confused for a while on a prohject I worked on.

Jamie
In reply to Mike McKee

Re: .swf file problem

by Jamie Pratt -
If you need to have MOodle tell your Flash movie were to find the file you want  to load instead of hardcoding the absolute URL in your Flash movie then you could pass the path name in in the FLASHVARS variable. You would put something like this in your embed and object tags :

FLASHVARS="filepath=<?php echo $CFG->moodleroot."/yourpath/filename.txt" ?php>"

Or something like that sorry, I've probably got the syntax and variable names completely wrong but I hope that might possibly help.

Ahh! This of course assumes you are editing the php for the page in which your movie will appear which probably you aren't!  It might not be helpful at all , sorry.

Jamie


In reply to Jamie Pratt

Re: .swf file problem

by Michael Penney -
If you want to use custom code to handle swf files, you can try putting this in filters.php.

In the filters forum is some code I set up a while back that allows different sized swf files, for an example.
In reply to Michael Penney

Re: .swf file problem

by Jamie Pratt -
Yes. You could use the Flashvars method to pass the Moodle root file path into all Flash movies by putting the appropriate code in the html used to embed Flash movies, movies that don't need it would ignore the variable.

If you use FLASHVARS = "variablename=value&variablename2=value2" in the HTML code to embed your Flash movie then variablename and variablename2 will be available as a (global?) variable in your actionscript.

To illustrate the problem I mentioned earlier of Flash finding its files if you don't use an absolute file path see this embedded flash file :

http://jamiep.org/tree/tree.swf

On this forum you will not see anything appear in the component because it is trying to load in some XML to initialise itself. IF you click on the link it works and some expanding folders appear in the component.

The problem is that when the swf is embedded in this forum when I do load "tree.xml" in action script the Flash file will look for tree.xml which it has to load in the same directory as the html page not the same directory as the .swf ie. it is looking for http://moodle.org/mod/forum/tree.xml while you are browsing this forum. If you however click on the link and load the .swf file directly into the browser or go to http://jamiep.org/tree/tree.html Then the browser will look for the file in the same directory as the file it has already loaded.

Jamie
In reply to Jamie Pratt

Re: .swf file problem

by Chardelle Busch -
Picture of Core developers

FYI Jamie,

I got a virus warning concerning your post:

Warning: This message has had one or more attachments removed

Warning: (msg-7973-54.html).

Warning: Please read the "VirusWarning.txt" attachment(s) for more information.

Using Moodle -> Forums -> General problems -> .swf file problem

In reply to Chardelle Busch

Re: .swf file problem

by Jamie Pratt -
Hi Chardelle,

That's very odd. You know the mail was not actually sent by me. It would be sent by the server and there was no attachement. As far as I understand there are no attachments in the mails that Moodle sends out, Moodle 'attachments' are actually links to the file on the server and not real email attachments that could be a virus. There could of course be a virus in an file that someone attaches but that would be detected if you downloaded the file and not when you check your emails.

I think this is your virus software being over protective. What does the "VirusWarning.txt" say?

Jamie
In reply to Jamie Pratt

Re: .swf file problem

by Chardelle Busch -
Picture of Core developers

Hi Jamie,

It is odd, I do not think it was any virus protection on my end (I use McAffee) and I do not know if this is a Moodle thing or not.  Here is the text:

This is a message from the MailScanner E-Mail Virus Protection Service
----------------------------------------------------------------------
The original e-mail message contained potentially dangerous content,
which has been removed for your safety.

The content is dangerous as it is often used to spread viruses or to gain
personal or confidential information from you, such as passwords or credit
card numbers.

Due to limitations placed on us by the Regulation of Investigatory Powers
Act 2000, we were unable to keep a copy of the original attachment.

The content filters found this:
   Found dangerous Object Codebase/Data tag in HTML message

--
Postmaster
Your Organisation Name Here
www.your-organisation.com

MailScanner thanks transtec Computers for their support

In reply to Chardelle Busch

Re: .swf file problem

by Michael Penney -

Hi Chardelle, it's sounds like it's neither from Moodle nor from Jamie, that is probably your ISP's email scanner reacting to the object tag used to embed flash.

Postmaster
Your Organisation Name Here
www.your-organisation.com

MailScanner thanks transtec Computers for their support

Your ISP apparently didn't finish filling out the form for the Mailscanner setupsmile>

My email client reacted to Jamie's message also, telling me that my privacy setting don't allow running active-x controls (which flash is a form of on Windows), though my U's email scanner didn't react to it.

Some spammers do use object code to tell them if you've seen the email and such, so they can tell just whether your address is valid, I suppose one could use flash for this by having a swf send a message every time it runs.

Object code might also link to a vb script or exe which might provide a gateway to a virus, though I don't think there is any way to spread a virus via flash at this time.

In reply to Michael Penney

Re: .swf file problem

by Chardelle Busch -
Picture of Core developers

Hi Michael,

I'm hoping to figure out where this came from.  Anybody working on security, Martin? Petr?, know about this?  Has MailScanner been integrated with Moodle?

At first I thought it was some sort of email spamming scam crap.  I'll ask my website host if it came from them--I don't think it has anything to do with my ISP which is MSN.  The subject line of the email begain with {Dangerous Content?} followed by the regular post subject line.  And the email was in text format, not html. 

In reply to Michael Penney

Re: .swf file problem

by Jamie Pratt -
The Flash movie I uploaded attempts to load in another file, the xml file, as I said, maybe this is triggering virus warnings??

I didn't think the code to embed the Flash movie would be sent out by email.

Jamie


In reply to Jamie Pratt

Re: .swf file problem

by Michael Penney -

I didn't think the code to embed the Flash movie would be sent out by email.

Yep, I got it (with a warning about running active-x from my mail client). It shows up (in Outlook Express on Win2k) with a box where the flash would be, but doesn't load the flash file.

Probably it would get converted to text by a mailserver set to block object-embed code (that is what mine does with files it thinks contain a virus, but it's not set to do that with simple object/embed code).

In reply to Mike McKee

Re: .swf file problem

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
You need to have slasharguments (<---click on it) set to use pure slash arguments (and not the ? method).