Wednesday, March 26, 2014

Preloader in Flash Develop

From my previous post, once you have started to embedding swf (huge ones especially) you probably notice that while loading, you are faced with a blank screen or suffers from preload animations... depends on how your project is. So there must be something to do away with this... ... something called preloader. Thankfully, there is a project type in Flash Develop called..."AS3 Project with Preloader"



What it does is it creates a project with a preloader.as. Yup...



And if you view in the Main.as, you will spot the preloader in the
[Frame(factoryClass="Preloader")]
Just compile away and you have your very own swf with a preloader.

Now look into preloader.as

You get comment sections like
// TODO show loader 
// TODO update loader
// TODO hide loader
They are simply placeholders that you can add codes into.

Now in a preferred situation, you will want to add a background image in your preloader. First make an image. I name mine "preloading.jpg"

Put it in the same directory as the codes and add in
[Embed(source = "preloading.jpg")] public var PreloadLogo:Class;
right at the start of the class Preloader declaration. Now in order to use the jpg image you need to add
import flash.display.Bitmap;
at where the imports are. Now at the // TODO show loader, add
var activeLoadBitmap:Bitmap = new PreloadLogo();
addChild(activeLoadBitmap);
That's it. Just compile and run it. Yeah.. it works...

What do you mean you want more?
Wha?
Status? Progress?

Ok I will add a textfield to this just to show the progress status.
Now in order to use a textfield, you need to add
import flash.text.TextField;
Then at the start of the class declaration add in
public var textFiled01:TextField = new TextField;
public var loadperc:int;
Now right after the addChild(activeLoadBitmap); add...
addChild(textFiled01);
Now at the // TODO update loader add in these two lines...
loadperc  = e.bytesLoaded / e.bytesTotal * 100;
textFiled01.text = "Load " + loadperc.toString() + " %";
Compile and ran... that's it. now your preloader comes with a 'Load xxx %" shown on the top left corner! And it will automatically goes to the "main" after finish loading. Here is how mine look like...

Friday, March 21, 2014

Mochimedia closing down :( Absolute beginner blurrr case scenario for MMF users for Ad quickfix with Flash Develop

Well mochimedia will be closing it's doors coming 31st March 2014. :( With this, it will be the end of all my ads revenue from mochimedia. I have been using Multimedia Fusion for my flash games for some time so adding in the mochiads is rather simple as it's a built in feature for MMF Developer Edition.

The two immediate alternatives for ads I found is FGL and ZuperAds. FGL has been a long player in the industry while ZuperAds is a startup that is shaping up rather nicely after mochi's announcement of it's closure. None of them had an extension in Multimedia Fusion for it's flash exporter :(. I am sure sometime later it will be in but meanwhile I am left with embedding the swf files created by MMF in another SWF which acts as a container that serves the ads.

I am going to walk through on how to add FGL ads as at time of writing, ZuperAds requires you to call ZuperAds,hideAd(); to hide the ads once it's displayed while FGL handles the close ads on it's ad container itself... just to keep it simple.

This might not be the best way but it works... for now.

Ok here goes... what you need.
  • FREE Flash Develop - Get it HERE
  • . Download get the latest. I got mine yesterday ver 4.5.2 Zipped version.
  • FREE Adobe Flex SDK - Get it HERE Now if you got the Flash Develop Zipped version like me, you need to manually download this.
  • FREE Flash Player Active X Debug version - Get it HERE
Yes... I am a bit on a tight budget so everything used is FREE. Even the screenshot I captured was done in FREE GIMP.
Now the hard part... go through Flash Develop Wikidocs on how to set it up properly.

Once it's up and running, create your first Flash Project as shown below.


Make sure you choose AS3 Project and not the default 'Flash IDE Project' or you gonna have problem. I named my project 'TryFGL'

Now you will get a project which has a file class called 'Main' under the src folder. Just go there and click on the Main.as file to view the content. It should look like below



Now try to compile the project... right click on the project and choose 'Built Project'



If everything goes well, the output window at the bottom should show some things that ends with a blue Done.



Congratulations! You are a winner! Ahhh... that's not that bad. You have compiled your swf. It's located in your project directory's bin directory.



Now you need to signup with FGL to get the codes... well I am not going to walk you through the signup and getting the codes part. Just go to FGL.
...
..
.
I am just gonna assume you are able to figure it out by yourself, get the "FGLAds.as" file and get to the 'Download Ad Code' button to actually download the ad code for your game. You will get something like [NAMEOFGAME]_adcode.as. Mine is InvaderDefender_adcode.as.

Just copy the two files over to your project's src folder along with your SWF files created from MMF. Mine is InvaderDefender.swf



Open up the [NAMEOFGAME]_adcode.as. It should look like this.



Note the FGL Ad code number "FGL-2xxxxx28". Now go back to the main.as code and edit it as below.



Ok for those lazy lads that do not like typing... here is the code
package 
{
 import flash.display.MovieClip;
 import flash.events.Event;
 import FGLAds;
 [SWF(frameRate='30', width='550', height='400', backgroundColor='0xffffff')]
 /**
  * ...
  * @author 
  */
  
 public class Main extends MovieClip
 {
  
  [Embed(source = "InvaderDefender.swf")] public var MMFswf:Class;
  public var ads:FGLAds  = new FGLAds(this, "FGL-2xxxxx28");
  
  public function Main():void 
  {
   if (stage) init();
   else addEventListener(Event.ADDED_TO_STAGE, init);
  }
  
  private function init(e:Event = null):void 
  {
   removeEventListener(Event.ADDED_TO_STAGE, init);
   // entry point
   ads.addEventListener(FGLAds.EVT_API_READY, showStartupAd);
   
   var MMFswf:MovieClip = new MMFswf() as MovieClip;

         MMFswf.x = 0;
         MMFswf.y = 0;
         addChild(MMFswf);
         MMFswf.gotoAndStop(0);
   
  }
  
  private function showStartupAd(e:Event):void 
  {
   ads.showAdPopup(); 
  }
  
  
 }
 
}


Now, if only you would spent some time to read and understand the codes... but I guess you won't so... for a quick fix just change the

InvaderDefender.swf to your MMF swf filename.
FGL-2xxxxx28 to your FGL Ad Code.

Now lets compile! Yup... that's it! You have successfully embedded your MMF produced SWF into a new SWF with an ad container from FGL. Just click on your index.html in your bin folder.



Your FGL ad should display on top of your game!



Hope this article is useful.

Tuesday, June 25, 2013

Invader Defender now available on Android!

Invader Defender is now available on Android!

Get it on google play

Tuesday, June 18, 2013

New Game Release! Invader Defender!

Invader Defender! Yet another variant of Space Invader type of game but this one is simply a bit of a different :D Do try it out! Just get that keyboard smacking fingers ready. You will need it!


Wednesday, September 12, 2012

New Game Release! Smack-A-Lot : Titan!

Smack-A-Lot is back! Now with the Olympians to help out against a Titan! Zeus, Poseidon and the other gods will come to your aid.

Now lets get smacking!

Tuesday, September 20, 2011

New game release! Zombie VS Pinball!

This is a Zombie themed pinball game which uses Box2D library for the physics :D. A tribute to my old pinball days! Hope you guys enjoy it!

Get all 'ZOMBIE' and the zombie comes to life! :D



Created in Multimedia Fusion Developer
Learn all about Multimedia Fusion at www.clickteam.com

Wednesday, July 6, 2011

Corona is my friend...

Well like it's title suggested, Corona is my friend. Now what is this corona? It's basically Mobile Development Framework. Currently does

  • iOS

  • Android

  • Barns & Noble's Nook


Hmm... now what does this have to do with Flash Game Programming? You can read / download / try ... all about it here
http://www.anscamobile.com/corona

They even have a Flash Actionscript comparison on that side to help you migrate from Actionscript to LUA. Oh wait... did I mentioned that the codes are in LUA? No? Well everything in Corona is in LUA. Just code once and deploy to iOS, Android and that Nook thingy.

It comes with

  • Emulator for Android

  • Emulator for iOS Devices - for Mac version only :(...



What it didn't come with is a nice LUA scripting interface but you can find a LUA editor by googling it.
It's

Does this mean I am leaving the Flash Arena?
...
..
.
Never!!! Well not currently... if you look at my [BETA] page you can see I am actually working on a pinball game.... sponsor anyone? Help poor me?