In short, no script: in the Static Resource field, select your Media Source and select your file. Then at the beginning of the path this will put in the field, put [[$pathPrefix]], so it looks like this
[[$pathPrefix]]path/to/your/file.pdf
Now some thoughts on the subject:
If you're not comfortable remembering to put the chunk tags in the Static Resource field, you could use a plugin to check if the resource being processed is a modStaticResource, and if it is, fetch the path property from the JSON string in the "properties" field of your Media Source (modx_media_sources) and prepend it to the Static Resource path (its content) before doing anything else with it. I'd have to experiment a bit to figure out the best event to use for this.
If Static Resources properly worked with Media Sources, it would simply indicate what Media Source was selected, and when the resource is requested, if it's a modStaticResource it would get the path prefix from its Media Source's properties field. That way if the Media Source is edited, the changes will be incorporated in the final full path to the file. That's why it's not so easy; you can't just add the Media Source path to the Static Resource path and save it, because then you can't change the path to the files in the Media Source without editing every Static Resource. I think I'm beginning to see how a plugin could do this, though: add {myFiles} to the beginning of the path of all modStaticResource resources onBeforeDocSave, then on processing the request, if the resource requested is a modStaticResource replace the {myFiles} with the path property of the myFiles Media Source.
What we really need is another MODx tag, for Static Resource. Something like [[#MyFiles]], so you could use it wherever you wanted (including having MODx automatically add its path property to the Static Resource path) when you want to indicate the Media Source's properties (paths, URLs, etc). So something like [[#myFiles? &value=`path`]] would return the Media Source's path property. Hm... an output modifier, perhaps?
[ed. note: sottwell last edited this post 10 years, 8 months ago.]