You can embed non-code assets in your swf, and access them from your code.
This is usually images, but it can also be text files.

http://stackoverflow.com/questions/2141276/flex3-load-contents-of-an-embedded-text-file-into-a-variable

Maurice 

-----Message d'origine-----
De : Barry Gold [mailto:[email protected]] 
Envoyé : lundi 24 février 2014 07:16
À : [email protected]
Objet : Re: Including/referencing an external MXML file

On 2/23/2014 9:40 PM, Alex Harui wrote:
> 1.  If the mx:Text file is named BarryScript.mxml, then in the main 
> MXML file, you would include a namespace like xmlns:local="*" and then 
> somewhere, add the tag<local:BarryScript id="theScript"/> 2.  Then your code 
> would access theScript.text.

Is that a "global" variable?  I would expect it to be an instance variable in 
my application class.  Then I would tell the Parser class where to find it, by 
calling a setter function, right?

> But really, it isn't obvious why you aren't just including the script as a 
> String unless you want to display that script to the user.

IIUC, ActionScript does not allow multi-line quoted strings.  So I would have 
to wrap each line in quote marks and concatenate them (with the + operator, I 
guess).

This way, the entire text -- including newlines separating the lines (I'm using 
a partly line-oriented parser) is in the control and I can go ahead and parse 
it.

> Also, you may want to load the script externally so you can change it without 
> having to recompile the app.

I suppose I might do that, but then I have to make a package (install
script?) that deploys the script, too.  If it's compiled in, all I have to do 
is hand out the .swf file.

And other people who want to use my game layout and engine can just change the 
script and recompile to make a different game.  (I'd be making the whole thing 
available under CC-BY-SA.)

Reply via email to