Script Editor launched or not???

I am writing an Applescript which will export a movie in all the available options using QuickTime Player.

Here is a small piece of the code…

tell application “QuickTime Player”
set exportlist to {AVI, BMP, DV stream}
set countervariable to 1

repeat 3 times
   set movietype to item countervariable of exportlist
   can export movie moviename as movietype
   if result is true then
   export movie moviename to "Movie Export " & movietype & "" as movietype
   end if
  set countervariable to countervariable + 1
  set result to false
end repeat

end tell

I then saved the script as an application on the desktop. When I drop the application on top of script editor to launch, the script runs fine and names as exported movies as 'Movie Export AVI", “Movie Export BMP” etc… in the specified location.

However, if I double click on the QuickTime Export applescript application that I have created on the desktop and run it WITHOUT launching script editor, it names the movies as follows:
Movie Export «constant expkVfW », Movie Export «constant expkBMPf» etc…

Does anybody know what is happening here?

The reason you’re getting «constant expkVfW », etc. is because the ‘movietype’ is not a string, it’s an application constant.

There are two possible fixes. First you can try coercing the movietype to a string:

export movie moviename to "Movie Export " & (movietype as string) as movietype 

which may coerce «constant expkVfW » to “AVI”. If that doesn’t work you’ll need to make the substitution manually:

if movietype is avi then
	set suffix to "AVI"
else if movietype is BMP then
	set suffix to "BMP"
else if movietype is DVStream then
	set suffix to "DV Stream"
end if
export movie moviename to "Movie Export " & suffix as movietype