Alex Jeffery

HomeArchivesAboutFeed

Hard Lemonade

I have two lemon trees full of lemons and as they say, When life gives you lemons, make lemonade.

I have decided to try to brew some kind of bubbly hard lemon drink. After reading the internet and not finding that many recipes for hard lemonade I just made some thing up. So in a few months it will be interesting to see if the end result can be drunk.

Ingredients:

  • 12 Lemons
  • 1 large piece of ginger
  • 2 Kg of sugar
  • 22 L of water
  • 1 packet of brewers yeast

Steps:

Sterilize all equipment as per the instructions for making a standard home brew.

Slice up as many lemons as will fit in the largest pot I own.

Slice up the ginger and add to the pot.

Fill the pot up with water and bring to the boil for about 20 mins.

Strain the liquid of rind and scum. Pour the strained liquid back into the pot.

Add the sugar and bring the liquid back to the boil.

Add a few liters of cold water to the sterilized fermenter and add the lemon liquid.

Top up with water until it reaches the 22 L mark and the temperature is in the 20 to 27 degree C range.

Throw some brewers yeast over the top of the mix and seal the fermenter.

Brew until it stops fermenting and then bottle with a primed shot of sugar.

Results:

Total Mystery! In a few months I will post the results of this brew. Luckily I have a large supply of lemons that I can try this a few times if this recipe does not work. For my next experiment I am thinking I will try peeling the lemons and blending the fruit. Then mix it with honey and brewing it.



How To Embed An MP3 In Haxe With FlashDevelop

Another quick tutorial about using embedded assets in Flash using Haxe and Flashdevelop.
This time we are embedding an mp3.

For some reason in FlashDevelop after adding an mp3 to your project you can’t add the mp3 to the library. I am unsure why this is.  What this means is we can’t embed the mp3 in exactly the same way as we embed a bitmap

Luckly there is a work around. There is a utility program called SWFMill that can create SWF files based on an xml config file. It looks like FlashDevelop uses SWFMill behind the scenes to create it’s library. You can see this by looking in the obj folder for a flash project as there is an xml file in there and also in the FlashDevelop install location, it includes a version of SWFMill.

So the first step is to create a swf file that contains our target mp3 file. My example xml config looks like this.

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <movie version="9" width="800" height="600" framerate="30">
  3.   <background color="#FF0080" />
  4.   <frame>
  5.     <library>
  6.       <sound id="Funk" name="Funk" import="Funk.mp3"/>
  7.     </library>
  8.   </frame>
  9. </movie>

After creating the config file we call SWFMill to build the swf file with our mp3 in it. The  call looks like this.

swfmill.exe simple config.xml music.swf

After SWFMill has run you should get a music.swf file and it should be about the same file size as your mp3.

Now import the music.swf file into your FlashDevelop project.
Right click the music.swf file and select the add to library option.

Now we need to create a class for the music file. There is one thing to note here. If you want this music class to be in a package you must set it’s name attribute in the SWFMill config above to “packageName.AssetName” or else you will get an error 2068 invalid sound. Here is the code snippet to create the sound class.

  1. import flash.media.Sound;
  2. class Funk extends Sound { public function new() { super(); } }

Playing the music is now very easy.

  1. var music:Funk;
  2. music = new Funk();
  3. music.play();


How To Embed A SWF File In Haxe

Overview

This tutorial will show you how to access objects from an SWF file using Haxe and FlashDevelop. By following these steps you will be able to compile ActionScript 3 code into a SWC, extract the SWF file from the SWC, embed the SWF file in your Haxe project and access the ActionScript 3 objects.

Prerequisites

For this tutorial I am going to be embedding this AS3 SWF Profiler written by Shane McCartney. Note that I will be using the version downloaded from GoogleCode it has a different package than the one on his blog.

Compiling a SWC

To compile a SWC from ActionScript soure we need to use the compc component compiler that came with the Flex3 SDK. It can be found in the bin directory under your Flex3 SDK root dir. For example “C:\flexsdk\bin\compc.exe”

To run the compiler I found it easiest to create a config file and tell compc that to use it to work out what to compile. Here is an example config with comments explaining what each element does.

  1. <flex-config>
  2.   <compiler>
  3.     <source-path>
  4. <!–
  5. The path-element tells compc where to find the actionscript source files
  6. –>
  7.       <path-element>D:\Flash Games\External\SWF Profiler</path-element>
  8.     </source-path>
  9.   </compiler>
  10. <!–
  11. The output tells compc what to call the compiled file.
  12. –>
  13.   <output>SWFProfiler.swc</output>
  14.   <include-classes>
  15. <!–
  16. The class nodes tell compc wich classes to include.
  17. Add more class nodes to add more classes to the output.
  18. Note: The class files have to be in folders that match their package under the path-element directory.
  19. For example my actionscript file is found here D:\Flash Games\External\SWF Profiler\com\lia\utils\SWFProfiler.as
  20. –>
  21.     <class>com.lia.utils.SWFProfiler</class>
  22.   </include-classes>
  23. </flex-config>
  24.  

Then simply call compc from the command line and tell it to use this config file.
For example: ”C:\flexsdk\bin\compc.exe” -load-config+=config.xml

If all goes well you will end up with a new file called SWFProfiler.swc

Generate Haxe classes

After compiling our SWC file we need to generate some Haxe classes so that we can reference these object from our Haxe project. This is pretty easy as the Haxe compiler will help do this for us but first we need to extract the SWF file from the SWC file.

Take the SWFProfiler.swc and rename it to SWFProfiler.zip

Open this zip file and extract the library.swf file.

Tell the Haxe compiler to generate class files for the library.swf by executing this command from the command line:

haxe –gen-hx-classes library.swf

If all goes well you will have a directory structure that looks like this:

hxclasses\com\lia\utils\SWFProfiler.hx

Embeding the SWF file into the Haxe project

Open your Haxe project with FlashDevelop.

Duplicate the directory structure that was generated by the Haxe compiler. The easiest way to do this that I have found is to copy the com directory in Windows explorer and paste it under my src directory in FlashDevelop.

Import the library.swf file into your Haxe project. Again I find it is easy to copy/paste it from Windows explorer into my haxe project.

Rename the library.swf to some thing more meaningful. Eg: SWFProfiler.swf

Right click the SWFProfiler.swf and press the “Add to library” menu option

You should now be able to call the SWFProfiler code from your Haxe code!

For example I have this line of code in my test project and I am able to then use the profiler in my compiled Haxe project.

SWFProfiler.init(flash.Lib.current.stage,flash.Lib.current);

Conclusion

By following these steps you should now be able to compile ActionScript 3 source code into a swc file, extract a libray.swf file from the swc file, generate Haxe classes for each class in the swf, embed the swf and use the embeded objects from a Haxe project in FlashDevelop.

References



How To Install FlashDevelop

Overview

I will be covering how to install and configure FlashDevelop a free, opensource Flash IDE for Windows.

Prerequisites

You will need to have the following software installed before starting this instalation.

Step 1

Download the following:

Step 2

Install the Flash Player ActiveX content debugger. There are no install options or configuration needed.

Step 3

Unzip the Flex 3 SDK to c:\Flex3Sdk

Step 4

Run the FlashDevelop installer using the default install options.

Launch FlashDevelop. Open the settings dialog by going to the Tools/Settings menu.

You can also press F10 to launch the settings dialog.

From the left hand side under plugins select the AS3Context.

Now in the right hand side menu under Language set the Flex SDK Location to the directory you unzipped the Flex sdk too. For example c:\Flex3sdk

Step 5

Unzip the Flash Develop Hello World Project.

Double click the Hello World.as3proj to load the Hello World project.

Press F5 to build and run the Flash application.

You should get a Flash application popup with Hello World in a big blue font if your install is successful.

Conclusion

You should now have a working, tested and verified install of FlashDevelop.

If you run into any issues you can try these pages on the FlashDevelop wiki for troubleshooting.



Embed A Custom Bitmap Using Haxe And FlashDevelop

Recently I started learning Haxe to program Flash games using FlashDevelop. I wanted to embed a custom bitmap image to use as my player sprite. It took me two days to figure this out, so I am writing a quick tutorial in the hope it will save someone else some time.

Add a png file to your FlashDevelop project
Right click your png file and click the “Add to library” option
Right click your png again and select the new “Options” option that is now active
Check the “Embed as Bitmap instead of clip” check box
Uncheck the “Auto-generate ID for attachMovie():”

Enter a sensible name Eg “PlayerBitmap”.
Prefix this name with the package your Main is found in. Eg “org.alexjeffery.PlayerBitmap”

The need to prefix your embeded sprite name with the package name tripped me up when I was trying to get this to work. If you don’t do it the code will compile fine but you will get an invalid bitmap exception when you try to create your custom BitmapData class.

Add the following code to your project

  1. class PlayerBitmap extends BitmapData {public function new(){super(0,0);}}
  2. var bitmapData:BitmapData;
  3. bitmapData = new PlayerBitmap();
  4. var bitmap:Bitmap = new Bitmap(bitmapData, flash.display.PixelSnapping.AUTO, false);
  5. bitmap.x = 100;
  6. bitmap.y = 100;
  7.  
  8. flash.Lib.current.addChild(bitmap);

Build and test your movie.
You should see your custom sprite on the screen.

References:
Embed bitmap in haxe
How to embed and display a png with FlashDevelop, Haxe and Swfmill



CakePHP session lost when using Applets or Flash

Recently I have been developing a website on my dev machine using the CakePHP framework. During this I ran into a problem where I could log a user in, view a Pulpcore applet and then be logged out right after viewing it.

After doing a bit of searching on the net I found the cause and the solution.

The cause:
My Pulpcore applet trying to do a request a CakePHP action from the web server to get and set the highscores.
CakePHP would check the HTTP_USER_AGENT and compare it to the one used to create the session.
When it found that they differed it would kill the session thinking it was preventing a session hijack attempt.

A solution:
In the config/core.php set the following lines
Configure::write(‘Session.checkAgent’, false);
Configure::write(‘Security.level’, ‘medium’);

This will stop CakePHP from regenerating a session every request and stop CakePHP from checking the user agent.
After that my Pulpcore applets where able to request actions as the logged in user fine and keep the session alive.



Pulpcore: Hello world tutorial

A while ago I found a neat Java API called Pulpcore

Pulpcore is an API for creating games in Java as web applets while maintaining a good user experience.
It looks to be quite promising from my dabbling with it so far.
Check out the demo game Milpa to see for your self.

A weak point I can see with Pulpcore is the lack of documentation for people to get started with.
So now I will introduce a setting up a simple Hello world tutorial with the awesome Eclipse IDE.

You can find the tutorial here.

Enjoy.



Crystal Reports Tip: crdb_oracle.dll could not be loaded

At work recently I had to use Crystal reports
We where using it to connect to an Oracle database and generate a report which was then displayed from an ASPX page.

Both of these installs failed at first with the error:
The database dll ‘crdb_oracle.dll’ could not be loaded
Here is a check list of things to try.

  1. Check that crdb_oracle.dll is installed. By default in the Crystal Reports 10 install that I had Oracle was not installed. To fix it run the installer and pick Oracle from the list of items to install.
  2. Check you have the Oracle client tools installed. I remember vaguely it had to be version 9.2 upwards.
  3. Check your PATH variable. If you have more than one version of the Oracle client tools installed I have read that Crystal reports will use the first one it finds set in the PATH variable. Make sure it is the correct version for the database your report needs to connect to.
  4. Check that the IIS user that runs your reports has access to your Oracle client install. Parent directory’s count too from my experience.
  5. Check that the IIS user that runs your reports has access to the crdb_oracle.dll
  6. Checking these things fixed both installs. Both times it was a problem with the IIS user not being able to get to either the Oracle or Crystal report dll’s.



Alex Jeffery