How to prepare yourself for Flash CS4 ACE exam

Just passed! I become Adobe Certified Expert on Flash CS4!

Like Flex with AIR certification I’d like to share my experience to prepare yourself for ACE exam of Flash CS4.

First of all… EXPERIENCE! You must work, play and work & play with Flash CS4 IDE and Actionscript 3.
More experience you have on Flash development less you must study for the exam and you have more chance to pass.

Obviously, it’s so difficult to know everything about Flash CS4 from all IDE controls to Actionscript 3 and OOP so there are 2 books that could be helpful to solve this “issue”.

With those book you can create a good base to try ACE exam for Flash CS4 but, if you have read Essential Actionscript 3 could be better for Actionscript side and for your daily work ;).
Another good suggestion is to read Help guide of Flash, in fact Adobe made an impressive job on that guide and you can find lots of interesting stuff; you can download a guide PDF file directly from this link.

Try everything, from import PSD or AI files to prepare files for web or desktop application with AIR, because you may find some questions about AIR and own code syntax!

Finally test yourself before real exam with a very good service (I really appreciate it) like acequestions.com with less then $10 you can try how Flash CS4 exam works and also which kind of questions you could find in that certification.
That’s it! Take a look at Adobe site to read all information to become Adobe Certified Expert and… GOOD LUCK!

Memento Pattern in Actionscript 3 (UNDO/REDO)

Happy new Year everybody!

I’d like to begin 2010 with a design pattern argument.

First design pattern of this year is Memento pattern, that could be very useful if you are working on an AIR desktop application or in a Flex RIA and you want to make an history of user’s actions.
In fact this pattern is used to make undo and redo in an application.

Memento pattern is tightly coupled with originator object and it’s usually composed by 3 different parts:

  • memento
  • caretaker
  • originator

Originator is object that pass data to caretaker and it saved them in a couple of arrays (undoArray and redoArray).
So caretaker is an object that stores a memento snapshot and, if originator needs, pass undo or redo data to this object.

I prepare a sample to understand better what could you use Memento pattern in your applications (“view source” option is activated).
I wrote a Memento class with a Singleton to centralize all users actions,then I create a MementoVO that is a dynamic class to help me store data from each object used by the user, you could use a simple Object instead of a dynamic class to save more memory if you prefer.
Sample is very easy but useful for Memento pattern purpose, in fact you can move windows trough the stage and our “history” class (Memento.as) saves their positions when saveAction method is called by the originator (an instance of CustomWin).

Memento class has 4 essentials methods that are:

  • undo()
  • redo()
  • saveAction(_obj:Object)
  • saveRedoAction(_obj:Object)

I start from the end, saveRedoAction, last method, is used to save the position of a window before I restore its positions, usually Redo action is used only one time, but if you want you could create an Array and work with multiple Redo.

Another important method is saveAction that is called when mouse down event was triggered and it stores in memento class own old position and object itselfs.

First two methods need to undo and redo an user action, it’s easy isn’t it?!

I think that in this year I’ll share lots of those patterns with you to share our knowledge together so feel free to add comment at this post and we could make an interesting and useful conversation, I’m totally sure!

Are you a developer? Great! Take this survey

Hi everyone,

this post is very important, for us but also for you.
If you are a developer we want to know your opinion!

With my company, we are starting a new software development  dedicated to developers, made from developers to developers.
So we’d like to hear your voices, help us to make a better software for developers world.

Take this survey, it’s only few questions but they help us to know how you expect from a new tool for developers.
Don’t worry, in next few weeks I’ll give you more informations about that, but until now, please take the survey and thank you in advance to everyone.

Feel free to leave a comment or contact me via email for any questions.

Flickr mesh-up with actionscript 3, REST or SWX

Today I spend my afternoon to configure a part of a full Flash website that interact with Flickr and that retrieve data from my account without any appication authentication but only with my Flickr key.

First of all I was really impressed about how many languages you can use to bring Flickr photos and use in own desktop application or website (Real Basic, cUrl, Perl, Delphi, C…).

When you want retrieve photos from Flickr you must have a Flickr key that is totally free and you can activate one directly in the right section of Flickr site.
In the same section you can find whole documentation and lots of services expose to retrieve any kind of data from a photo, from Exif data to user or friends informations.
For AS3 we have a couple of interesting library; first one is as3flickrlib very well documented but it’s so long to start work with it because you must to find a frob ID then a token and finally you can start to work with Flickr API.
The other one is SWX, that is written by Aral Balkan and it’s too easy to mesh up any kind of popular service like Flickr, Twitter and so on.
Aral gives us availability to use SWX Service Explorer to take a look at the data and how to mesh up your application with public API, I really love it on Flash Lite too!

This is very interesting because you can retrieve all API in this library and in few line of code you can work with public services.
This is a simple example to call Flickr services with SWX, you can download source code too:

swx = new SWX();
swx.gateway = GATEWAY_PHP;
swx.encoding = "POST";
var callDetails:Object =
{
serviceClass: "Flickr",
method: "photosSearch",
args: ["", "", "#mart3"],
encoding: "POST",
timeout: 5,
resultHandler: resultPhotos,
faultHandler: faultHandler
};
swx.call(callDetails);

Another interesting way to work with Flickr API without any authentication is using REST API.
REST (Representational state transfer) is a very simple way to request data from a database, update, delete them or to create new record using HTTPHeaders and XML.
You must know that AS3 doesn’t have PUT and DELETE method but there are some libraries that create a workaround to solve this limitation and they work very well with REST (as3httpclientlib for example)
I start to approach REST a couple of months ago with Ruby on Rails and I think is amazing.

Flickr gives us REST API too, and you can see that is so simple create a Flickr gallery with REST and Actionscript 3.

We have some API that works without authentication like photos search and we use this service to retrieve data for our Flickr gallery.
First of all we take a look at service documentation on Flickr, you can see that we have a lots of opportunity to find data on Flickr; we can search photos via userID, tags, text on title or description and so on.

In Actionscript 3 we’ll use URLLoader class and prepare some url to retrieve XML data from REST.

private const FLICKR_SERVICE = "flickr.photos.search";

private const API_FLICKR:String = "c6c31464878505403f9bbbf6214ae413";

private const PATH_SEARCH_FLICKR:String = "http://api.flickr.com/services/rest/";

		

public function FlickrRest(){

			

	var varsFlickr:URLVariables = new URLVariables();

	varsFlickr.method = FLICKR_SERVICE;

	varsFlickr.api_key = API_FLICKR;

	varsFlickr.tags = "#mart3";

			

	var req:URLRequest = new URLRequest();

	req.url = PATH_SEARCH_FLICKR;

	req.method = URLRequestMethod.POST;

	req.data = varsFlickr;

			

	var urlL : URLLoader = new URLLoader();

	urlL.addEventListener(Event.COMPLETE, retrieveImages);

        urlL.load(req);

			

}

You can download source code and final sample from this link.
Finally I’d like to explain how to compose photo’s url to retrieve them on Flickr.
Flickr url is composed by some variables that you can find in REST XML or SWX result object

  1.  set FARM (ex.: http://farm”+flickrXML..photo[i].@farm+”.static.flickr.com/)
  2. set SERVER (ex.: +flickrXML..photo[i].@server+”/”)
  3. set Photo ID with underscore  (ex.: +flickrXML..photo[i].@id+”_”+”)
  4. set Secret code (ex.: flickrXML..photo[i].@secret+)
  5. last parameters is which size you want to get photos, you can use “_s.jpg” for small size, “_m.jpg” for medium, “_l.jpg” for large and so on.

I hope that could be interesting for many developers, if you have any suggestions or idea about mesh up with Flickr, feel free to drop a comment.

Presentation Zen: a book dedicates to speakers

This summer, during my flights, I decide to read a book dedicate on how to create AMAZING presentation, so I buy Presentation Zen and in 10 hours more or less I finish it and… WOW, it opens my mind!

Author approach is very simple and start his book saying: “Remember that are only suggestions, this book is not a bible that teach you how to use Powerpoint or Keynote, but it shows you how to approach a real presentation process”.

In fact, if you read the book, you don’t learn how to prepare great slides with slideware (it’s a fantastic term to define presentation’s softwares like Powerpoint or Keynote) but you’ll learn what you MUST think behind a slide… out of your computers world.

Few things that I learn reading Presentation Zen:

  • Avoid bullets list (like this :P)
  • Think about the message before switch on your computer and, if you can, go away from your computer with a pen or pencil and paper, tons of papers
  • You must focus your presentation in ONE MESSAGE and follow it during your slides creation
  • An image is better of 1 thousand of words
  • Presentation must help you during your speech and not substitute you
  • Less is better

There are tons of concepts that can help any kind of speakers from IT world to Yoga teachers (I suppose).

I think could be so interesting for anyone that usually speech for passion in conferences or for everyone that make presentation for work like CEO, marketing people and so on.
If you are interesting to buy this book or give more informations about it, go to author’s blog.

How to switch from Actionscript 2 to Actionscript 3… in September for FREE in Milan and Rome

During September I’ll take part of Arrivano i Guru Tour, an Italian event that allow designers, developers and photographers to learn new stuff for FREE about Adobe technologies!
In fact, the event starts in September until to the end of October and you can see it in 10 differents Italian cities.

In the last event you can find a special guest… Katrine Eismann, on of the most important person in creative digital retouch world!
I decide to talk about a big problem for a lot of developers: How to switch from Actionscript 2 to Actionscript 3 during my sessions in Milan (27th September) and Rome (5ht September).

During my session we can see the power of new AS3 features,  architecture of new Flash Player and differences of both languages.
You can see a real mirror from AS2 scripts to AS3 scripts and how to porting your daily “Actionscript life” to a new step: more interesting and powerful!

If you’d like to have more information take a look at the site or feel free to contact me leaving a message on my blog or dropping me an email.

I hope to see you during this event and remember that is a great opportunity to learn more and for FREE!

See ya!

Create PDF in runtime with Actionscript 3 (AlivePDF, Zinc or AIR, Flex or Flash)

This morning I’ve a new target, create PDF in runtime with Actionscript 3.
Very cool project to accomplished this mission is AlivePDF, an opensource AS3 library that you can download from Google Code.
AlivePDF allow you to generate PDF in runtime with Actionscript 3 and you can add pages, draw in each pages or add images, it’s very powerful library.

In this sample I use Actionscript 3 (with FDT) and Multidmedia Zinc 3, but you can use Flex or Flash and AIR to make this sample.
So first of all I create a simple class that allow you to create a PDF file with multiple pages and to add content in each pages.
This is the code:

package org.mart3.pdfGeneration {
    import flash.events.Event;    
    import flash.utils.ByteArray;    
    
    import org.alivepdf.images.ImageFormat;    
    import org.alivepdf.saving.Method;    
    
    import flash.display.Loader;    
    import flash.events.IEventDispatcher;    
    import flash.events.EventDispatcher;
    
    import org.alivepdf.pdf.PDF;
    import org.alivepdf.layout.Orientation;
    import org.alivepdf.layout.Size;
    import org.alivepdf.layout.Unit;
    import org.alivepdf.display.Display;
    
    /**
     * @author lm
     */
    public class CreatePDF extends EventDispatcher {
        
        private var pdf:PDF;
        public var pdfBA:ByteArray;
        
        public function CreatePDF(target : IEventDispatcher = null) {
            super(target);
            
            pdf = new PDF(Orientation.LANDSCAPE, Unit.MM, Size.A4);
            pdf.setDisplayMode(Display.FULL_PAGE);
        }
        
        public function set totalPages(num:int):void{
                
            for(var i:int = 0; i < num; i++){
            
                pdf.addPage();    
                
            }
    
        }
         public function setData(_l : Loader, _numPage:int) : void {
            
            pdf.gotoPage(_numPage);
            pdf.addImage(_l, 15, 15, 0, 0, ImageFormat.JPG, 100);
        }
        
        public function savePDF():void{
            pdfBA = new ByteArray();
            pdfBA = pdf.save(Method.LOCAL);
            
            var evt : Event = new Event("baReadyEvent");
            dispatchEvent(evt);
        }
    }
}

Obviously if you want, you can create a custom event that pass to the document class the ByteArray but this is a quick sample to show how you can create PDF in runtime!

One of the amazing things that you should do with AlivePDF, it’s that you can decide to save PDF locally or on web! Read documentation because it’s very interesting what you can do with this library!

Ok now, go to document class where we use MDM swc that you can find when install Zinc on your computer (you can find 2 differents SWC, one for Flash and the other one for Flex. Remeber also that Flash SWC works with Flash CS4 also, not only with Flash CS3!).
In this class we do those simple steps:

  • create a PDF object using CreatePDF object
  • set our PDF document
  • pass an external image loaded with Loader object
  • save PDF bytearray with Zinc FileSystem class
package org.mart3.pdfGeneration {

    import flash.display.MovieClip;    
    import flash.net.URLRequest;    
    import flash.display.Loader;    
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;

    import mdm.*;

    import org.mart3.pdfGeneration.*;

    /**
     * @author lm
     */
    public class Main extends Sprite {
    
        private var pdfObj:CreatePDF;
        private var l : Loader;
    
        public function Main() {
            
            mdm.Application.init(this);            
            
            pdfObj = new CreatePDF();
            pdfObj.totalPages = 2;
            pdfObj.addEventListener("baReadyEvent", saveLocalPDF);
            
            l =  new Loader();
            l.name = "myImg";
            
            l.contentLoaderInfo.addEventListener(Event.COMPLETE, showImage);
            l.load(new URLRequest(mdm.Application.path+"assets/bg.jpg"));
        }
        
        private function saveLocalPDF(e:Event) : void {
        
            mdm.FileSystem.BinaryFile.setDataBA(pdfObj.pdfBA);
            mdm.FileSystem.BinaryFile.writeDataBA(mdm.System.Paths.desktop+"generate.pdf");
    
        }

        private function showImage(event : Event) : void {
            
            l.scaleX = l.scaleY = .4;
            var mc : MovieClip = new MovieClip();
            mc.buttonMode = true;
            mc.addEventListener(MouseEvent.CLICK, savePDF);
            mc.addChild(l);
            this.addChild(mc);
        }
        
        private function savePDF(event : MouseEvent) : void {
            event.currentTarget.alpha = .5;
            pdfObj.setData(l, 1);
            pdfObj.savePDF();

            
        }
    }
}

You can also download source files from their hosting service and test it on your computer.
Feel free to give me any comments about AlivePDF, it’s very interesting to know what you think about this AS3 library.

I’m just come back from 3GSM World Congress

Here we are!
Yesterday I came back from Barcelona (what a wonderful city!), I was there for 3GSM World Congress invited from Adobe to show our latest Flash Lite contents made in collaboration with Mutado, an Italian creative and interactive company.
It was amazing for us and I’d like to thank you Adobe people to give us this opportunity, thank you guys!

Adobe stand was amazing I love it so much and also Adobe announced lots of new stuff from new Flash Lite player delivery to new challenge that allow developers to win $30.000!

Flash Lite challengers is a contest that will finish at the end of May and we’ll know winners in the middle of June.
Main prize is $30.000 for the best Flash Lite application, but there are also categories prizes from games to applications, it’s a great opportunity to show your mobile content and win!
More information about this challenge on Adobe site

Another great news is that now, we have a new way to distribute our Flash Lite contents, in fact if a device goes trough a Flash Lite content on the web browser or download a Flash Lite application, if this device doesn’t have installed Flash Lite 3.1, it will be downloaded from web and installed on the device.
More information about this new way to deliver your content on Labs site.  

Also Adobe and Nokia give us a new opportunity to invest in mobile projects with Open Screen Project fund ($10 million), in fact this fund is created to help companies and developers to join in mobile Flash world!
More information about it in open screen project site

Finally I put a review on mobile.actionscript.it about new Flash Lite devices like Palm Pre or Nokia N97, so feel free to comment it (and take a look about our new mobile website).

 If you want to see a quick tour about 3GSM feel free to take a look on my Flickr account.

My last 2 posts about SQLite in AIR cookbook

In last weeks I spent a lot of time to work with SQLite in AIR for a course that I made in an italian company, so I decide to create a couple of posts in Adobe AIR cookbook about transaction with query and how to works with existing SQLite database included in an AIR application.

You can find in AIR cookbook  section in Adobe.com site.
In those posts you’ll find full HTML/Javascript and Flex/Actionscript samples.

I suggest to use this great section to share your AIR or Flex (there is also Flex cookbook section obviously)  skills and experience with all developers community.
For any kind of suggestions or comment, please contact me directly.

New Flex resource: flexets forum

Today is my last at work, from tomorrow to 23 August I’m on holiday.

But before to go on holiday, I want to share with you a new resource made from Franto that is a new Flex forum where you can talk about Flex, AIR and actionscript 3, share your knowledge with other developers and so on.

It started a couple of days ago so there are few people now, but I’m sure that could become a great resource for all Flash Platform developers.

Flexest launches also a service called Coaching forum, where new developers has a traning coach on Flex, AIR or Actionscript that helps to learn this stuff.
If you have few minutes during this holiday period, take a look and register in this community to start share your Flex exeprience! see you there guys!