PDA

View Full Version : calling functions


elmimmo
03-08-2001, 10:56 AM
I am trying to launch quicktime, avi and mpg movies from flash and for this I use 2 techniques, one for windows users and another for mac users. For windows I call one of those programs that call the default executable for a certain document (the movie) that is passed as its arguments (one i'm using is shelexec.exe). For macs I call an applescript with the same name as the movie (without the extension) that calls the movie in question.

In the first place I manually define which system (win or mac) is the projector intended for with an action in the first frame stating:

var System = "mac";

And then in each button supposed to launch the movie I assign the following action:


on (release) {
if (System == "win") {
fscommand ("exec", "movies\\ShelExec.exe\tmovies\\movie01.mov");
} else {
fscommand ("exec", ":movies:movie01");
}
}

Except that I change the name of each movie to be launched. With this I define the variable "system", publish one of the projectors, and just by redefining it again and publishing the other projector I have both version with minimum hassle. I've tested this and it works.

Anyhow there are dozens of buttons launching movies so I tried to define the function to launch the movies just once and call it from every button like this: First I changed the action I defined in the first frame to:

var System = "mac";
function LaunchMovie (NameMovie, ExtensionMovie) {
if (System == "win") {
fscommand ("exec", "movies\\ShelExec.exe\tmovies\\" + NameMovie + "." + ExtensionMovie);
} else {
fscommand ("exec", ":movies:" + NameMovie);
}
}

and in each button I changed the action defined simply to:


on (release) {
LaunchMovie (movie01, mov);
}

I've tried this only on Mac OS for the moment (that's why the variable "System" is defined as "mac") but it does not work any more. Any help, pleeease?

elmimmo

axel
03-09-2001, 11:55 PM
problem in "adressing"

if you defined this function on main timeline and buttons are inside of a movie clip you should use:

on (release) {
_root.LaunchMovie (movie01, mov);
}

in buttons

dnalogic
03-10-2001, 04:32 AM
Maybe a stupid suggestion, but, have you tried putting the parameters in quotes? they are strings and not objects, afterall.


Old code:

on (release) {
LaunchMovie (movie01, mov);
}



New code:

on (release) {
LaunchMovie("movie01","mov");
}



Regards,
Dean Alexandrou.

elmimmo
03-12-2001, 08:53 AM
I tried with _root.LaunchMovie writing its parameters with and without quotes, but still no luck.

Maybe I should have pointed that those buttons I assign the action to are in a different scene (but same movie clip) than the first one (the 1st frame of which is where de function is declared).

axel
03-12-2001, 10:24 AM
working for me ;)

where did you defined this function? check it with debug/variables

//main timeline
var System = "mac";
function LaunchMovie (NameMovie, ExtensionMovie) {
trace("XXXXXXXXXXX"); // be sure it is called
if (System == "win") {
loadMovieNum("movies\\ShelExec.exe\tmovies\\" + NameMovie + "." + ExtensionMovie,2);
} else {
loadMovieNum(":movies:" + NameMovie,2);
}
}

//button inside movie clip
on (release) {
_root.LaunchMovie("movie01","mov");
}

elmimmo
03-12-2001, 11:57 AM
It works!! I do not really know what I was doing wrong. Probably a bunch of things, mistyping the movies, sometimes trying with projectors sometimes not (and only projectors can launch executables which is what I use)... whatever. THANKS A LOT!.

As my question probably revealed, I am neither programmer nor have touched ActionScript but the surface. This was the 1st time I used the debugger and I saw Flash itself has a predefined "$version" variable, the value of which when debugging in Mac OS is reported as "MAC 5,0,30,0" in my version of Flash. So I saw there is no need for a manual change in a custom "system" variable.

So, just two teenie weenie little question more. Could anyone provide me with the value of "$version" in a windows Flash Player (whatever its version number might be). And is there an operator which I can use in the "if" function which would mean
$version contains "MAC"
instead of
&version equals "MAC 5,0,30,0"
(so that the movie keeps working even if I upgrade Flash and publish it again)

Whether you can answer these also or not, THANKS A LOT again