What for?
Have you ever received a layout with flash-elements that should be links to external or internal resources, but in reality they are not? At the same time, when you are not a flash developer and there is no Flash IDE at hand (or even the operating system in which you work, this Flash IDE does not support this) - this becomes a small difficulty. You can, of course, kick the coder so that he corrects everything, but it takes time, which means money. Besides, kicking it every time the URL changes is not the best idea.
Swftools come to the rescue
')
On
the developer's site, you can find out that this is a set of console utilities for working with .swf files. These utilities are good and different (for example, the ActionScript compiler does not know how to compile Box2D, that is, not everyone understands ActionScript syntax), but they will cope with our task.
Utilities, by the way, are able to:
- convert swf to pdf (PDF2SWF)
- pull content from SWF movies (SWFDump, SWFStrings, SWFBBox, SWFExtract)
- convert to swf some image / audio / video file formats (JPEG2SWF, PNG2SWF, GIF2SWF, WAV2SWF, AVI2SWF)
- import TTF, Type1 (Font2SWF) fonts to swf-movie
- compile ActionScript3 code with certain restrictions
Good, and links in banners how to do?
Here we will be helped by another console program from the swftools kit called swfc. It allows you to collect flash-videos based on the description of their special markup language.
Suppose we have a banner of 980 by 136 pixels in the banner.swf file and we want it to be displayed on the main page of the browser when it is displayed in the browser on our website.
Create a text file movie.sc with the following markup:
# the name of the file with the roller, its size and playback speed
.flash filename = "banner_with_link.swf" bbox = 980x136 fps = 12
# our banner
.swf banner "banner.swf"
.put banner
# over it is a transparent rectangle
.box rect width = 980 height = 136 color = red fill = # FFFFFF00 line = 0
# collect a rectangle in the essence of the "button"
.button mybutton
.show rect as = shape
# click on the button to go to the specified link
.on_press:
getURL ('http://habrahabr.ru/', '_top');
.end
.end
.put mybutton
.end
It remains to compile the swf movie from this file using the swfc utility:
swfc movie.sc
As a result of the build, we will get a banner_with_link.swf file in the same directory with the functionality we need.
So what?
Actually, the task is completed, but this can not stop. After all, the assembly does not have to happen on your machine - it is enough to install this utility on the server and banners can be collected dynamically. With proper caching, this has virtually no effect on performance. In the References section on the developer’s site there are examples of projects working on this technology. And after studying the materials of the
wiki documentation and open source project you will have many other great ideas on its use. Dare, and forget to write about it on the habr!