32272

Actionscript 3, read file text at compile time?

Question:

There is some way to make the flash put the content of one text file in a string, or at least put it in the .swf, so the user don't need to download it?

Answer1:

Solution:

[Embed(source = "ExampleText.txt", mimeType = "application/octet-stream")] protected var pscene:Class; var tmp:ByteArray = new pscene(); result = tmp.readMultiByte(tmp.bytesAvailable, tmp.endian);

It took me a while to understand how to read the data from the Byte Array.

Answer2:

I've always used a pre-compile step to populate a template. It's pretty easy to make a class that has a string to be populated before compilation.

Ant can do this pretty easily. Check out the <a href="http://ant.apache.org/manual/Tasks/replace.html" rel="nofollow">replace task</a>.

Recommend

  • Indexing documents using Solr results in Expected mime type application/octet-stream but got text/ht
  • Missing Content-Length header when using Nginx + Gzip + Unicorn
  • SWIG get returntype from String as String array in java
  • Youtube v3 api 401 Unauthorized
  • How to send a file AND other POST data with Synapse
  • Object de-serializing from base64 in C#
  • (Python 3) How to pass binary file as text without saving first
  • Android NFC: can we use intent filter with mime type? (android 2.3.3)
  • Can't upload base64 image using cordova-plugin-file-transfer
  • SonataMediaBundle: The file “” does not exist 500 Internal Server Error - FileNotFoundException
  • Passing parameter through “window.location.href”
  • ASP.NET RegularExpressionValidator, validate on a non-match?
  • Replace Fragment with another on back button
  • Unzip archive in .Net CORE 1.0
  • Adding Parent and Child Nodes in TreeView from Sql Server 2008
  • How to upload specific List image using click on Upload button
  • Streaming screenshots over WebRTC as a video stream from iOS
  • Blackberry 6: how to detect a long click on track pad?
  • unable to get jsonEncode in magento2
  • Authentication failed with Azure Active Directory in Windows Phone
  • How to get listview position?
  • pip in virtualenv gets ConnectTimeoutError
  • Autofac with Web API 2 - Parameter-less constructor error
  • Laravel: Getting Session ID oddly truncates when using foreach
  • Bypass multiple inheritance in Java
  • Run multiple queries from 1 SQL file showing result in multiple tables
  • Installed module is empty
  • Play WS (2.2.1): post/put large request
  • Bad request using file_get_contents for PUT request in PHP
  • Paperclip, set path outside of rails root folder
  • Recording logins for password protected directories
  • how to do an event when i swipe from fragment to the other
  • C# - Serializing and deserializing static member
  • Sending data from AppleScript to FileMaker records
  • Shallow update not allowed (git > 1.9)
  • How to include full .NET prerequisite for Wix Burn installer
  • Is it possible to post an object from jquery to bottle.py?
  • unknown Exception android
  • Observable and ngFor in Angular 2
  • Unable to use reactive element in my shiny app