Setting dimensions of SWF by modifying AS code
Monkey Targets Forums/Flash/Setting dimensions of SWF by modifying AS code
| ||
After uploading my game Doggy Bounce to Kongregate, I noticed the website didn't allocate enough space to the SFW. The game was partly hidden from view. On their technical forum, one of their moderators suggested the SWF header didn't contain proper information on the width and height. I read in the Monkey documentation that the desired dimensions have to be set in the AS code, so I had a look. I found a solution here: http://www.morearty.com/blog/2006/06/27/setting-the-width-and-height-of-a-pure-actionscript-application/ Just above the game class definition in the AS code generated by Monkey in the flash build folder, you'd have to add a line like this: [SWF(width="640", height="480")] So the start of the AS file would look something like this: package{ import flash.display.*; import flash.events.*; import flash.text.*; import flash.media.*; [SWF(width="640", height="480")] public class MonkeyGame extends Sprite{ ' etc... After building and uploading the SWF again, it is now properly displayed on Kongregate! :D |
| ||
how do you get the game to be 800x600? (without changing the source upon every compile) EDIT - oh its monkey/targets/flash/ and alter the source found there |
| ||
Except Mark frowns on modifying the targets for stuff like that but he leaves us no choice at the moment. xD |
| ||
Well, in the documentation it says: To modify the size and layout of Flash Monkey apps, you will need to modify the MonkeyGame.as file in the .build/flash directory. I just thought at first it wasn't necessary to do this (plus I didn't know how to) as the game was displayed properly on my own site. However, that is probably because in the embed and object code in the HTML I set those dimensions. On Kongregate, they try to get the dimensions from the SWF automatically, which will only work after setting it in the SWF. |