This post is a translation of a previous one, written in French. It has been read many times, even by non french speaking person, that’s why I decided to translate it into English.
In order to compile Alfresco WebPreviewer (the component used to display documents inline), you will need:
- WebPreviewer sources : you can find them in Alfresco SDK (alfresco-share-src.zip in as folder),
- Flex SDK version 3.6;
- a Flex IDE, FlashDevelop is my choice.
For those that do not like IDEs and that rather use command line, you could jump to the end of this post.
1st step: FalshDevelop project creation
Launch Project > New Project… and choose AS3 Project as shown:
Choose a name and a location to store your project. You should get something like:
Then you can import WebPreviewer sources. My simplest method is to copy files in src folder from Alfresco sources to the project src folder, using file explorer. FlashDevelop will refresh the project tree automatically.
Main.as file is a template file created by FlashDevelop and can be deleted.
To finish this first step, choose WebPreviewer.mxml as project main class:
2nd step: first compilation attempt
Ok, step title is too explicit: you know it won’t work
But will learn what needs to be changed in order the compilation works.
Launch Project > Build Project, 6 errors are shown:
All of these errors are due to images access path: sources uses relative paths but compiler needs abstract ones.
3rd step: sources corrections
Change « assets/cursor-hand.png » (for example) to « /assets/cursor-hand.png ». You can use search and replace function.
4th step: launch compilation a new time
You know how to do it ! And if you try it now, it will work without error.
But we can do better than only compiling WebPreviewer, we can optimize it! To do this, you should change the compiling mode from Debug to Release:
Compiling in « Release » mode will create a much smaller file than in Debug mode… and standard WebPreviewer is compiled in Debug mode.
5th step: installing our new file
Our brand new and optimized WebPreviewer is available in bin project folder. Just copy it in Share webapp (or include it in an AMP file), free your browser cache, and that’s all!
For command line enthusiats, here are the steps:
- correct source code in order to set abstract path for assets (cf. 3rd step)
- launch <flex sdk home>\bin\mxmlc.exe -optimize WebPreviewer.mxml
You can now script WebPreviewer compilation in batch or ant files.