How to add Preloader to Monkey - Plz add this MarkMonkey Programming Forums/Flash/How to add Preloader to Monkey - Plz add this Mark
| First we need to alter trans, open up src\trans\targets\flash.monkey.|
Alter the Execute command (around line 72) so it looks like this:
Execute "mxmlc -static-link-runtime-shared-libraries=true -frame=MonkeyGame,MonkeyGame Preloader.as"
And the FLASH_PLAYER execute (76):
Execute FLASH_PLAYER+" ~q"+RealPath( "Preloader.swf" )+"~q",False
Compile trans, then move the exe to the bin folder.
Now go into the folder targets\flash and create the Preloader.as:
Alter the MonkeyGame.html embed line to look like this:
<embed src="Preloader.swf" type="application/x-shockwave-flash" width="640" height="480" wmode="direct">
Alter MonkeyGame.as, add the following line after [SWF(width="640",height="480")]:
Then compile your game... hopefully you will have a loading bar. Play around with the Preloader.as.
| In safari the loading bar goes off the right side, any way of scaling it to the resolution of the window? |
| the loading bar goes off the right side cos its being drawn at xcoord 100 and its 600 pixels wide. So its an easy fix.|
Good work Mr revills
| Very nice that you have figured this out. |
| Yeah the loading bar was quickly added ;)|
I think I can streamline the process, by making mxmlc output the swf as MonkeyGame.swf, there is an "output" parameter.
So I guess we could do something like this in trans:
Execute "mxmlc -static-link-runtime-shared-libraries=true -frame=MonkeyGame,MonkeyGame -output=MonkeyGame Preloader.as"
This should create a MonkeyGame.swf, so you dont have to alter the FLASH_PLAYER execute line or the MonkeyGame.html file.
| Just tested the above and I was wrong, it needed to be this:|
Execute "mxmlc -static-link-runtime-shared-libraries=true -frame=MonkeyGame,MonkeyGame -output=MonkeyGame.swf Preloader.as"
And I've moved the loading bar back a tad:
| Thanks! Since I don't have a clue about ActionScript you pretty much saved my life. |
| I had some trouble using this preloader after uploading to Kongregate. It worked fine in the latest IE and Chrome but lots of IE8 users complained that the intitial load worked fine, but after that they only saw white screen when they refreshed the page or restarted IE and went to the game page.|
After endless head-banging I tried swapping the preloader.as code for the code here:
I think all is good again. :)
| Hey Siread, what final preloader did you use? (As on that web page, there are a few pages with code on there?) |
| Ah sorry, I just used the one in the first post. I haven't tried the others. :) |
| No worries, so its this code:|
(Just to place it here on this forum)
| I did a little more work on my pre-loader, incorporating a background image and a third-party intro using FlashDevelop. You can see how in this thread...|
| did this ever get added? |
| Altering trans isnt a big deal. See the whole monkey package as an overall for your next game.. so you might have modified files for your target game such trans or the target directory template.. this is why i love monkey as it is extensible in many ways. I even think i could make an application to configure this and lets you use many instance of trans source in one click.. that would help. |
| Just saying thanks for this. Makes my LD48 flash games seem a bit less shabby now! |
| Wouldn't it better if Monkey was set up to always use a dummy pre-loader? That way we wouldn't have to alter Monkey core files. |
| Yeah I would agree with that. I can't really imagine a scenario where when using flash you wouldn't want one. |
| +1 to dummy pre-loader|
HEY, HOW ABOUT THIS???
Make the dummy pre-loader an upsell to Monkey (Made With Monkey!).
Then we change it if we want to, no obligation to keep it that way, but on one hand it's more user friendly and the other it helps market Monkey.
We have used the pre-loader in this thread so also thank You <3