Today, I decided to add a preloader to an ARP based application that I have been working on. I decided to use an external preloader to avoid the problems that others seem to be having with V2 components when they are not loaded in frame 1 (such as column headers not showing up in datagrids).
I modifed the preloader kindly provided at FlashGuru - basically I took out the first layer “fix onLoad/onData” as it stopped the onLoad function working in my main application. I also modifed the progress bar slightly. My modified version of the preloader is available for download.
As I was already using the Flash Javascript Integration Kit I needed to modify the FlashTag which loaded my application (fis.swf) from
var ft = new FlashTag('fis.swf', '600', '330', '7,0,14,0');
to
var ft = new FlashTag('loader.swf?movie=fis.swf', '600', '330', '7,0,14,0');
All seemed well until I navigated to a page in my application which had a combo box - it would not drop down. I fixed this by adding
this._lockroot = true;
to the constructor of my application view (which is the first code that is run in my ARP based application).
This fixed the problem with the combo box but now my FlashVars were not loading and the Javascript integration was not working. I managed to fix this final problem by modifying the JavaScriptProxy call from
proxy = new JavaScriptProxy(_root.lcId, this);
to
proxy = new JavaScriptProxy(_level0.lcId, this);
Basically, locking the root meant that we couldn’t reach the flash vars through _root anymore but using _level0 still works. In a similar vein, the code which tested for variables being present at initialisation needed to change from
transactionId = parseInt(_root.transactionId);
to
transactionId = parseInt(_level0.transactionId);
Finally, I have a basic (but reasonable looking) loader and the application works as it should.