Global variable in as3

June 4, 2010 Leave a comment

in as2 when we going to use a global variable we just write _globl before the variable.

however in as3 due to it become OOP in writing style we have to follow it. that’s mean we can’t do that anymore

instead we create a class and then declare a variable inside it. since class can be access from anywhere.

for examlpe:

public class global

{

public var gv: string;

}

after that we can use it on anywhere to calling the class and it variable global.gv = “as3 is nice”;

Categories: Uncategorized

Introduction to Unity3D for creating 3D content on web

June 3, 2010 1 comment

i have been playing some 3D thingy for flash and suddenly come across a development tools called Unity. and it instantly become my favorite toy to play with. i mean in at least creating 3D content for web

As far as i know for 3D content, Unity is way way way better than flash’s any kind of 3D engine, and its sucks player.. please  put some effort on displaying 3D content Adobe ..i mean come on..even sony’s 3D tv is coming

Yes Unity has it own player which support 3D with super smooth frame rate. Not making you freak fall from chair you said? wait until you hear this

Unity 3D support all cutting edge 3D effect and physics you have seen in real game console nowadays..Lighting effects, Shader, Nvidia’s physic etc and it support many language to develop the interaction content like

Javascript, C++,C#, etc. ok ok now now if you haven’t fall from your chair or didn’t shout out omg, or jaw dropping on the floor than take a look of these example.

http://unity3d.com/gallery/live-demos/index.html#tropical-paradise (wait for it to install the unity player and right click to chose full screen if you like)

unity rockx

Categories: Uncategorized

Animate with Enter_Frame event in AS3

March 25, 2010 Leave a comment

Hi folks, in this post i’m going to show how to animate an object by using Enter_Frame in as3.

Beside commonly used tween class, or third party tweener Enter_Frame event constantly triggering according to the frame of the fla file per second.

In this post i created a Main document class and a circle class as the example, every time you click the circle the circle will move 200 in x-axis;

circle class:

package
{

import flash.display.Sprite;
import flash.events.*;

public class Circle extends Sprite
{
public function Circle()
{
this.addEventListener(MouseEvent.CLICK, movecircle);

}
function movecircle(e:MouseEvent)
{

this.addEventListener(Event.ENTER_FRAME, circleframe);

}
function circleframe(e:Event)
{
var i:int
this.x=this.x+10;

for (i=0; i<10; i++)
{

if(this.x == 200*i)
{
this.removeEventListener(Event.ENTER_FRAME, circleframe);

}
}
}

}
}

2. Main Document Class

package
{
import flash.display.MovieClip;

public class Main extends MovieClip
{
var circle:Circle = new Circle();
public function Main()
{
circle.x= 150;
addChild(circle);

}

}
}

As you can see what i’m done here, i just created an sweet little handy event handler called circleframe like any other events and execute the method

this.addEventListener(Event.ENTER_FRAME, circleframe);

along with its function:

function circleframe(e:Event)
{
var i:int
this.x=this.x+10;

for (i=0; i<10; i++)
{

if(this.x == 200*i)
{
this.removeEventListener(Event.ENTER_FRAME, circleframe);

}

If you want to stop it just remove it by using any condition.

As you test the movie the first click the circle only moved  50 in x-axis this is because we initiated the circle at 150 x position at the main document class.

Categories: Uncategorized

2 ways to instantiate and link document class in AS3

March 11, 2010 Leave a comment

ok folks, today i’m going show you 2 ways to link class in as3

Method 1: Instantiating in AS file and link from Document class
Method 2: Instantiating in fla’s file main time line

Method 1: Instantiating in AS file and link from Document class

On the new fla file make sure the name of the Document class ‘s name is same with the AS file class you’ve created, be note  that class name must be same with the AS file name. By using this way every object has to be instantiate in the as file.

Method 2: Instantiating in fla’s file main time line

This method will be using time line to instantiate the object in the AS file,  first create the class with its method but remember don’t link the Document class in FLA file with the AS file class,or you will get error, instead of that you have to make it on the time line.

is easy for example

first you create you class like normally you create but you don’t have to import flash classes.  because we’ll instantiate directly to the FLA’s time line. but how to link it you said? easy

just instantiate on the main time line with the ‘new’ keyword:

for expample-   var yourval:classname = new classname();

That’s it simple and easy hope you enjoy.

Categories: Uncategorized

scaleMode in AS2 and AS3

March 8, 2010 1 comment

There is abit little change on Scale mode in as3

In as2:

Stage.scaleMode = “noScale”;

In as3:

stage.scaleMode = StageScaleMode.NO_SCALE;

and remember to import the scale mode class in order to make it works

import flash.display.StageScaleMode;

Categories: Uncategorized

AMFPHP issue Function eregi_replace() is deprecated error

January 22, 2010 Leave a comment

Hi folks,

amfphp 1.9 beta was released quite a long time, and recently i installed it to my localhost with newer php version but guess what, there was a function error stated eregi_replace() is deprecated error, now thanks to Renato Moya who adressed the problem on his blog the problem can now be fix by just replacing: the file in /amfphp/core/shared/utils

$comment = eregi_replace("\n[ \t]+", "\n", trim($comment));
$comment = str_replace("\n", "\\n", trim($comment));
$comment = eregi_replace("[\t ]+", " ", trim($comment));

with

$comment = preg_replace("`\n[ \t]+`U", "\n",trim($comment));
$comment = str_replace("\n", "\\n", trim($comment));
$comment = preg_replace("`[\t ]+`U", " ",trim($comment));

that’s all. hope this help who have the same problem.

Categories: Uncategorized

Papervision with Augmented Reality / FLARToolKit…………..Part 1

November 26, 2009 Leave a comment

Hello folks, due to a job needed recently I’m playing with Augmented Reality with papervision.

I’m going to give some guide to create a simple 3D by using 3Dsmax studio and export it to collada file and implement to flash by using FLARTToolkit.

Augmented Reality is a technology that allows you to superimpose images into real-time environments by using a shape or symbol to recognize through webcam.

and papervision is a 3D flash engine.

To get a better idea what the Hell is that.. just watch the youtube video:

http://www.youtube.com/watch?v=vS6r5d-0hZ8&feature=related

Before get started make sure you have:

1.FLARToolKit you can download from here

http://saqoosha.net/lab/FLARToolKit/FLARToolKit-starter-kit.zip

2. FLAR marker generator (yes scroll down and search it):

http://www.adobe.com/devnet/flash/articles/augmented_reality.html

3. Collada exporter plugins for 3Ds max:

http://sourceforge.net/projects/colladamaya/

Lastly:

A printer or marker pen and paper :) Yes you can draw the symbol by yourself later on if you don’t have a damn printer like me.

That’s for today, part 2 will be start out soon enough i think….Uh mm.. Until then get your self prepare with those whatever.

Any experts are welcome to give comment for my tutorial. Cheers

Categories: Uncategorized

Freelancer Needs more Vitamin

November 24, 2009 Leave a comment

hey is that me?

Categories: Uncategorized

Paypal now support MYR (Malaysia Ringgit)

November 22, 2009 Leave a comment

Here is source and guide:

here

Categories: Uncategorized

Create a stunning and smooth popup using jQuery

November 20, 2009 Leave a comment

Hi folks, recently found a nicely done tutorial for creating smooth popup using jQuery (yup step by step, even your mother can get it done)

Here’s the link:

http://yensdesign.com/2008/09/how-to-create-a-stunning-and-smooth-popup-using-jquery/

Categories: Uncategorized
Follow

Get every new post delivered to your Inbox.