Flash notes by Edzis

ActionScript programmer / Flash developer Edgars Simsons on professional stuff

Archive for the ‘Flash platform’ Category

AS3 preloaders made easy in FlashDevelop

with 7 comments

AS3 Preloader in FlashDevelop

AS3 preloader in FlashDevelop. Click to view swf

 In my code based approach to development I frequently come across the problem of adding a preloader. For projects which are made in Flash authoring the typical one file approach is to add a light preloader in frame 1 of your fla and stuck everything else (including the classes) in frame 2. But how do you make that if you don’t even have an fla file? My favorite code editor FlashDevelop has this feature for AS2 already quite a while. As of beta8 release a similar preloader solution was added also for AS3 projects and today, inspired by Pretty Loaded from Big Spaceship, I finally put my hands on it and created an test project.

As a developer you only need to:
1. create a new project using the template AS3 Project with Preloader,
2. add preloader visuals and logic in the generated Preloader.as,
3. add all the rest of the project in the generated Main.as, the same as for a regular project,
4. compile and enjoy.

preloadertest_swfexploreIf you look at my screenshot or explore your resulting swf, it is can be understood that the first frame contain only the Preloader class and the rest is stuffed on frame 2. Bot how is it done? In step 1 FlashDevelop does a couple of things behind the scenes to tie together the Preloader and Test classes, but most of the magic comes from adding a compiler option -frame start com.edzis.preloadertest.Test. This tells the Flex compiler to add an additional frame, add a label start to it and include class com.edzis.preloadertest.Test  in it. You may read the discussion about this feature on FlashDevelop forum or take a look at compiler option documentation. Note that the used -frame option is just a shortcut to the official -frames.frame.

You have to be careful if you change the name of your Main.as to something else; this requires changes in 2 other places: 
1. var mainClass:Class = getDefinitionByName("YourClass") as Class; in Preloader.as,
2. -frame start YourClass in Project Properties -> Compiler Options -> Additional Compiler Options.

I don’t have much experience with Flex Builder or FDT, but I guess they do not have such feature. But as long as you use the same templates for Preloader and Main classes and find the right place to add the compiler options, there are no other limits.

Feel free to view the preloader in action and download project source.

Written by edzis

January 16th, 2009 at 3:04 pm

Event Tracking in Google Analytics

with one comment

Events are visible in Google Analytics despite<br /> not being enrolled in Event Tracking Beta

Events are visible in Google Analytics despite not being enrolled in Event Tracking Beta

Google recently announced Google Analytics Tracking For Adobe Flash by publishing gaforflash library. This is a standardized and officially supported way for flash platform to track pageviews and events, with the second available only in Event Tracking Beta. Yesterday I checked it out.

After some misunderstandings in the initiation process (tracker has to be of type AnalyticsTracker instead of GATracker) I got my pageviews tracked. But, as i am not enrolled in Event Tracking Beta, the GA user interface did not provide me with access to the events I had tracked. But today I found the cure for that – it is still possible to access event data by navigating to Content Overview and changing the URL from /analytics/reporting/content to /analytics/reporting/events.

Written by edzis

November 28th, 2008 at 10:42 am