Groups | Blog | Home
all groups > flash actionscript > june 2006 >

flash actionscript : Accessing JSFL from a SWF


caskater
6/22/2006 10:52:58 PM
I'm trying to create a little app where I can execute methods i've written in a
JSFL file from my SWF. All the documentation says this is possible but only
refers to it when the SWF is loaded externally into some type of HTML or other
container where the JavaScript would be automatically present. What i'm trying
to do is get at JavaScript that would be held in a *.jsfl file and not linked
by the SWFs container. I do not see any way in the docs to be able to identify
a specific file to load in order to execute the JavaScript. Does anyone know
how to accomplish this? Thanks in advance.
NSurveyor
6/23/2006 12:23:42 AM
I don't get what you are trying to do. JSFL is for the authoring environment,
e.g. making it easier to do something within Flash. If you make your SWF a
Flash panel (a panel in the authoring environment), you can call jsfl files
with something like:

MMExecute("fl.runScript(\"makeEverythingBlue.jsfl\");");

But note, ALL OF THIS is happening within Flash.
caskater
6/23/2006 12:48:46 AM
Yea thats what I am working on .... a flash panel. Its having a problem running
though. It doesn't seem to like a relative path name, it wants a full path name
such as file://C|/...../myfile.jsfl which isnt very helpful since the location
will vary depending on installation and platform. Also, does this return
values... part of me needing to execute through the JSFL is to get stuff back,
how can I get return information into the SWF?
NSurveyor
6/23/2006 3:09:48 AM
OK, just making sure...

Ok so, I think you could use _url property to make an absolute path based on
the current swf... Also, instead of just calling the JSFL file, call a specific
function within the JSFL file that returns a value, and you can pass arguments
if you like. Note, this value will be a string:

var path = _url.split("/").slice(0,-1).join("/")+"/makeEverythingBlue.jsfl"
var jsfl = 'fl.runScript("'+path+'","functionInTheFile","arg1",2,"arg3!!");'
MMExecute("success = "+jsfl);
trace(success);

I haven't tested the above, but it looks awright to me.
AddThis Social Bookmark Button