Embedding n (more than one) .txt files in Flex application - actionscript-3

I have to embed .txt files in my Flex application. My application has some examples(whose count can be increased later). For each example, I have to embed a different txt file. I know how to use the Embed tag but it requires the use of n Class variables for n txt files I will embed. Is there any way around to achieve this in a more optimal manner?

I think there's none, as each embed is treated as something separate. You can, however, merge all your text files into a single XML/JSON file as strings, and embed only that file with its class, create one instance and parse it for text file pieces.

Related

Best way to include/embed PDF images in slidify presentation (R Markdown)

I'm preparing a presentation in .Rmd (R markdown) file using slidify.
I have some vector graphics saved as PDF files that I would like to render on particular slides.
I've tried methods that I used in raw .Rmd (markdown syntax) as well as those from bookdown. However, none of them works.
As I can see in generated HTML, PDF file location is directly provided in img src and as I understand HTML files do not directly support PDF files.
However, I'm not sure what to do (what is the best approach):
convert PDF (to .svg) and use it in .Rmd?
try to write some raw HTML in my .Rmd fo;e using suggestion from Recommended way to embed PDF in HTML? that will allow me to render PDF,
use different command to embed PDF in presentation (something specific to slidify)?

How to convert an HTML file with content folder to a self-contained HTML file?

How do I convert an HTML file with content folder to a self-contained HTML file which can be viewed from anywhere with its images etc.
How can it be done so that it's also editable and stays self-contained, post-edit?
I basically need to make HTML file based documentation which can be viewed from anywhere. Unfortunately it HAS to be HTML, otherwise I would have made PDFs
You can use pandoc, it has an option to create self-contained html files https://pandoc.org/MANUAL.html#option--self-contained.
If you start with html, this is the command.
pandoc in.html --self-contained -o out.html
This tool can do a lot more things, for example, you can also generate html from markdown files or generate pdfs instead.
The most direct way is to convert all asset urls to data: urls. (There are online coverters available that will take a provided asset and produce a data: url from it.)
A possibly simpler way is to convert image and font urls to data: urls while instead inlining scripts and css.
Edit: Possibly of interest: inliner, a Node utility for doing this kind of thing. "Turns your web page to a single HTML file with everything inlined". Also performs a number of minifying optimizations.
I don't know exactly what you're envisioning, but HTML was never meant to be fully self-contained. There may be some loopholes that allow it in the end, but to my knowledge there are no premade tools that do this 'conversion'.
It would require the following things:
Converting all linked style sheets and scripts to inline style sheets and scripts. This means that whenever there's a <script src="http://url.to/foo.js"></script> you'll have to download foo.js and include it as such: <script type="text/javascript"> [this is the content of foo.js] </script>. Something similar applies to CSS and other linked source files.
Downloading all linked media (images mostly, I presume) and converting them to blobs (a service that provides you with a base64 blob you can use within a HTML file is https://www.base64-image.de/). This means replacing <img src="http://url.to/image.jpg" /> with <img src="data:image/png;base64,[converted image data goes here] />.
So there's gonna be some manual labour involved there, but it probably can be done (almost) fully.
Possibly there's a way to accomplish what you're wanting to do another way though, what exactly is your reason for wanting this?
Here's another option: write your documentation in markup, then use a tool such as "Marked 2" (http://marked2app.com) to convert to self-contained html. Works slick. Plus you can go back and edit the markup any time you need to update your documentation, then simply re-export your html file.

Convert gnome-help (yelp) xml to static html with xslt

Some of the gnome applications on linux use a help browser called yelp. For example, the gnome-calculator, gcalctool, has its help files located in /usr/share/gnome/help/gcalctool
The folders there are then sorted by language. These help files essentially consist of an xml file and some accompanying png figures.
What I'm trying to do is convert this xml and its accompanying png figures into static HTML because I want to be able to properly view and navigate the document from a different browser (firefox). If you want to see what I'm talking about and you are on Linux, just run gcalctool and open the help menu.
Unfortunately, opening the xml directly with firefox is not successful because there are no stylesheets and thus firefox doesn't know how to format it. I have read that gnome applications make use of a library called libxslt (http://xmlsoft.org/libxslt/) for applying stylesheets. I am not familiar with xslt at all. Are the stylesheets saved elsewhere, or embedded in the source when it is compiled?
I guess what I'm wondering is if it's possible to somehow use libxslt by itself or another tool to convert the xml and figures into static HTML, preferably in the same manner yelp does this when it executes, or in a manner that results in an exact/very similar output to what yelp displays.
Thanks
gcalctool uses docbook. Yelp brings everything to display this xml format. You will find some projects to convert this docbook document to html on http://wiki.docbook.org/DocBookToXhtml.
best regards
Majo
Depending on how old your gcalctool is, its help files might be in DocBook or Mallard. If it's Mallard, you'll see a bunch of .page files. Otherwise, it's DocBook. Either way, you can use yelp-build to create HTML files. It's part of the yelp-tools package, and uses the same transformations as Yelp. For DocBook, pass the top-level XML file:
yelp-build html -o /path/for/output/ /path/to/gcalctool.xml
For Mallard, pass the directory containing the .page files:
yelp-build html -o /path/for/output/ /path/to/gcalctool/
yelp-build will build the HTML, copy the images and other media files, and take care of the CSS and JavaScript.

Web application that compiles to swf

I have a swf template that can be used with different data input such as colors, texts etc. however i don't want to use the ordinary way of binding data to it such as xml. I would like the application to be able to produce a compiled swf with all the data in it.
Is it possible to inject the data in the compilation time?
Thanks
it should be, but depends on how much you want to mess around with the code of the template.
You can embed resources in flash, so you can just embed the XML with the information you want.
Then all you need to do if find the place in the code where it loads the XML file, and give it your own embedded XML file instead.
Yes it is possible, but only if you have access to the the source .fla file, so that you can generate a new .swf file from it.
If you simply want to change a few colors or other looks of some of the objects in the .fla file you should be able to do that without having to mess with xml, simply open the library items in Flash and edit their colors.
If you want to put your external assets within the actual .swf you can do that too, but if you already have it to pull external assets I would recommend keeping it that way.
For the XML, in ActionScirpt you can actually declare the XML within the actual Actionscript code. Open up the XML file and copy the the XML contents over to your code where it is parsing it.
For images you can simply drag image files directly on the stage or into the library.

How to automatically include a number of images in the SWF file?

i'm trying to include a number of images in my SWF file not by loading them but by embedding them in the SWF itself. I found the following instruction to do that:
[Embed(source="../graphics/images/ss0.png")]
private var SS0:Class;
Basically, i want to embed a different number of images each time. Is there a way to do that automatically (let's say inside a for loop) or do i have to type manually this instruction for each image i want to include?
You could store all your PNG files in a single ZIP file, then use the FZip class to extract them. See the example of this on their site.