Flash Camp Brasil

September 15th, 2009

Galera interativa, é isso mesmo que vocês leram no titulo do post. Quem dá sempre uma olhada no blog do Lee Brimelow viram que haverá ainda nesse ano em países próximos ao Brasil como Chile, Argentina, Peru entre outros o Flash Latin Tour onde ficamos de fora por questões aparentemente técnicas. Mas o bom de tudo isso que em 2010, especificamente em Janeiro, bem no comecinho do ano, vamos ter o Flash Camp Brasil, evento que irá reunir boa parte da galera que programa em Flash, designers e todos que tem o interesse de aprender mais com os caras que estão ai pelo mundo fazendo a coisa girar e aparecer sempre coisas novas.

Então vamos ao Camp galera e sorte a todos ai.

Site: Flash Camp Brasil

Flex now is Flash Builder

May 18th, 2009

Yes, Flex Builder now is named Flash Builder and will be the Flash Platform Coder for Actionscript inside the Adobe Creative Suite CS5. Lee Brimelow write in your blog, The Flash Blog:

We at Adobe expected that the renaming of Flex Builder to Flash Builder would cause quite a bit of conversation in the community and indeed it has. After waking up this morning and reading all the reactions on various blogs and on Twitter, I feel like I need to answer some of the questions and concerns people have.

There you can see some answer for these questions:

• Are you planning on phasing out the Flash IDE?
• Isn’t it going to be more confusing when talking with clients about Flex?
• This screws up my resume and will make job interviews confusing won’t it?
• Will Flash Builder still be based on Eclipse?
• What about the Flex SDK?

Link: Flash Builder rebrand FAQ

Hi for all, today i will explane something about the principiles of Actionscript 3: how to load an image inside the Flash. For totaly beginners, it’s so simple do it.

What the difference when load a picture using Actionscript 2 or 3?
Well, on AS2 you can call the file and imediatly when it loaded will appear inside the moviclip or stage. Using AS3 you can choice when and where the loaded file will appear.

AS3 Loader: your first loader inside Flash CS4
You need the Loader object and too create the listeners that will say for you what’s happen, if is loading, was an error or if the file is completely loaded. These listeners will be necessary always when you call a image or a XML file and others. Well, go to the Loader: see the code bellow:

1
2
3
4
5
6
7
8
9
10
11
12
import flash.display.Loader;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.ProgressEvent;
import flash.net.URLRequest;
 
var request:URLRequest = new URLRequest("image.png");
var loader:Loader = new Loader();
     loader.load(request);
     loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadingImage);
     loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadingError);
     loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadingComplete);

Here i created some differents listeners for the loader, the first, ProgressEvent.PROGRESS, will call the function loadingImage alway when the image is loading, inside the loadingImage you can create your preloader function using loader, get the bytes loaded and bytes total using the ProgressEvent inside the called function, something like this:

15
16
17
18
19
20
21
var loaditPercent:uint;
 
private function loadingImage(p:ProgressEvent):void
{
	loaditPercent = Math.ceil( ( p.bytesLoaded / p.bytesTotal ) * 100 );
	trace(loaditPercent);
}

The loaditPercent will show us the percent loaded. If you try your code will see that the image is loaded because the trace will show you 100% loaded but the image dont appear, need create the loadingComplete function and inside it we will put the loaded file inside of some movieclip or add it on the stage, you choose:

25
26
27
28
29
function loadingComplete(e:Event):void
{
	// addChild(loader);
	addChild(e.currentTarget);
}

This will add the loader, the picture, on the stage. Change the location using the MovieClip instance befora the addChild function. You can use too the loadingError function for your custom loader error, it’s so easy like others. Try it, for support comment here. Thanks for read.

Hi again, sorry for the delay to write again. Here im Brazil, 1st May was a holly day and i was play with my son. Well here in agency we have some problens today with system memory of a AIR Project, the project play full HD videos and HD images into a 32″ LCD. 

The problem: When i load videos and pictures, so much pictures, inside the project using Loader Class the memory will be always growing and growing and this will close sometime the application.

Solution: Like the post title, Garbage Collector. Well, the Garbage collector is alway actived by Flash Player, when i unload the Loader it will be send to the “trash” of Flash Player, and Garbaga Collector will define when delete the “trash” content, but we can tell to the Garbage Collector that “trash”  is Ok to be deleted.

It’s so simple:

1
2
import flash.system.System;
System.gc();

If you have a custom loader class you can put the System.gc() into your unload public function to say to the Flash Player that the unloaded content it’s ok to be deleted.

1
2
3
4
5
6
7
import flash.system.System;
...
public function unloadcontent():void
{
	_yourCustomLoader.unLoad();
	System.gc();
}

To force the Flash Player delete the content more speedily you can make a loop with 10 times calling the Garbage Collector:

1
2
3
4
5
6
7
8
9
10
11
import flash.system.System;
...
public function unloadcontent():void
{
	_yourCustomLoader.unLoad();
	// Calling System Garbage Collector loop
	for ( var gci:uint = 0; gci < 10; gci++ )
	{
		System.gc();
	}
}

The loop will force the Flash Player delete the content and make your app don’t crash.
It’s really easy, yeah? Try it, comment and if i save your life buy me a beer using the donation block in right side. Thanks for reading again

Hi again folks, today working with AIR application i was searching something about control the window and database using Flash CS4, but today i will talk about only window control, close, minimize and move application window, its so simple do it, basically you need import only NativeApplication class, see the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package
{
	import flash.desktop.NativeApplication;
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
 
	public class DocumentClass extends MovieClip
	{
		public var closeBt				:MovieClip;
		public var minBt				:MovieClip;
		public var recordBox			:MovieClip;
 
		public function DocumentClass():void
		{
			closeBt.addEventListener(MouseEvent.CLICK, closeApp);
			minBt.addEventListener(MouseEvent.CLICK, minApp);
			recordBox.addEventListener(MouseEvent.MOUSE_DOWN, dragApp);
		}
	}
}

We have now three functions: closeApp, minApp and dragApp. Three simple steps to take the window control, lets start with dragApp, the function that will drag your AIR Application using MOUSE_DOWN event.

Now we need put this private function inside the document class, bellow the code:

20
21
22
23
private function dragApp(m:MouseEvent):void
{
	stage.nativeWindow.startMove();
}

The function will work only when mouse is down in the recordBox Movieclip, now you can drag your application using mouse moviment. Now to close and minimize the application you will use a simple CLICK event.

25
26
27
28
29
30
31
32
33
private function closeApp(m:MouseEvent):void
{
	NativeApplication.nativeApplication.exit(); 
}
 
private function minApp(m:MouseEvent):void
{
	stage.nativeWindow.minimize();
}

To close the application using Flash CS4 you need use the NativeApplication and not only NativeWindow. But is so easy to use and now you can create your AIR application using a custom chrome. Try it!

Hi guys ( and girls ) today i will talk about the GA for Flash without use any component, only the GA library, like in post title: easy way.

Well the first part is download the GA library: http://code.google.com/p/gaforflash/downloads/list
There you will download a compacted file and when extract it, into the ‘lib’ folder you will see two swc files but the important file now is the analytics.swc

Second step is add analytics.swc file in your library path on Flash. Go to Edit > Preferences > Actionscript > Actionscript 3.0 Settings and now you may browser for SWC file on library path and select the analytics.swc file. Done? Fine. Now we can begin code.

In order for bridge mode to function correctly, ExternalInterface.avaliable must be set to true in your ActionScript 3 code. This also means thatallowScriptAccess should be set to always in the HTML page that embeds the Flash content.

Probably into your project files have a ‘mother function’ for your navigation and is in this function that analytics will have more efficiency, but lest import the GA classes first and after create the GATracker:

1
2
3
4
import com.google.analytics.AnalyticsTracker;
import com.google.analytics.GATracker;
// @ Creating the GA Object
var tracker:AnalyticsTracker = new GATracker( this, "UA-111-222", "AS3", true );

The upper code import and create the GA Object into your project, well import is the same code always but when you create the object need change the data for your Google Analytics account.

23
24
25
26
27
28
29
30
31
32
33
private function changeLink(m:MouseEvent):void
{
	pageID = m.currentTarget.id;
	pageName = pageList[pageID];
	// @ Using bellow custom loader and Events
	var newLoader:loadit = new loadit("pageName");
	newLoader.addEventListener(Events.PROGRESS, showProgress);
	newLoader.addEventListener(Events.COMPLETE, showPage);
	// @ Adding GA for Flash
	tracker.trackPageview("/ + String(pageName) + ");
}

The tracker.trackPageview will send to your HTML page a event alway that changLin function be executed and one day after in your Google Analytics account you will see the access for your flash links. tracker.trackPageview (virtualPage:String), this virtualPage receive the name that your put to your pages, no need physic file but you can set the name like one for sample

32
tracker.trackPageview("/pageName.php");

In your results will appear the access to pageName.php but this file no need exist, its so simple to use.
Try it.

Using Flex together Flash CS4

January 31st, 2009

Hi, now i will talk something about how work with Adobe Flex together with Adobe Flash CS4, and how it can speed your code and make increase your produtivity. Well, three simple things to change your coding to Flex is a complex project organizer into Flex, at the first time we load all the project and we can jump from the document classe for the import classe using a simple click in the import line. 

When we write the code, or beginner coders, can dont understant or dont know where is the ‘Event’ class. Using Flex when i write the code that use Event automaticly Flex create the import line into your class – Great. So, other thing is the ‘import help’, typing the import line the Flex make one list of classes that you found into com or gs or some class folder like show bellow:

import class

Of course for make this list we need put the our library folder using right click on your Project and select the Properties selection. Into Properties go to Actionscript Build Path and add a folder where have your classes or into Library Path can set your SWC file library.

Library folder

Other thing so much important to increase the produtivity is an Cold Fusion plugin update. You can see the install process in GotoAndLearn site in this tutorial. This update will install the Snip Tree View. Essencialy Snip make shortcuts to code functions, hmm great or no? Thing you type ef + CRTL or COMMAND + Space and appear in your code the lines:

addEventListener(Event.ENTER_FRAME, );

Well, it is totally possible using this new feature, see the preview bellow.

Snipet Tree View

These is some features that can make your job time better. Try use Flex Builder or install Flex plugin in your Eclipse and have a fun.