tags:

views:

121

answers:

2

I've been trying to build my own (small) framework in JavaScript for an AIR application and I've run into a peculiar problem: I can't find a way for a JavaScript file to load another. It seems the only way to load JavaScript is for an HTML file to load it.

Is this correct? Is there really no way for a JavaScript file to load another?

+1  A: 

Have you tried creating a script element, setting the src attribute, and adding it to the document body? I don't think the usual document.write() trickery works but I'm pretty sure adding a script element should.

(I believe all paths are relative to the root of the Air application itself.)

Maciek
Haven't tried that one. Seems very roundabout, though. (I was actually looking for an @import statement or something.)
staticsan
+1  A: 

The security restrictions in Application Sandbox mode do not allow instantiating any new JavaScript code after the load event (during that event you can still load and evaluate JS).

As for the loading data, you should be able to use XHR to retrieve any text data you want at any moment of time without any restrictions.

Sergey Ilinsky

related questions