How to combine an external preloader with actual SWF file? - actionscript-3

I have an external preloader that loads my swf file. How can I combine these two to upload them on the internet? I cannot add the preloader in the first frame of my original swf and move the layers to the second layer as this tampers with my file.

You should have the preloader as a different file so do not try to combine them. Just upload both of the files to the webserver and to your html file include only the preloader.swf. Make sure that your preloader is calling the correct file in its Loader.load() method.

Related

How can I load library assets from a separate project at runtime?

I'd like to set up a project so that there are two HTML5 createjs projects, with one loading assets from the other at runtime.
This is so that I can have part of my project that's shared across lots of files, and can be updated separately.
Ideally, I'd load these from a separate source, like how swf files can load assets from other swf files. Still within the same domain.
How can I set that up with createjs? I know I can easily load bitmaps and text files like you'd load any file in javascript, but I'd like to load vector graphics created using Animate and be able to render them on the stage.
The HTML5 exports are the resulting js files, along with some other additional assets, like images or sounds. Therefore, all you need to do is export both .fla files and load both of the resulting js files in the HTML document at the same time.
<script src="js/export.js"></script>
<script src="js/export2.js"></script>
After all that is loaded, you will be able to use vector graphics from both files, as long as they are properly referenced.

Embed jpeg into SWF at compile (without fla file)

Users upload images and select a template AS3 file, which would be used together with the images to compile into a SWF and be downloaded by the user.
Basically, use my own custom animations with the user's resource files in order to compile a new SWF at run-time.
I found a tool called "swftools", which can convert images into a slideshow, so I know something like this is partly feasible, I just don't know enough about AS3 to know how to load resources dynamically, without creating a FLA file manually.
EDIT: To clarify, I do not want to dynamically load an image from a URL or file at run-time. I want to embed the image into the SWF, but the image data is decided at compile-time.
Same problem here, and I found some great tuts that show how it's done, but (unfortunately) in AS2 (not AS3):
loading images
The code to convert:
loadMovie("photo.jpeg",photo.empty);
loading text
The code to convert:
myData = new LoadVars();
myData.onLoad = function () {
myText_txt.text = this.myVariable;
};
myData.load("myText1.txt");
AS2 to AS3 is very poorly documented, even for small scripts…
If you have a solution I'd like to know it ;-)
Use Flex and compc compiler.
http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7fd2.html
You can modify as3 sources on server and embed your images with [Embed(source='path/file.ext')] directive, run compc and get final swf...

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.

I have a .swf file in my website

I have a .swf file inside a website I've been asked to modify. Will this file contain normal html files and if so how do I get to them, there are no .fla file on the machine that created the site.
Thanks
Ross
.swf file is a flash element which is "playable" by your flash player. .swf is normally created used action script. In other words, the .swf file is the compiled version of the .fla file, and you can therefore not edit the .swf file.
Although Roskvist is completely right, there IS a way to convert .swf files back to actionscript code (and possibly .fla). This won't get you the original source code, but an 'estimated' code (with different variable names etc) that would give you pretty much the same .swf upon rendering. This can be done by software called a 'flash decompiler'.
A word of warning though: It's not okay to use this for stealing flash code from others' flash creations, you must have the rights to use any source code.

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.