Printing Locally Stored Photos in Adobe Flex/Air - actionscript-3

In my Adobe Flex/Air application I have an ArrayCollection storing a list of details (including the file path) for locally stored photographs.
What would be the best way to print all these photos from within the application?

The solution consists of two steps:
Load images. It can be done by using Loader. It can load images by local path or URL.
Print images. Flex have appropriate class for printing - FlexPrintJob. It can print any UIComponent (Bitmap too).
I did not write all the code, but there are examples in the documentation and there is not any magic =). But if you have question feel free to ask.

Related

Beginning with D3.js and parallel coordinates

I would like to use the parallel coordinate toolkit from syntagmatic.github.io/parallel-coordinates/#.
As I am new to the D3.js framework, I am encountering some trouble to begin and visualize data locally.
What I am trying to achieve is to use one of the standalone HTML examples (e.g. brushing.html) and edit the data table with my own data.
I stored locally (in a Windows folder):
the brushing.html example file
the cars.csv file
the D3.js library files from d3js.org (d3.min.js and d3.js)
When I load the HTML file in my browser, only the text displays, not the parallel coordinates themselves.
What am I missing/doing wrong? Should I be able to display locally the same result as what appears in brushing.html?
I checked out several tutorials for D3.js, but they generaly skip these preliminary requirements step. Thanks for any feedback.
Thanks to the straightforward comment to my question, I was able to identify the issues checking the browser's console.
It mainly came down to redefining paths to the different files, and eventually downloading the missing packages from the corresponding Github page https://github.com/syntagmatic/parallel-coordinates
I can now test the tool locally with custom data.

Is it necessary to import actionscript files through timeline actions?

It seems as though every actionscript file (not custom ones) is automatically included when coding in the timeline's actions, so I'm wondering if it's necessary to import the files through the code. Are there any advantages? Can I prevent flash from importing every file to reduce the size of my flash application (SWF)?.
For example, I don't need to import MovieClip to use the MovieClip class in timeline actions.
You can indeed load external assets, that is, anything of SWF, MP3, WAV, JPG or any byte sequence you have a decoder for, then parse it via code, then use in your Flash app. The advantages are flexibility, for example, if a user has all sounds turned off, you are free to not load large music for him thus saving him some traffic - this might be crucial for some people out there. There are also disadvantages, because the files (assets) in SWF are available from the start of your app, and because the connection can get lost at any moment, you might not receive your external files in time for the app to use, or not receive them at all.
Not importing in order to reduce the SWF size? I'd say reduce the size or quality of those assets instead. The actual mess with Loaders is something you should avoid unless you have dynamic downloadable content (some extra levels' metadata maybe) which you plan to generate on a timely basis in order to attract longer attention to your app.
In short, all static content is better embedded, all dynamic content should be loaded afterwards.
Compiling FLA file doesn't embed every AS file in the resulting SWF. My test directory structure.
Work Directory
file.fla
ClassA.as
ClassB.as
The code on my timeline.
var a:ClassA = new ClassA();
The resulting SWF only contain the ClassA.
For multiple SWF files with code, every SWF embed the class. It's your job to tell the compiler.
If you are using FLEXSDK, you can look to these parameters.
-link-report file.xml : Generate a file containing all AS file include at compilation.
-load-externs file.xml : Exclude all class containt in the file.
If you are using Adobe Flash exclude class article

Some way to change text of SWF without having Flash?

I have a FLA with some text but the person that will be sending the SWF doesn't have Flash and doesn't know anything about Flash either.
Is there some way to build the FLA so that the text can be changed simply by modifying the SWF somehow? Due to company policy, the SWF cannot read from external files.
We tried programming into the FLA that it read an XML in another server, but that's not allowed. I also cannot send the SWF with another file (ie. an xml file).
Thanks.
Use FLASM or SWFMILL which are free command line assembler/disassembler for swf files. Use any of the one to disassemble your swf. You can open the result file in any of the text editor, find and replace your text and assemble it as swf again. Hope it helps.
It is a strange logic to try to modify a FLA file without Flash. A FLA file is a binary file, you'll need an editor to read it and I'm pretty sure Adobe isn't allowing 3rd party editors legally.
But yes, it's fine to have a dynamic TextField where you can send the parameter and change the data. Please note - you need to send the data. Means it has to come from outside.
What are the options? Well, actually, there are few:
Loading from an external file or getting it from a server side script. You said it's not allowed, let's omit this method.
Read FlashVars. If you publish it within a HTML page, you can actually feed some data via FlashVars. Not only 1 variable, but as many as you want. And it's fine for small strings, but if you plan to pass a text larger than a sentence… Don't do it.
As a funny hack you could try naming your file with the text you want and read the URL of the SWF thus showing it's name and using it as a text data. But don't do it :)^
If you want to try it, you can access the URL with stage.loaderInfo.url, just make sure you have a stage defined - call in the document class or after the display object you're calling from is added to stage.
Use ExternalInterface to communicate with, for example, JavaScript and get the variables from JavaScript. It's actually not so bad, since your text will be tidily stored in a .js file and you can modify it on the run. That of course is a separate file and you need to have the SWF embedded in HTML for that, but it is one of the options you have.
Other than that you could have an external file that will hold the data and embed it in the SWF. Look more on embedding here: http://flashgamedojo.com/wiki/index.php?title=Embedding_XML_in_AS3 . It is about embedding XML data, but you can use the technique for any data, even binary.
Embedding data is a great thing, but you'll need to re-compile each time you make a change in the file, since it isn't loading the file dynamically, but embeds it into to the SWF itself on compile time.
Hope that helps!
JPEXS Decompiler can change text in an SWF pretty easily. It's still actively developed as of 2021.

Actionscript 3.0(Adobe Flash CS4) Loading external .as files without knowing name of .as file

I want to know how to load external class files(.as files) in actionscript but don't have to know the class file's name. Think of it like loading mods in minecraft with forge mod loader, it doesn't know the main class of the mod's file name, yet it successfully loads the mod. I want to know if something like this is possible in actionscript 3.0 because I feel like making a tower defense game that isn't like the others out there but have it so it can be modded and have mods loaded but of course I have to load the class file without knowing the class file's name.
Note: I don't got access to Adobe Air so I can't use anything that requires Adobe Air.
You want to load a particular .as file AFTER or BEFORE compilation? After the compilation it is hardly possible - the file would not be compiled and therefore it would be useless. Why don't you use a swf or some kind of XML/JSON with settings in that case? Before the compilation you would still need to identify it by it's package name/name.
Basically, you want a plugin management system.
In AS3, it is not possible to "load" a .as file on execution, because it is a (uncompiled) source file. But, it is possible to load another swf and to use the classes within it.
Your process should probably be something like this :
Get a list of the plugins/addons. If you were using AIR, it would have been possible by browsing the content of a folder. Since you're not, you'll probably need to use a listing file (basically, a file that say "Here's the list&path of the plugins you need to load".
Load each swf file
(possibly) call a initialization method for each plugin.
You may wish to look into the way OSMF manages plugins, for example : http://osmf.org/dev/osmf/OtherPDFs/osmf_plugin_dev_guide.pdf

Saving several images (and metadata for each) in a single file using Adobe Air

Is it possible, via Adobe Air, to save multiple types of data in a single file? For example, an application would allow the user to load in external images, position them on stage and label them. This data would be then be stored in a ByteArray (I guess) using BitmapData for the images and probably XML for the metadata.
I would then like to write this to a single file, with a bespoke file extension that could be associated with said Air app.
I've asked this on various forums and never received a single reply.
You can add everything to a byte array and write it to file - but defining boundaries and extracting individual entities back from the file would take some effort. How about writing them to normal files, zipping them to a single file and deleting the originals? This way you can still have a single file and deal with the individual items more easily.
This article describes some ActionScript zip libraries. I've used nochump in the past and it was easy - this page has some sample code
If you want some individuality for your files, you can rename the zipped file to whatever extension you want - that's what Firefox extensions do, they have .xpi extension, but they're plain zip files renamed.