Aug
22
2011

SEO Expert Philippines

Enhance your business by hiring ME as a SEO in your website. If you want reliable and affordable SEO expert in Philippines, just contact me.

How expert am I:
“filipino flash developer” – Google, Yahoo, Bing
“filipino flex developer” – Google, Yahoo, Bing
“filipino html5 developer” – Google, Yahoo, Bing
“filipino iphone developer” – Google, Yahoo, Bing
“filipino android developer” – Google, Yahoo, Bing

Bookmark and Share
Aug
17
2011

AS3 Benchmark: Graphics.beginBitmapFill() vs BitmapData()

Just worked on a racing game…

It requires lots of graphics and bitmaps. I have just discovered the other way how to render bitmaps in the flash.

Before, I’m using BitmapData and insert it in Bitmap, then add it in the stage. Just a while ago, I tried to use the Graphics.beginBitmapFill(). First, I did some benchmark and this how it was:
- using BitmapData:

var bmpData:BitmapData = new BitmapData(100,100, false, 0x000000);
var bmp:BitmapData = new BitmapData(100,100, false, 0x000000);
for(var i:int = 0; i < 10000; i++){
	bmp.draw(bmpData);
}

- using Graphics.beginBitmapFill()

var bmpData:BitmapData = new BitmapData(100,100, false, 0x000000);
var shp:Shape = new Shape();
for(var i:int = 0; i < 10000; i++){
	shp.graphics.beginBitmapFill(bmpData);
	shp.graphics.drawRect(0,0,100,100)
}

This gave me 17ms for Graphics.beginBitmapFill() and 93ms for Bitmapdata()

So I’m suggesting now to use Graphics.beginBitmapFill() for bitmap patterns.

Bookmark and Share
May
4
2011

10 Things Senior Flash Developer Should Know

I thought my skills in Flash/Actionscript is for senior level.  I just realized that no matter how good you are in: actionscripts, designing, problem solving, math, etc., that doesn’t mean you are for seniority level. Because you should know how to manage/optimize your codes, how is the component/compiler works, you should be strict with your attitude in making back-ups of  your codes, clean up your codes as per other developer can read yours, and should know some simple terminologies. AND so as not to compare your skills to other Flash Developers. Be HUMBLE to accept their ideas/skills and be GENEROUS to share your ideas/skills.

Here is a guide to be a Senior Flash Developer (If this stuff is “old hat” to you,feel free to make critiques on  this listing and add more references in the comments):

1.      The Elastic Racetrack
You need to understand when events fire, when code is executed, and when the player renders. It’s really the foundational concept of Flash Player.
http://www.craftymind.com/2008/04/18/updated-elastic-racetrack-for-flash-9-and-avm2/

2.      FlexSDK, mxmlc, compc, and all that jazz
You need to know what’s going on when you hit that “run” button in Eclipse.
http://www.senocular.com/flash/tutorials/as3withmxmlc/
http://livedocs.adobe.com/flex/3/html/help.html?content=apparch_08.html

3.      Player Events, Custom Events, Event Bubbling
I can’t imagine where flash player would be without frames and mouse clicks.
http://www.adobe.com/devnet/actionscript/articles/event_handling_as3_03.html
http://livedocs.adobe.com/flex/3/langref/flash/events/package-detail.html
http://www.tink.ws/blog/custom-events-in-as-30-dont-forget-to-override-the-clone-method/
http://jacwright.com/blog/70/how-to-listen-to-flash-events-that-dont-bubble/

4.      Statements, Keywords, and Directives
You should never be surprised by a new “word” in as3. If you don’t know what “static” or “override” or others are, learn them.
http://livedocs.adobe.com/flex/2/langref/statements.html

5.      ASDoc
Someday, you’ll re-read your code and have no idea what it does. The stress here is on proper documenting, but generating asdocs is nice too.
http://livedocs.adobe.com/flex/3/html/help.html?content=asdoc_3.html

6.      Managing visual assets (images, fonts, CSS, etc)
Flash is visual. So you need to know how to manage assets with code.
http://www.gskinner.com/talks/flexlovesflash/
http://code.google.com/p/queueloader-as3/
http://code.google.com/p/bulk-loader/

7.      Arrays, Collections, Dictionaries, Mapping
You’re not just working with one MovieClip here, so you need to know how to control multiple objects at once.
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/Array.html
http://www.gskinner.com/blog/archives/2006/07/as3_dictionary.html
http://code.google.com/p/as3ds/

8.      Programmatic motion (tweening, easing)
If you wanted things to stay still, you should’ve stuck with HTML
http://blog.greensock.com/tweenmaxas3/
http://www.amazon.com/Foundation-Actionscript-3-0-Animation-Making/dp/1590597915/ref=sr_1_1?ie=UTF8&s=books&qid=1243014431&sr=8-1

9.      OOP and Coding Against Frameworks
The days of a one huge .as file are over. You need to smartly move your code into organized and reusable objects. Also, now there are plenty of popular as3 frameworks to help manage your code. Read up on them and start using one.
http://www.adobe.com/devnet/actionscript/articles/oop_as3.html
http://www.actionscript.org/resources/articles/684/1/Object-Oriented-Programming-in-AS3/Page1.html

10.  Version control
Unless you think your code is worthless, you need to learn how to back it up properly.
http://tortoisesvn.net/downloads
http://versionsapp.com/
http://en.wikipedia.org/wiki/Revision_control
http://git-scm.com/
http://www.nongnu.org/cvs/

Bookmark and Share
Dec
16
2010

Compile ActionScript file using mxmlc

Steps in compiling ActionScript file (.as) using mxmlc of Flex SDK.

Obtaining the Compiler
- To create SWF files from ActionScript, you will need a compiler, the program that interprets ActionScript code and translates it into the machine code used in SWF files. The compiler used to compile ActionScript or MXML is mxmlc.exe. mxmlc.exe can be downloaded free, just download the latest Flex SDK, and you will obtain the MXMLC.EXE.

MXMLC.EXE – can be found in SDK_PATH/bin/mxmlc.exe.

About mxmlc.exe

mxmlc.exe is a launcher that runs the MXML and ActionScript 3 compiler that converts MXML files (.mxml) and ActionScript 3 files (.as) into published SWF files (for the purposes of this tutorial, we will be primarily concerned with ActionScript 3 files though the compiler handles both as well as some other file types used in the ultimate generation of the SWF). The real compiler is a Java jar file located in the lib directory of your Flex Builder/SDK install and not mxmlc.exe itself. Because of this, to work with the compiler you’ll A) need to make sure you keep all of those files of which the compiler is dependant (i.e. dont go moving around just mxmlc.exe and expect it to work), and B) need to have the Java runtime environment installed on your system. If you’ve installed Flex Builder you won’t have to worry about this since it will take care of this for you. If you just got the SDK, however, and haven’t had Java installed on your computer, you can download and install the Java runtime environment from http://java.sun.com.

In the directory containing mxmlc.exe you may notice some other executables. compc.exe is for creating SWC files (pre-compiled component file), and fdb.exe is the command line debugger. Here we are sticking to just using mxmlc.exe which is all you need to get started using ActionScript 3.

For mxmlc command line options, just visit http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_13.html

How to compile ActionScript in mxmlc
- create a batch file. Here is a sample of batch file I used for compiling fonts.

C:\flex_sdk_4.1.0.16076\bin\mxmlc.exe -static-link-runtime-shared-libraries=true -o output.swf -source-path="C:\_cafepress\devtools\manila\fonts\src\" "C:\_cafepress\devtools\manila\fonts\src\font\Alepholon.as"

- the ActionScript file (I used Alepholon.as here)

package font
{
	import flash.display.Sprite;
	import flash.text.Font;
 
	/**
	 * Font library
	 * @author mykhel
	 */
	public class Alepholon extends Sprite
	{
 
		[Embed(source='../../lib/Alepholon.ttf'
		,fontFamily  ='Alepholon'
		,fontStyle   ='normal' // normal|italic
		,fontWeight  ='normal' // normal|bold
		,unicodeRange='U+0020-U+002F,U+0030-U+0039,U+003A-U+0040,U+0041-U+005A,U+005B-U+0060,U+0061-U+007A,U+007B-U+007E'
		,embedAsCFF='false'
		)]
		public static const fontClass:Class;
 
		public function Alepholon()
		{
			Font.registerFont(fontClass);
		}
 
	}
 
}

Note: This class is to embed font. I get this sample in one of the output file of automation tool in converting Font file (.TFF) into SWF that I have created.

- Run the batch file, and look for the output file. In my example, output file can be found in the directory of the batch file.

Download the sample files here.
Please note, I cannot include the Alepholon font, but you can try the other font. Play around with the batch file, change the path and options.

Original story here.

Bookmark and Share
Oct
27
2010

“Enter” key in input textfield

How to catch ENTER key in input textfield?

In AS3, we can’t just use:

inputText.addEventListener(Event.KeyboardEvent.KEY_DOWN, keyDownHandler);

Because, you can’t get any event from the regular TextField that would be fired when the ENTER key is pressed. You have to do work around…

One idea would be to listen the textfield for focus events. When it has focus, you add a listener to the stage for key board events and check if the pressed key is ENTER, if so fire your action, else skip.

AS3:

inputText.addEventListener(FocusEvent.FOCUS_IN,textInputHandler);
inputText.addEventListener(FocusEvent.FOCUS_OUT,textInputHandlerOut);
 
function textInputHandler(event:FocusEvent):void {
    //our textfield has focus, we want to listen for keyboard events.
    stage.addEventListener( KeyboardEvent.KEY_DOWN, keyDownHandler);
}
 
function textInputHandlerOut(event:FocusEvent):void {
    //our textfield lost focus, remove our listener.
    stage.removeEventListener( KeyboardEvent.KEY_DOWN, keyDownHandler);
}
 
function keyDownHandler( e:KeyboardEvent ):void{
    //a key was pressed, check if it was Enter => charCode 13.
    if( e.charCode == 13 ){
      //ok, enter was pressed. Do your thing.
      trace("We pressed enter, doSomething" )
    }
}
Bookmark and Share
Jul
21
2010

Adding Like Facebook Button with Dynamic Link

You wanna go to facebook Like button. This facebook developer’s site, will teach us how to simply generate a code and copy and paste it in our website.

Just wanna share how this can be dynamically created. Using iframe, php, and javascript code :D

This is how I did it.

<iframe src="http://www.facebook.com/plugins/like.php?href=<?php $url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
echo $url; ?> &amp;layout=button_count&amp;show_faces=true&amp;width=180&amp;action=like&amp;font=arial&amp;colorscheme=dark&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:180px; height:21px;" allowTransparency="true">
</iframe>

Just copy and paste it anywhere your pages are. I test it using IE, FF, and Chrome using Windows 7. (I don’t care with other platforms.)

Hope this can help.

Bookmark and Share
Jul
21
2010

How to install Android SDK and play with Android 2.0 in the emulator

1)      Download appropriate file for your system from http://developer.android.com/sdk/index.html

2)      Extract to desired location

3)      Run “SDK Setup.exe” (or the equivalent for your system)

a.       If you receive an error message stating “Failed to fetch url…” then you will have to force the Setup program to use http in lieu of https.

i.      Close the “Refresh Sources” window

ii.      Cancel the “Choose Packages to Install” window

iii.      Select “Settings” from the left side of the “Android SDK and AVD Manager” window

iv.      Check the box labeled “Force https://… sources to be fetched using http://…”

v.      Click “Save and Apply”

vi.      Close and restart the SDK Setup program

a.       If you are only interested in trying out the Android 2.0 Emulator

i.      Reject everything except “SDK Platform Android 2.0. API 5, revision 1” by selecting each item then selecting the Reject option

b.      If you plan to develop Android applications and Games, you may wish to Accept All

c.       Click “Install Selected”

(Since I’m new in Android, I chose “Accept All”, because I’m not sure which thing should be installed. I don’t advise to choose “Select All”.)

5)      Allow the selected packages to download and install then close the “Installing Archives” window

6)      Create a new Android Virtual Device (AVD). Go to Virtual Devices at the left menu, and then click New button.

a.       Select “Virtual Devices” from the left side of the “Android SDK and AVD Manager” window

i.      Click “New”

ii.      Enter a Name

iii.      Choose a Target

iv.      Enter a size for the emulated SD Card

v.      Choose a Skin

1.      To emulate current hardware such as the G1, MyTouch 3G, Hero, etc…

a.       Leave the default value

2.      To emulate the Motorola Droid

a.       Choose WVGA 854

3.      To emulate other devices

a.       Choose anything else

vi.      Click “Create AVD”

7)      Start your newly created Virtual Device

a.       Choose the Virtual Device from the list

b.      Click “Start…”

c.       Click “Launch”

8)      Just wait the android takes for a while to setup complete. This depends on the user’s machine. (will look for tweaking solutions to solve this issue)


9)      After setup complete! :D


Testing my facebook using Android Emulator.

Credits to http://androidandme.com


Bookmark and Share
Jul
15
2010

Dynamic TextField with Particle Effect

I have finished a dynamic TextField with particle effect using AS3. I have tested some particle effects, but never came out a very good output.

Rollover on the TEXT and you will see a very good effects. :D

Hope you like it.

In my POV, to create a very good particle effects it requires deep imagination and very good problem solving. In my experience, I encountered lots of physics computations and mathematical expressions to come out a very good solutions or formulas like this. I hope this will be the beginning of lots of very good particles.

For source code, click here. I just used single class here. :D

Bookmark and Share
Jul
8
2010

How to create an email form with ActionScript 3

Problem

How to create an email form in AS3 without any redirection to a mail application, such as Mail (mac) or MS Outlook… Have the form and the confirmation all in the same flash.

Solution

First you need to be aware of your server and back-end script capabilities. I’m using my host which runs PHP (which is probably the only language I am comfortable writing in and there are tons of resources online) Then, I am considering factors such as: People may send emails not using real emails so you will possibly need to add validation. To get started: We are going to use AS3 but we are also going to use PHP as back-end. Everything else is done in one swf.

Detailed explanation

I made two movieclips that I used as buttons: sendbtn and resetbtn .

I created input fields called: yourName , fromEmail, yourSubject and YourMsg.

They post the variables: name, from, subject and msg to the PHP.

/*************************************
Buttons
**************************************/ 
 
sendbtn.buttonMode = true;
 
sendbtn.addEventListener(MouseEvent.CLICK, submit);
 
resetbtn.buttonMode = true;
 
resetbtn.addEventListener(MouseEvent.CLICK, reset); 
 
/*************************************
Variables needed
**************************************/  
 
var timer:Timer; var varLoad:URLLoader = new URLLoader;
 
var urlRequest:URLRequest = new URLRequest( "mail.php" );
 
urlRequest.method = URLRequestMethod.POST;
 
/*************************************
Functions
**************************************/ 
 
function init():void{
 
	//Set all fields to empty
 
	yourName.text = "";
 
	fromEmail.text = "";
 
	yourSubject.text = "";
 
	YourMsg.text = "";
 
}
 
function submit(e:MouseEvent):void
{
 
	//Check to see if any of the fields are empty
 
	if( yourName.text == "" || fromEmail.text == "" ||
		yourSubject.text == "" ||YourMsg.text == "" ) { 
		valid.text = " All fields need to be filled.";
	}
 
	//Check if you're using a valid email address
 
	else if( !checkEmail(fromEmail.text) )
 
	{ 
		valid.text = "Enter a valid email address"; } 
 
	else { 
		valid.text = "Sending over the internet...";
 
		var emailData:String = "name =" + yourName.text + 
							" from = " + fromEmail.text + 
							" subject = " + yourSubject.text + 
							" msg = " + YourMsg.text;
 
		var urlVars:URLVariables = new URLVariables(emailData);
		urlVars.dataFormat = URLLoaderDataFormat.TEXT;
		urlRequest.data = urlVars; varLoad.load( urlRequest );
		varLoad.addEventListener(Event.COMPLETE, thankYou );
	}
}
function reset(e:MouseEvent):void
{
	init(); //call the initial clear function
}
function checkEmail(s:String):Boolean 
{
 
	//This tests for correct email address
 
	var p:RegExp = /(\w|[_.\-])+@((\w|-)+\.)+\w{2,4}+/; var
	r:Object = p.exec(s);
	if ( r == null )
	{
		return false;
 
	}
 
	return true;
 
}
 
function thankYou(e:Event):void {
	var loader:URLLoader = URLLoader(e.target);
	var sent = new
	URLVariables(loader.data).sentStatus; if( sent == "yes" )
	{
		valid.text = "Thanks for your email!"; timer = new Timer(500);
		timer.addEventListener(TimerEvent.TIMER, msgSent);
		timer.start();
	}
	else 
	{
		valid.text = "Oh no! Something is wrong! Try again..."; 
	}
}
 
function msgSent(te:TimerEvent):void 
{
	if ( timer.currentCount != 10 ) 
	{ 
		init();
		timer.removeEventListener(TimerEvent.TIMER, msgSent);
	}
 
}

————-

PHP file called mail.php with the code:

<?php 
$yourEmail = "yourEmailAddress@yourdomain.com"; // This will be your email address so please change this
 
$ipAddress = $_SERVER['REMOTE_ADDR']; // This gets the user's ip Address
 
$emailMsg = "Name: $yourName sent this from IP:
$ipAddress\n\nReturn Email: $sender
\n\nSubject:$yourSubject\n\nMessage:\n\n$YourMsg \n\nThis email was
sent using
a form on your site";$return = "From: $sender\r\n" .
"Reply-To:$sender \r\n" ."X-Mailer: PHP/" . phpversion();
 
if( mail( $yourEmail, "$yourSubject", $emailMsg, $return))
{
echo "sentStatus=yes"; 
}
 
else { echo "sentStatus=no"; } }
?>

emailer.zip *remember to change your email address in the PHP where it says

yourEmailAddress@yourdomain.com

Original link at Adobe, click here.

Bookmark and Share
Jun
22
2010

Color Spectrum Chart AS3

Color Spectrum Chart is a AS3 tool for creating different types of color spectrum chart. It is very useful for custom color picker. This class includes ColorUtils class, another class which is useful in manipulating colors.

This is PURE CODE and PURE CALCULATION, using pixels and arrays. Absolutely no images embeded. This only requires 2-kb of filesize, and the speed is well analyzed and it is very fast.

I have no liable in other color spectrum charts or others. This class is purely coded and no tools, besides with FlashDevelop, has been used. I’m sharing this to others with no charge. Again, The images (Bitmap) that comes out after finishing this tool was not intended to copy with the others. It is only how it was output by the algo.

The AS3 file is documented well, and will easy to be use by other developer. The tutorials is in the class itself as well as in the ColorUtils class.

Source code here. (used FlashDevelop, if using Flash IDE/FLEX, just copy the src foloder and use the Main.as)
Demo here.

Bookmark and Share