Think your stuff in MVC!

2010-01-27 by Quentin Lengelé
Posted in Flash, Flex having 1 comment »

This little post to tell how I’m bored too find good tools but not really well coded or not well structured.
A good example is the AS3 TouchLib library to build multi-touch applications with TUIO :

This library is a very good idea to translate TCP data from the TUIO server (through FLOSC) to Flash… and it works well.
But when you look to the sources, you can immediately understand the bad MVC knowledge of the developers of that project.
The main controller (TUIO.as) and core classes are inside the flash events package (flash.events)… strange usage, no?
It should be good to organize a cleaner package, something like this :

com.nuigroup.touchlib.controllers.TUIO
com.nuigroup.touchlib.events.TouchEvent
com.nuigroup.touchlib.controls.TUIOCursor
com.nuigroup.touchlib.controls.TUIOObject
com.nuigroup.touchlib.controls.TUIOSimulator

The TouchLib library is not the only case.
A lot of developers release stuff and make them public too quickly.
The time spent to organize your project in a good MVC/OOP way will help others to understand it easier and will help you to maintain it correctly.
A framework is not required to do that. You just need to keep a good and coherent structure of your classes.
For my part, I always begin a project by creating empty packages :

com.myproject.models
com.myproject.views
com.myproject.controllers
com.myproject.controls
com.myproject.utils

During the development, I will create the classes I need to the corresponding package. In that way, I’m sure to keep and good and understandable code for everybody.

Last point : Why AS3 frameworks?

I know I will get some enemies but I need to explain why I don’t like PureMVC, Cairngorm and others:

  • There are good native tools in AS3, often ignored by the developers.
  • Using these frameworks sounds a bit like “re-invent the Life” by using extra classes, interfaces, commands and event dispatchers…
  • The code becomes exaggeratedly split into many classes.
  • Because it’s exaggeratedly split and oppositely to many ideas, you lose a lot of time when someone else has to enter in the project.

There is a good idea of “re-usability” or “maintainability” behind these frameworks but if your project is just well “MVC-minded” they become useless…especially if the main goal of them is to use tools that are already in the Flash or Flex core.
I’m finally thinking that these frameworks are made for(and by) people who ignore how to give a professional structure to their project.

I’m often surprised by the inability or fadeless of some people to simply and correctly use the native AS3 library. And, in many cases, that’s why they use a framework. Sometimes they don’t know how to manage their events properly with native EventDispatcher. Sometimes they forget other native stuff like Event.ADDED_TO_STAGE and Event.REMOVE_FROM_STAGE events to manage things to be killed and cleared from memory. Sometimes they just don’t realize it’s much more quick and simple to create your own controller and its events, a model and the views without a framework layer behind that. Sometimes…

Sometimes I’m so disappointed by the bullshit coming from the mouth of pseudo Certified Flex Developers. They are crazy about frameworks.
One day, a colleague in consultancy to a big client told me : “He came to me to discuss 3hours about the name of a method. ‘GetProductByIdWhenReceivedFromForm1′ or ‘GetProductByIdForm1′. Finally, he chose the second one and he had to refactor lots of classes and re-organize his project.”

First thing, we forced to admit this guy was unable to take a decision, and his faculty to choose a method name is grammatically really bad and counterproductive.  Secondly, wow… 3hours to find a way to recode 40% of your project because your framework madness is killing you from inside…

Hopefully, some of you, pure actionscript programmers, are not like that :)

If you do Flex applications, don’t forget Flex is already a framework.
If you do Flash applications, don’t use a framework, just think MVC.

AS3 2D Ribbons Effect translated from Processing

2009-07-28 by Quentin Lengelé
Posted in Flash having 5 comments »

This is a really nice ribbon effect made by a friend (Christophe Deaconescu).
He translated the Processing code from James Alliban you can find here.
The result is pretty smooth…even with a little glow filter.

Move your mouse over the black area below:

This movie requires Flash Player 9

Here are the sources, ribbons.zip

MovieClip acting like ViewStack

2009-06-25 by Quentin Lengelé
Posted in Flash having no comments »

For some weeks ago, I’m using MovieClips in Flash like I use ViewStack in Flex.

I made this tool because I was bored to work on FLA files with huge timeline animations where it’s almost impossible to find directly what you are looking for, especially when you work on a team and when it’s not your own source code.
In fact, I like the way to open a FLA file and see immediately all the states of an application.

The ViewStack Class and the ViewStackPanel Class manage your different states (frames of a MovieClip) using Event.ADDED_TO_STAGE and Event.REMOVED_FROM_STAGE events.

It becomes really easy to handle you IN and OUT transitions between states and kill all the listeners in a custom view linked to a Class.

In the following example, you’ll see a 2 states (2 frames) ViewStack.
On each frame, there is another MovieClip, linked to a Class that extends ViewStackPanel (here: ContactPanel and InfoPanel).
ContactPanel and InfoPanel inherits of the init(), kill() and disappear() methods… But let’s see in details, just for the ContactPanel:

ContactPanel Class:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package org.cornflex.examples.viewstack
{
  import flash.display.MovieClip;
  import flash.events.MouseEvent;
 
  import org.cornflex.core.ViewStackPanel;
  import org.cornflex.transitions.TweenMax;

  public class ContactPanel extends ViewStackPanel
  {
    public var navigation:MovieClip;
    public var topBanner:MovieClip;
    public var pageContent:MovieClip;
    public var nextButton:MovieClip;
   
    public function ContactPanel()
    {
      navigation.alpha = 0;
      pageContent.alpha = 0;
      topBanner.alpha = 0;
      nextButton.alpha = 0;
    }
   
    override public function init():void
    {
      nextButton.addEventListener(MouseEvent.CLICK, changeFrame);
     
      TweenMax.to(navigation, .5, {alpha:1});
      TweenMax.to(topBanner, .5, {alpha:1, delay:.2});
      TweenMax.to(pageContent, .5, {alpha:1, delay:.4});
      TweenMax.to(nextButton, .5, {alpha:1, delay:.6});
    }
   
    override public function kill():void
    {
      //clear listeners and stuff...
    }      
   
    override public function disappear():void
    {
      TweenMax.to(nextButton, .5, {alpha:0});
      TweenMax.to(pageContent, .5, {alpha:0, delay:.2});
      TweenMax.to(topBanner, .5, {alpha:0, delay:.4});
      TweenMax.to(navigation, .5, {alpha:0, delay:.6, onComplete:finish});     
    }
   
    private function changeFrame(evt:MouseEvent):void
    {
      viewstack.goto(2);
    }
   
  }
}

The main Class of the FLA File, ViewStackExample:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package org.cornflex.examples.viewstack
{
  import flash.display.MovieClip;
  import flash.events.MouseEvent;
 
  import org.cornflex.core.ViewStack;

  public class ViewStackExample extends MovieClip
  {
    public var viewstack:ViewStack;
   
    public var jumpButton:MovieClip;
   
    public function ViewStackExample()
    {
      viewstack.debug = true;
     
      jumpButton.addEventListener(MouseEvent.CLICK, handleClick);
    }
   
    private function handleClick(event:MouseEvent):void
    {
      viewstack.goto(2);
    }
   
  }
}

As you can see in the Main Class, I put a jumpButton to show the possibility to call other states from outside the viewstack itself.
You can imagine to have a navigation working with indexes and telling the viewstack on which state it has to go…

And the SWF output :

This movie requires Flash Player 9

To understand well the concept, I advice to take a look to my sources, here.

FLARToolKit : AS3 Augmented Reality

2009-03-25 by Quentin Lengelé

Months ago, I saw lots of video examples on blogs and YouTube and finally I got some time and found AS3 sources from some brilliant japanese guys (Libspark).
They built an AS3 library called FLARToolKit which is translated from a Java library (NyARToolkit).
This library can detect a “marker” on a video source and calculate its position in a three-dimensional space.
Theses coordinates can be easily used with Papervision3D and applied on a Collada Object or anything else.

Here is my AS3 Augmented Reality Example, done with a Spongle Bob 3DS file found for free on TurboSquid.

Here are some screenshots :

You wanna test it?

1. Download the marker in the PDF document and print it.
2. Allow Flash to access to your webcam when it asks.
3. Point the webcam at the printed marker.

This movie requires Flash Player 9

Sources available soon ;)

Adobe Flex SDK 3.3.0.4852, here it goes again

2009-03-10 by Quentin Lengelé
Posted in Flex having 6 comments »

Am I wrong or the Charting Components are parts of the Free Flex SDK?
If I’m not, the Adobe Flex Dev Team forgot to implement these Charting Components in their last SDK, once again.

One fixed or semi-fixed thing is you don’t need to add the “playerglobal.swc” when you create a project.
I said semi-fixed because, if you want to build a Flex project using Flash 10 player features, you need to remove the playerglobal.swc (FP9) and replace it by the playerglobal.swc (FP10). And If you don’t forget to change your HTML Wrapper “Required Flash Player Version” on 10.0.12, with a bit of chance, it will work correctly.

Hopefully, these tricks are common for experimented Flex/Eclipse users. But think one instant to the poor developpers wanting to learn some MXML and stuff… They have to be very very patient to set up their IDE before starting to enjoy the power of Flex.

Adobe Flex 3.2.0.3958, not so good

2009-01-22 by Quentin Lengelé
Posted in Flex having no comments »

I’ve found some other bad stuff in the last production release of the Flex SDK.

  1. There is no Chart Components
  2. There is no more GroupingCollection in mx.collections
  3. When you create a project with the 3.2.0.3958, you MUST add the playerglobal.swc (Flash9 or Flash10) library if you want to use classes like MovieClip, Loader,…

At least, we are able to compile Flash 10 applications and use the expected unloadAndStop(true) and System.gc() methods… but Jesus! When they are planning to release a complete and bug free SDK?!

How can they announce that :
“Flex SDK version 3.2.0.3958 is the latest production quality release.” at http://opensource.adobe.com/wiki/display/flexsdk/Flex+SDK

Adobe AIR 1.5 codename Cosmo

2008-09-12 by Quentin Lengelé
Posted in Flex having 3 comments »

Mike Chambers Article here.

I was hoping for a long time Adobe AIR team release a new version of AIR. I was hoping especially for the memory leaks (garbage collector) in the Flash Player 9 normally fixed in Flash Player 10 and other bugs.

But I was a bit disappointed :

There is no runtime installer in the AIR 1.5 given in the last SDK Nightly build.
We still have to wait before testing and debugging :(
I installed the last SDK in Flex Builder but we just able to see AS3 code improvements and we cannot export an AIR application because there is no runtime to play it.

The only way to test improvements is to build a Flex Application with that new SDK because there is a Flash Player 10 beta2 for Internet Browsers.

And I was disappointed again :

I wanted to test the famous and expected “unloadAndStop()” method of the Loader Class.
The purpose of that method is to kill all listeners and free memory of a loaded SWF inside a Flash-Flex-AIR application. … It still seems to be buggy because I cannot see memory variations when this method is called.
I hope it’s due to the beta2 version of Flash Player 10 because this bug is a real mess! The unload() method of the MovieClip class in Flash Player 8 was working so perfectly !!

Definitely, Adobe put companies in bad situation. Think one instant to the companies have been planned big projects with Flex or AIR and they are blocked now due to bugs that was not there in previous Flash Player versions…

Can we continue to wait quietly ?? It’s difficult to do…when clients are nervous.

WeatherVision3D

2008-07-25 by Quentin Lengelé

I’m developping a new way of General Positionning System with Flash 9.
It’s still in beta and it has to be bundled with Flicker and many other GPS services.

How to build a SphericVR quickly

2008-04-17 by Quentin Lengelé

This movie requires Flash Player 9

Click and move your mouse over the image.

Again, you need to build a sphere with 3DStudioMax and export it in ASE format.
And your texture has to be a spherical shot to be applied on the sphere.

Take a look to my sources here.

BumpMapping with Flash

2008-04-08 by Quentin Lengelé
Posted in Flash having no comments »

This example is amazing.

PV3D BumpMapping

  • Mouse move — move light source
  • Mouse click — change light color
  • Mouse wheel or +/- — change material’s highlight curve
  • Ctrl + wheel or +/- — change spotlight size
  • Spacebar — next texture

Source :
http://blog.alternativaplatform.com/en/2007/12/30/spot-normal-mapping/




Google

About CornFlex – Flex & Flash by Quentin Lengelé


Hi, I’m a Rich Internet Application developer, based in Belgium.

CornFlex.org is my R&D corner and I hope it will convince you to do more web applications with Adobe Flex and Flash!