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
| I don't suppose the dummy preloader ever got added and I just missed it?|
Trying to create a web version of my latest game and all is well except for the fact it's got no preloader bar.
I've attempted to incorporate the one above. This is what I've done:
1. changed flash.monkey to incorporate the updated line 72 therevills mentioned.
2. compiled Trans (scary stuff!)
3. created Preloader.as
4. updated MonkeyGame.as
It all compiles but I run into a couple of difficulties:
1. no preloader bar! Just a white screen (when I load from a site. If I run locally it just loads the game as normal).
2. it changes the res of my game (I'm going for 800x600) and makes it look as if image filtering is turned off (it runs fast enough with it turned on).
I suspect I'm just being a dumbo. Any clues anyone?
| Diddy needs a loading bar /me looks at them...|
I don't think this works with the current version of monkey, might be wrong tho, I know I tried it a little while ago and couldn't get it working either.
| Ah phew, that makes me feel better! At least I wasn't doing anything silly then.|
Can't see why this isn't already included as part of Monkey. I mean, when would you ever not want a loading bar of some description in Flash?
| Agh, could really do with a preloader soon. |
I've got some contract work involving making flash stuff and without the preloader it's going to look a bit shoddy :(
Unless anyone knows the answer to getting this preloader working?
| Okay using v72b:|
1. Create Preloader.as
Create the file "Preloader.as" in the \targets\flash\template\ folder:
2. Alter MonkeyGame.as
Add the following line after [SWF(width="640",height="480")]:
3. Compile your app
Ensure that you have deleted the old build folder from your app to get the preloader files.
Tested in FireFox and Chrome.
| therevills, I always said you was a genius! Thanks very much for that, appreciated :D |
| Awesome, thanks for the clean and easy-to-add preloader! |
| Before I spend hours wrestling with it, please, does this still work with the latest Monkey, or at least V74a? |
| Ive tried this preloader with V74a and V75d.|
In both cases no preloader shows up at all in IE and the progress bar doesn't move in Chrome.
It works fine in Firefox, Safari and Opera though.
Can anyone else confirm this as I suspect it may be a problem with just my box.
UPDATE: I tried building with 72b which therevills specifically wrote the last preloader for and I got the same exact results so apparently it is my box.
I tried building with 3 different Flex SDK's and still the same results.
I'm at a loss to figure out what it is.
Other than the Flex SDK what else is involved in building Flash games with Monkey?
| I use essentially the same code, with minor tweaks. |
(I bloated out the swf to ~6MB so you see the loader bar for longer).
For me, this works on Chrome, Firefox, Opera, mac+windows. + works in IE7, Safari. But, I havent done a wide release using this preloader yet (have been using mochi distribution till now).
I'm using flex 4.6. My browsers + flash are generally up to date. I'm using monkey 72b. Actually, I dont edit any of the monkey trans/build commands, I just use mxmlc on the command line manually, but its the same command.
| Yep, your preloader works in every browser so it is my box.|
Thanks for the confirmation.
I'm going to try an uninstall/reinstall of everything.