Flash game Eggie (WebORB, PHP and MySql)

Posted by admin on May 30th, 2010

Together with a colleague Piet Santy (aka Ploem), who did the artwork, we created a Flash Game for a friend of ours. Elections are up in Belguim and Dominique Dehaene needs votes! One way to get some attention and publicity is off course the internet. It was great to work with CS5, but I did have some problems with code completion and Flash Builder. Also, in Flash Builder, lots of classes weren’t found. I probably haven’t searched enough to find out the solutions of these problems.
I really like creating once in a while such a small game. No design patterns are involved, no architecture, just programming and quickly seeing result! With WebORB for PHP together with MySql I created a TOP 10 highscores. When the game finishes, your score is stored in the database and top 10 is fetched and displayed. Setting up WebORB for PHP was very easy. I just had some problems with a function that I called Echo, which is a reserved word in PHP and off course not knowing the language PHP. But everything was created very fast.

The result can be found here.

<

WebBrowser Control – Flash DropDown Fix (Framework 2.0)

Posted by admin on May 4th, 2010

For a customer of ours we had to create a standalone browser that could load assessments for candidates. It couldn't be loaded in a browser because the user would have access to the computer. Anyway, the .NET WebBrowser component loads a html page with the swf that starts the assessment.
The problem now was that Flex/Flash dropdowns didn't seem to work. A candidate could click on the dropdown, the items were shown but when an item was clicked, the dropdown closed and the item was not selected. On my laptop I couldn't reproduce the bug.

After searching someone pointed me in the right direction on StackOverflow and with the help of this question on a vbdotnetforum, I finally managed to find the problem and two solutions.

Problem

It seems that when clicking the dropdown, a Flash layer is displayed on top of the dropdown with the items. At that moment, the WebBrowser seems to take over the focus. When clicking on an item, you are actually clicking on the whole Flash Application, giving back focus to the swf, but not selecting an item. Because Flash gets back the focus, the dropdown closes automatically.

Solution 1

The problem only occurs when the client pc has .NET Framework 2.0 installed and nothing higher. When installing .NET Framework 2.0 SP1 or 3.5, the problem is resolved.

Solution 2

By extending the WebBrowser component and overriding one function, you can resolve the problem without upgrading .NET Framework. Use this Class as your WebBrowser and everything should work fine (the VB implementation can be found at the link above):

C#:
  1. using System.Windows.Forms;
  2.  
  3. namespace SaltoExplorer
  4. {
  5.     /// <summary>
  6.     /// When clients have .NET Framework 2.0 installed and
  7.     /// nothing higher, then there's a problem that not item
  8.     /// can be selected in Flex DropDowns.
  9.     /// It's a problem with focus. From the moment
  10.     /// .NET Framework 2.0 SP1 or  higher (like 3.5) is installed,
  11.     /// the problem is resolved.
  12.     /// Extending the WebBrowser component can fix this problem,
  13.     /// but it should only be done if the problem occurs
  14.     /// (with .NET Framework 2.0)
  15.     /// See
  16.     /// http://www.vbdotnetforums.com/vb-net-general-discussion/18563-webbrowser-control-2-0-framework-flash-fix.html
  17.     /// http://stackoverflow.com/questions/2205924/problems-flashflex-in-net-webbrowser-component
  18.     /// </summary>
  19.     public class Edumatic3WebBrowser : WebBrowser
  20.     {
  21.         private const int WmLbuttondown = 0x201;
  22.         private const int WmRbuttondown = 0x204;
  23.         private const int WmMbuttondown = 0x207;
  24.         private const int WmMouseactivate = 0x21;
  25.  
  26.         private ContainerControl FindContainerControl()
  27.         {
  28.             ContainerControl cc = null;
  29.             Control ctl = this;
  30.             while(ctl != null)
  31.             {
  32.                 var tempCc = ctl as ContainerControl;
  33.                 if(tempCc != null)
  34.                 {
  35.                     cc = tempCc;
  36.                     break;
  37.                 }
  38.                 ctl = ctl.Parent;
  39.             }
  40.             return cc;
  41.         }
  42.  
  43.         protected override void WndProc(ref Message m)
  44.         {
  45.             switch (m.Msg)
  46.             {
  47.                 case WmLbuttondown:
  48.                 case WmRbuttondown:
  49.                 case WmMbuttondown:
  50.                 case WmMouseactivate:
  51.                     if(!DesignMode)
  52.                     {
  53.                         var cc = FindContainerControl();
  54.                         if(cc != null && cc.ActiveControl != this)
  55.                         {
  56.                             //Probably giving focus to the Swf
  57.                             cc.Focus();
  58.                         }
  59.                     }
  60.                     base.DefWndProc(ref m);
  61.                     break;
  62.                 default:
  63.                     base.DefWndProc(ref m);
  64.                     break;
  65.             }
  66.         }
  67.     }
  68. }

<

Educational software

Posted by admin on October 18th, 2009

I've been working almost 5 years now on educational software in two companies (first Indie Group, now Televic-Education). We mainly created CD-ROMS (that were enclosed with schoolbooks) and online solutions. All those applications were not built from scratch, instead we created a framework that could read in all exercises and hierarchy of the exercises. Those exercises were created in a back end were you could assemble them in folders and export them in a format for our framework (xml) or other formats like SCORM.

I haven't got any videos yet on those CD-ROMS, but you can see two of our online solutions in action. The first is Edumatic, the first application that was created and which has some 20 exercise types (multiple choice, fill in, cross word, dragndrop, translate, ...). It can be used online or exported to be used in CD-ROMS. On the site of edumatic, you can try out an online example of a multiple set of exercises (for each exercise type there are a lot of exercises). Our senior product manager (;-) Piet Santy) also shows an example each day created with Edumatic which you can follow on Twitter --> link. Please follow and try out his examples! Some of his past examples are shown here and here and here and here(demo). Edumatic back end is created in ASP.NET, the front end in Flash (AS2). Together with Christophe Herreman we created the framework for it, but a lot of other persons contributed to the framework, back end and exercise types like Kristof Neirynck(current technical lead), Bert Vandamme, Piet Santy, Sofie Deparcq and others.

Our other product, which is newer than Edumatic, is called Edumatic Exam. It is now used by three customers and has a lot of potential. It's more an assessment application than an exercise application and has currently some 15 exercise types. We are striving to support all exercise types from Edumatic, but that'll take some more time (we're nearly there). Client side is created in Flex, back end with .NET. This application is used by our government to test the knowledge of applicants. Daily there are multiple sessions with hundreds of candidates. We haven't got a demo online yet, but if you subscribe yourself at Selor, you can practice some of the language assessments with our application (you need to go to Mijn Selor, subscribe and then choose Taaloefenpakket... all in Dutch or French...) Try it out! The product is also online, but currently you can not register for it. That'll be something for the future. Currently working most on Edumatic Exam are Bert Vandamme, Sem Dendoncker, Wouter Vanden Berghe and me.

Cheers and practice!

<

Oldschool Flashing

Posted by admin on August 2nd, 2009

After some years of Flexing I've restarted to Flash. I'm creating a flash site for Peter Platel (know from 'Kleren maken de man') and it has been lots of fun and lots of frustration. Luckily I've gotten support from Ward De Langhe, one of the best Flash Developers around! (Check the Art he's creating with Flash! Awesome!).

Four and a half years ago I started working with Flash mainly to created cd-roms (in a Zinc of Director shell --- even more frustrating). After a while you get to know that Flash isn't always logic. Sometimes I would search hours for a bug just to find out that the bug was in Flash and all you could do is work around it. Other things I remember from working with Flash:

  • Debugging is a disaster because there is no debugger. You had to put traces all around to find a bug and those traces would only appear when you were building in Flash. So SOS logger was used to get some logs when you're site was online for example.
  • Quite often the library in Flash was like a battlefield after a few weeks of development. And once a battlefield is wasn't easy to find anything back.
  • Putting code on the timeline in Flash was a way of punishing the developer that came after you... We had projects from a previous developer that were like a puzzle with code all around... we called it 'name of developer'-code... :-)
  • Creating flash content that would adapt to the size of the stage is a hard one. Certainly when you worked with Flex were Layout Containers are part of the sdk going back to Flash is a adventure. With the help of some basic classes created by Ward De Langhe I created a liquid flash site. Some bugs are left in my flash site but they will be resolved in the near future. For a project I've worked on (Edumatic) we even created Layout Containers in AS2 (based on the Layout Containers in Java).

So, this in mind, I went on creating this Flash Site. Now I have:

  • Still no debugger but, but I started an ActionScript Project in FlexBuilder parallel to the Flash project. This ActionScript Project uses assets from an Swf file. This ActionScript project has the adventage that it can be debugged. The flash project still can't be debugged. Another thing I'd like to try is a Flex Project for creating a Flash Site. I wonder if this will work out... (to be continued).
  • My library is kept clean from in the beginning! If you import graphics from Illustrator, you sometimes get hunderds of groups in groups in groups... I always clean them out first.
  • Almost no code is found in the fla file. All code is in classes, except sometimes a stop() for animations (I could also do this in code but in this case I like it more in the fla).
  • The liquid design isn't easy when you've never done it. For example, if you have a Tween that's dependent of the stage size and during the tween you the stage is resized, you can get in trouble.
  • Thx to some classes provided by Ward, the site is localized. For each language there's a Xml file containing the text content.

I've tried to use Spring.Actionscript in the project but the Ioc framework needs some classes from the Flex Sdk so I could not compile it. Anyway, to keep the size small of the swf it's maybe better to leave it out.

Another thing I learned is that it's a lot of work compared to the result. What seems little work for the customer or graphical designer sometimes takes a lot of hours... But I'm happy with the result for now. The site is far from finished so check it out in the next months as new parts will be added.

<

AS3 – C# String Replace with Regular Expressions and Callback function

Posted by admin on January 15th, 2009

In AS3:

Actionscript:
  1. ...
  2. var regExpDigitString:String = "\\d+"
  3. modified = original.replace(new RegExp(regExpDigitString, "gi"), findSuffix);
  4. ...
  5.  
  6. private function findSuffix():String {       
  7.     var result:String = arguments[0];
  8.     var index:int = arguments[1];
  9.     var input:String = arguments[2];
  10.        
  11.     ...
  12.                
  13.     return result;
  14. }

In C#

C#:
  1. ...
  2. String regExpDigitString = "\\d+";        
  3. modified = Regex.Replace(original, regExpDigitString, new MatchEvaluator(findSuffix), RegexOptions.IgnoreCase);
  4. ...
  5.  
  6. private String findSuffix(Match m) {
  7.     String result = m.ToString();
  8.     int index = m.Index;
  9.     String input = original; //apparently you can't get the original string out of the Mach Object, so you'll need a reference to the original Object in your class.       
  10.            
  11.        ...   
  12.  
  13.     return result;
  14. }

<

Artist with Flash – Ward Delanghe

Posted by admin on November 6th, 2008

A friend of mine, a great flash programmer, creates art with Flash! I didn't want you to miss this:

http://www.flickr.com/photos/v-i-p/3004875027/sizes/o/

Next one I really like:

http://www.flickr.com/photos/v-i-p/3002746743/sizes/o/in/photostream/

Cheers! Lieven Cardoen aka Johlero

<

Using Zinc with Flash9/Flex AS3 Swf’s

Posted by admin on December 20th, 2007

I had a Zinc project which worked fine on PC but showed absolutely nothing on Mac. I just got a nice Window with nothing in it. Even a swf with a simple button wouldn't load on Mac.

After an hour of searching I saw that in a Mac Zinc Project, you can choose the Embedded Flash Control in the Flash Settings tab. If you want your executable to work on Mac, you better set this on Flash 9...

ZincAs3EmbeddedFlashControl

Yeah, life can be hard.

<

Making Service Accessible for FluorineFX

Posted by admin on December 17th, 2007

With FluorineFX you need to add the tag [RemotingServiceAttribute]] to our service class to make it accessible. It means you need a hard reference to FluorineFX in your class.

There's however a configuration setting to make all services accessible at once:

<!-- value="browse|access" -->

<remotingServiceAttribute>access</remotingServiceAttribute>

<

Sending Arrays instead of ArrayCollections in Fluorine & FluorineFX

Posted by admin on December 17th, 2007

In Fluorine:

<classMappings>

 <classMapping>

  <type><![CDATA[System.Collections.Generic.List<T>]]></type>

  <customClass>Array</customClass>

 </classMapping>

</classMappings>

In FluorineFX:

In services-config.xml

<channels>

 <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">

  <endpoint uri="http://{server.name}:{server.port}/context.root}/Gateway.aspx"  class="flex.messaging.endpoints.AMFEndpoint"/>

   <properties>

    <legacy-collection>true</legacy-collection>

   </properties>

  </channel-definition>

<!--

<channel-definition id="my-rtmp" class="mx.messaging.channels.RTMPChannel">

<endpoint uri="rtmp://{server.name}:2037" class="flex.messaging.endpoints.RTMPEndpoint"/>

<properties>

<idle-timeout-minutes>20</idle-timeout-minutes>

</properties>

</channel-definition>

-->

</channels>

<

.NET Invocation guide for Flash Remoting clients AS3

Posted by admin on December 17th, 2007

Finding examples with AS2 to do a Remote Call (Fluorine or WebORB) is easy.
However, finding an example for AS3 is very, very hard.
Here's how you do it (thanks to Ward De Langhe):

Actionscript:
  1. private function getGalleryData():void{
  2.  
  3. registerClassAlias("logics.BLL.CollectionEntity",GalleryVO);
  4. registerClassAlias("logics.BLL.GridRowEntity",GalleryRowVO);
  5. registerClassAlias("logics.BLL.PictureEntity",GalleryImageVO);
  6.  
  7. galleryService=new NetConnection();
  8. galleryService.objectEncoding=ObjectEncoding.AMF0;
  9. galleryService.connect(SiteModel.GATEWAY_URL);
  10. //SiteModel.GATEWAY_URL is url path to your gateway
  11. responder=new Responder(galleryResult, galleryFault);
  12. galleryService.call("remoting.service.CollectionService.GetCollection",responder);
  13. }
  14.  
  15. private function galleryResult(result:Object):void{
  16. galleryVO=result as GalleryVO;
  17. }
  18.  
  19. private function galleryFault(fault:Object):void{
  20. }

We haven't been able to figure aout why ObjectEncoding.AMF3 doesn't work.
Well, it works, but in the result the objects are not deserialized, so you just get Objects...

<

Copyright © 2007 Johlero – Cardoen Lieven. All rights reserved.