`

Thursday, September 30, 2010

Everything you want to know about the Adobe 9A0-082 exam

Author: Jenny

Q. What is the Adobe Flex 3 with AIR exam?

A. The 9A0-082 Adobe Certified Expert (ACE) certification is
developed for programmers, web applications developers, and
other development professionals who want to demonstrate
proficiency with single or multiple Adobe products. The exam
consists of 50 multiple-choice questions and it costs
approximately $150, and is administered by Pearson VUE.

Q. What are the areas on which the exam is focused?
A. The 9A0-082
exam tests the knowledge and skills of a candidate for using
Adobe Flex 3 software. It recognizes a candidate's ability to
use the features and functions of the software to Creating a
User Interface (UI), Flex system architecture and design,
Programming Flex applications with ActionScript, etc.

Q. What are the prerequisites for the Adobe Flex 3 with AIR
exam?
A. There are no prerequisite for the Adobe
Flex 3 AIR exam

Q. What are the benefits to becoming an Adobe Flex 3 with
AIR?
A. On successful completion of the exam, you
will be an Adobe Certified Expert (ACE), Adobe Flex 3 with AIR.

Q. How many questions are asked in the test? A.
There are 50 questions asked in the Adobe
9A0-082 test.

Q. What is the duration of the test? A. The
duration of the 9A0-082 exam is 85 minutes.

Q. Which type of the test is it? (Adaptive/Linear)
A. The 9A0-082 exam is in linear format.

Q. What is the passing score? A. The passing
score is 67%.

Q. What is the test retake policy? A. If you fail
in the 9A0-082 exam, you will have to purchase a new exam
voucher to retake the exam. There is no wait time fixed between
the two attempts.

Q. Where to take the test? A. Adobe exams may be
taken at Pearson VUE . There are more than five thousand
authorized testing centers in many countries. You can register
your exam in any center by phone, on the Web, or in-person.

Q. How do I register for an Adobe Flex 3 with AIR exam?
A. After you purchase your exam voucher, you can contact
an authorized Prometric or Pearson VUE center to schedule your
exam date, time, and location. You can book the exam within one
year from the date of purchase of the voucher. The exam date may
depend on your choice (and availability of slot) in your
selected test center.

Q. What is the exam retake policy? A. If you do
not pass in the 9A0-082
exam, you will have to purchase a new exam voucher to retake
the exam. There is no wait time fixed between the two attempts.

Q. When will I get my certification kit? A. Your
score is automatically reported to Adobe. On successful
completion of the exam, you will receive your Welcome Kit within
two to four weeks from the date you pass the exam.

About the author:
Jenny Ford works as a Marketing Manager for uCertify.

Tuesday, September 28, 2010

SWF to MP4-Convert SWF to MP4 Video

Author: Athna

Article:
SWF to MP4 Video Converter Pro is
a handy utility Pro SWF to MP4
Converter
that can perfectly convert SWF to MP4 Video and
Audio format files. With it, you can convert SWF to video or
audio from local computer and from internet by adding its URL
directly. - SWF to MP4 ( iPod Video Movie, iPod Touch Movie,
Creative Zen Player Video, PSP Movie, Apple TV Movie, iPhone
Video)With no problem referred to audio distortion, loss of
frames, audio and video asynchronization for editing software,
DVD/TV and portable devices.

More important, this SWF to MP4
provides a great solution to animation masters, video designers
and individuals to create attractive websites, process further
editing in Adobe Premiere and explore the depth of digital
world, as this SWF to Video Converter support to convert SWF to
AVI video with alpha, generate 32 bits RGBA file, offer manual
mode for interactive Flash conversion, etc.

SWF to iPad MP4 Converter is the unparallelled SWF
decoder to show Flash SWF contents on iPad. It provides a
brilliant solution to convert Flash SWF format to iPad
compatible MP4, H.264 format with swift conversion speed and
terrific output quality.

Key Features of the SWF to MP4 Video Converter Pro:

* Convert SWF to iPod / PSP movie (MP4) and Support iPod /
PSP-compatible codecs such as H264, and MPEG4

* Realize Alpha Channel of original SWF files in generated video

* Convert SWF to AVI with RGBA alpha channel

* Convert SWF to AVI video, FLV, MPEG, 3GP, DV, GIF,

* Support all compression codecs installed in Windows system,
such as 3ivx, DivX, and Xvid, etc

* Support recording audio and ripping audio of MP3 format in an
independent file, Support ActionScript.

* Enabling users to interact with Flash content during
conversion

* Let users easily crop an area of a SWF picture to convert or
convert the full area of a SWF picture

* Enable users to set the beginning and ending for the created
video and effectively control conversion process

How to convert animated gif to swf

Author: 789soft


Gif to swf converter help you to convert the animated GIFs into
popular Macromedia's (now Adobe) SWF file format. You can use
the produced SWF files as banners for your web site. extract the
individual frames out of the animated GIFs.

GIF to SWF Converter is currently best and wonderful gif to swf
converting software. With this software, you can easily convert
your photos, pictures (.gif) to . swf format to make your own
Flash Slideshow on your website or your Myspace

Convert animated GIF to Flash SWF .Convert to BMP,TIFF,JPEG, PNG
image series. Capture a frame to a bmp,jpeg,gif,tiff,png file .

Convert to BMP,TIFF,JPEG, PNG image series. Capture a frame to a
bmp,jpeg,gif,tiff,png file Frame by frame: This mode runs Gif
frame by frame, and is suitable for batch converting.

Gif To Swf Converter is an easy-to-use program that allows users
to convert GIF images into Flash files. The program works,
mostly, but it doesn't have a lot of features, and it isn't
entirely clear about the ones it does have.

Gif To Swf Converter's interface is fairly plain, with buttons
for selecting one or more images or directories of images for
conversion. We like the program's preview pane, which displays
each animated GIF before conversion, if you want it to. Gif To
Swf Converter is quite simple to use: You specify whether you
want to resize the image or images, change the frame rate if
needed, and click then "Convert." The program quickly converts
the images to SWF files and stores them in your chosen
destination folder. This seems to be the extent of Gif To Swf
Converter's bag of tricks; although the software's built-in Help
file mentions that it's possible to capture a frame from an
animated GIF and save it in another format, neither the
interface nor the Help make it clear how to do this. We tried to
figure it out on our own, but unfortunately we crashed the
program in the process.

on this page http://www.789soft.com/gif-to-swf-converter.html

About the author:
789soft is a professional gif converter and swf Converter and
gif converter tools provider for Windows,It is one of the very
few developers that have a full range of high-quality Windows
multimedia software programs.

Monday, September 27, 2010

validating email address in as3

In this tutorial we will learn how to creating RegExp Validation

this is the code.


var bool:Boolean;
var str:String = "";
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 onClick(event:Event):void
{
    str=input_txt.text;
    if (str.length > 1)
    {
        bool = (checkEmail(str));
        if (bool)
        {
            output_txt.text = "Thank You !";
        } else
        {
            output_txt.text = "Invalid E-mail";
        }
    } else
    {
        output_txt.text = "Please Enter your E-mail !";
    }
    str="";
}

check_mc.addEventListener(MouseEvent.CLICK, onClick);


Preview

Download .zip

Sunday, September 26, 2010

Webcam in AS3

When using the Camera, you cannot always expect the default camera object to work when using.

var myCam:Camera = Camera.getCamera();

Sometimes you need to access a different camera object in your hardware setup.  This is true when using my MBP, the default DV Camera object just doesn’t work.  Now the API suggests that you can access a camera object name from the array in”
var names:Array = Camera.names;
However trying to access a camera object via this API yields null.

var names:Array = Camera.names;
var myCam:Camera = Camera.getCamera(names[i] as String);

instead you must use this syntax:

var names:Array = Camera.names;
//where i is the index, not the array index value
var myCam:Camera = Camera.getCamera(String(i));

iforIndia Connected Hearts

*~*~*~*~*~*~*~*~*~*~*~*~*~**~*~*~*~*~*~*~*~*~*~*
                        .-"""-.    .-"""-.
                       /       '..'       \
                .-"""-;    .-"""-.         |
        _      /       `..'       \        |
     .-' /    |                    |      /  /////
    <   (==========)               | (======<<<<<
     '-._\     \      iforIndia   /    /`    \\\\\
                \    Connected   /   /'
                 `\    Hearts  /'  /'
                   `\        /'`\/'
                     `\    /'
                       `\/'
*~*~*~*~*~*~*~*~*~*~*~*~*~**~*~*~*~*~*~*~*~*~*~*

Shuffle Array in AS3

Here's an AS3 class called ExtendedArray that unsurprisingly extends the functionality of the Array class. One important thing to note is that it is a dynamic class. This allows you to add properties and methods to the base class at runtime.

Another thing to note is looping through the optionalArgs (or "rest" arguments as they're known) and using super.push() to populate the Array in the constructor. Simply using super(optionalArgs) would create an array within the Array i.e. a 2d array.

here is the code.


package 
{
    dynamic public class ExtendedArray extends Array;
    {
        public function ExtendedArray(... optionalArgs)
        {
            for each (var value:* in optionalArgs)
            {
                super.push(value);
            }
        }

        public function shuffle(startIndex:int = 0, endIndex:int = 0):Array
        {
            if (endIndex==0)
            {
                endIndex=this.length-1;
            }
            for (var i:int = endIndex; i>startIndex; i--)
            {
                var randomNumber:int=Math.floor(Math.random()*endIndex)+startIndex;
                var tmp:* =this[i];
                this[i]=this[randomNumber];
                this[randomNumber]=tmp;
            }
            return this;
        }
    }
}


You could add many more functions to this to increase the functionality of the base Array class.

smoothing shapes in Flash

This is a quirk of Flash, which has caught me out a few times. If you're drawing a rounded rectangle with an internal fill colour and a stroke (outline) of 3 pixels, for example, then you get a rather jagged apperance between the fill colour and the stroke.

If you zoom into the shape, all looks fine and smooth, but zooming back to 100% the problem appears again.

To solve this, you must select the stroke (outline) of the shape - double click it to make sure all of it is selected. Then choose Modify > Shape > Convert Lines to Fills.

This solves the problem and your shape now looks smooth.

Saturday, September 25, 2010

Flash Fullscreen !

Here's a class that lets you go fullscreen quite simple.

Create a MovieClip in your document with two frames ('ON' and 'OFF 'mode') with
stop();
on the first frame. Remove it from the stage and in your library fill in 'FullScreenToggle' as the Class linkage.

Then instantiate this class from within your document class like this:

var fullscreen: FullScreen = new FullScreen(this.stage, 20, 400);
This works in the stand alone flash player or exe file. To make it work in the browsers too.

Friday, September 24, 2010

Replacing Strings in AS3

Although this may be pretty basic - when it comes to dealing with strings, one of the most valuable methods is no doubt the split().join().
So let’s first go over split().
This is from adobe’s live docs:
split(delimiter:String, [limit:Number]) : Array
Split has two Parameters:
delimiter:String - A string; the character or string at which my_str splits.
limit:Number [optional] - The number of items to place into the array.
Ok - don’t get confused. Essentially if you have the string:

var myString:String = % B % C % D % E % F;

The first parameter (delimeter) is whatever character(s) you want to use for splitting the other characters up. So:

trace(myString.split(%)); // outputs the array , B , C , D , E , F 

The second parameter basically tells split how many times you want to do it.
trace(myString.split(”%”, 4) // outputs: B , C , D
So a few really cool applications of this are:
  1.  using it to parse out data.
  2. using it to replace or remove a string.

Let’s say you have some external data you are loading in - but you don’t want to use XML for some reason. You can separate your content by inserting a weird string of characters between your content:

var theContent:String = this is some content #%?and some more #%?
var contentArray:Array = theContent.split(#%?);
trace(contentArray); // outputs: this is some content , and some more 

The other option - the real money maker - is split().join()
This is the easiest way to replace things in a string.
for removal:

var theContent:String = this is some content #%?and some more #%?
theContent = theContent.split(#%?).join(“”);
trace(theContent); // outputs: this is some content and some more  

For replacing strings:

var theContent:String = I hate when content has words like, ‘damn’ in it
theContent = theContent.split(damn).join(darn);
trace(theContent); // outputs: I hate when content has words like, ‘darn’ in it  

Importing external images using AS3

Today we will learn how to load an external image into flash using
Actionscript 3 and then work with it.

Say, we need to load a picture from a site, change its size and place
it in the upper left corner, placing it behind all existing objects on the
stage. First we need to create a Loader:

var imageLoader:Loader = new Loader(); 
'Feed' it the url to the picture:

imageLoader.load(new URLRequest("http://www.blueidea.com/
articleimg/2006/08/3904/images/image-2.jpg"));

Actionscript display list

When an event occurs, it moves through the three phases of the event flow: the capture phase, which flows from the top of the display list hierarchy to the node just before the target node; the target phase, which comprises the target node; and the bubbling phase, which flows from the node subsequent to the target node back up the display list hierarchy.

Thursday, September 23, 2010

as3 animated mouse cursor

In this lesson, let’s see how to build an animated mouse cursor

First, make a movieclip, give it an instance name of 'cursor_mc', draw any kind of arrow inside it and now for the code:

Mouse.hide(); // hide the default mouse cursor..

stage
.addEventListener(Event.ENTER_FRAME, onMove);

//This creates a listener on the stage, the event is Event.ENTER_FRAME, which is the new on.EnterFrame function, the listener calls the moveMouse function constantly because of it.

function onMove(event:Event) {
    cursor_mc.x = mouseX;
    cursor_mc.y = mouseY;

    //This sets the position of the cursor,

}

This is the end of the function.


Testing it should hopefully give you a working custom cursor.

Hope this helps and works.

Preview

Download .zip

Tuesday, September 21, 2010

Replacing Strings in AS3

Although this may be pretty basic - when it comes to dealing with strings, one of the most valuable methods is no doubt the split().join().
So let’s first go over split().
This is from adobe’s live docs:
split(delimiter:String, [limit:Number]) : Array
Split has two Parameters:
delimiter:String - A string; the character or string at which my_str splits.
limit:Number [optional] - The number of items to place into the array.
Ok - don’t get confused. Essentially if you have the string:

var myString:String = % B % C % D % E % F;

The first parameter (delimeter) is whatever character(s) you want to use for splitting the other characters up. So:

trace(myString.split(%)); // outputs the array , B , C , D , E , F 

The second parameter basically tells split how many times you want to do it.
trace(myString.split(”%”, 4) // outputs: B , C , D
So a few really cool applications of this are:
  1.  using it to parse out data.
  2. using it to replace or remove a string.

Let’s say you have some external data you are loading in - but you don’t want to use XML for some reason. You can separate your content by inserting a weird string of characters between your content:

var theContent:String = this is some content #%?and some more #%?
var contentArray:Array = theContent.split(#%?);
trace(contentArray); // outputs: this is some content , and some more 

The other option - the real money maker - is split().join()
This is the easiest way to replace things in a string.
for removal:

var theContent:String = this is some content #%?and some more #%?
theContent = theContent.split(#%?).join(“”);
trace(theContent); // outputs: this is some content and some more  

For replacing strings:

var theContent:String = I hate when content has words like, ‘damn’ in it
theContent = theContent.split(damn).join(darn);
trace(theContent); // outputs: I hate when content has words like, ‘darn’ in it  

Monday, September 20, 2010

Page print with AS 3.0

In this  tutorial, let’s see how we can print the content  using the PrintJob class
  • First Create a new flash file and save it as PrintTest.fla
  • Create the content that you want to print . 
  • Convert the whole content into a movie clip and give it an instance name of “page_mc”. 
Note :you must have a moveclip to print (i.e. if you want to print a text field, put it in a movieClip
  • And create the print button. Give it an instance of "printBtn_mc".
  • Finally create the “actions” layer. Open the actions panel.
    Type the following code.
|| ----------------------------------------------------------------------- ||


import flash.events.MouseEvent;
import flash.printing.PrintJob;
import flash.geom.Rectangle;

//  on Print function

function onPrint(event:MouseEvent):void{
    //a variable to hold new print job
    var pj:PrintJob = new PrintJob();
   
    // display Print dialog box, but don’t start the print job unless .start() returns successful
    var result:Boolean = pj.start()
   
    if(result){
        // add specified page to print job
        try{
            var rect:Rectangle = new Rectangle(page_mc.x, page_mc.y,page_mc.width, page_mc.height)
            pj.addPage(page_mc, rect, null, 0);
        }
        // in case an error pops up (i.e. printer not connected). warn the user to try again
        catch(event:Error){
            trace("unable to Print");
        }
    }
    // calls to addPage() was successful. You should always check for successful
    pj.addPage(page_mc)
    // Finally  calling send().
    pj.send()
}

printBtn_mc.addEventListener(MouseEvent.CLICK, onPrint);


|| ----------------------------------------------------------------------- ||

Preview

Download .zip

Sunday, September 19, 2010

Detecting focus on Flash using AS3

Sometimes it is needed to tell whether the user is focused on the Flash or not... in this tutorial, you will learn how to do that using AS3.

We need to create 2 listeners - one for focusing in, and one for focusing out. These events are called Event.ACTIVATE and Event.DEACTIVATE.

stage.addEventListener(Event.ACTIVATE,  inFocus);
stage.addEventListener(Event.DEACTIVATE, outFocus);

Now we need to show the user that he is focused out or in. Usually, this toggles the pause menu in Flash game, so that if a person focuses on something else, he will see that the game is paused and then proceed to click it to focus on it.

here is the example code:

function inFocus(event:Event){

     ball_mc.play()

}
function outFocus(event:Event){

     ball_mc.stop();

}


Preview

Download .zip

Saturday, September 18, 2010

Rotating BitmapData with Actionscript 3

Here’s a little snippet – rotating BitmapData (through 90 degrees) with Actionscript 3.

|| -----------------------------------------------------------  ||


var bd:BitmapData;
var bmp:Bitmap;

var matrix:Matrix = new Matrix();

var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
loader.load(new URLRequest("right.png"))


function imageLoaded(event:Event):void{
    bd = new BitmapData(loader.content.width,  loader.content.height, true, 0x000000);
   
    matrix.translate(-bd.width / 2, -bd.height / 2);
    matrix.rotate(180 * (Math.PI / 180));
    matrix.translate(bd.height / 2, bd.width / 2);

    bd.draw(loader, matrix);
    bmp = new Bitmap(bd);
    bmp.x = stage.stageWidth / 2 - bmp.width / 2;
    bmp.y = stage.stageHeight / 2 - bmp.height / 2;
    addChild(bmp)
   
}

||  ---------------------------------------------------------   ||
 
 
The code above can rotate an images BitmapData, using a Matrix to transform the image when you draw the data.  It’s only really designed to rotate the image in 90 degree increments though – so be aware of that.
How it actually works is to create a new Matrix object, offset the source BitmapData’s width and height (so the rotation goes from the center of the bitmap), rotate the BitmapData, move the BitmapData again (to undo the previous offset), create a new BitmapData object to draw the rotated BitmapData into, and finally draw the source BitmapData with our newly created Matrix.
 


Preview 

Download .zip

Friday, September 17, 2010

Functions Definition

Functions are blocks of code that carry out specific tasks and can be reused in your program. There are two types of functions in ActionScript 3.0: methods and function closures. Whether a function is a called a method or a function closure depends on the context in which the function is defined. A function is called a method if you define it as part of a class definition or attach it to an instance of an object. A function is called a function closure if it is defined in any other way.
Functions have always been extremely important in ActionScript. In ActionScript 1.0, for example, the class keyword did not exist, so "classes" were defined by constructor functions. Although the class keyword has since been added to the language, a solid understanding of functions is still important if you want to take full advantage of what the language has to offer. This can be a challenge for programmers who expect ActionScript functions to behave similarly to functions in languages such as C++ or Java. Although basic function definition and invocation should not present a challenge to experienced programmers, some of the more advanced features of ActionScript functions require some explanation.

Data types

ActionScript primarily consists of "fundamental" or "simple" data types
which are used to create other data types. These data types are very
similar to Java data types. Since ActionScript 3 was a complete rewrite
of ActionScript 2, the data types and their inheritances have changed.


  • String - A list of characters such as "Your Name"
  • Number - Any Numeric value
  • int - The int data type is a 32-bit integer between -2,147,483,648
and 2,147,483,647.
  • uint - The uint (Unsigned Integer) data type is a 32-bit unsigned
integer between 0 and 4,294,967,295.
  • Boolean - A simple binary storage that can only be "true" or "false".
  • Object - Object is the data type all complex data types inherit from.
It allows for the grouping of methods, functions, parameters,
and other objects.
  • Null - The Null data type contains only one value, null. This is the
default value for the String data type and all classes that define complex
  • void - The void data type contains only one value, undefined. In previous
versions of ActionScript, undefined was the default value for
  • Date - A date object containing the date/time digital representation.
  • Error - A generic error object that allows runtime error reporting when
thrown as an exception.
  • Function - The core class for all Flash method definitions.
  • RegExp - A regular expression object for strings.

And so on..

Thursday, September 16, 2010

Actionscript 3 array tutorial

In this tutorial we will learn to make and using arrays with actionscript 3.0 .

This is the first lesson so we will talk about what arrays are, how to use them,
and make our own simple one dimensional array.


What is an array?

An array is kind of a data type, like a string, variable and so on, which means
its purpose in life is to contain data. An array is usually made to contain more
then one information, like a list of information. We could load a list of objects
into and array.

One thing I use arrays to a lot is to hold data sets from a database, or an
xml file, so I can close my database connection after the data is loaded,
and only needs to call the array data when needed. Its much easier and
much faster, I will get into that in one of the more advanced array lessons.
How to make and use an array?

Now here is how to declare a simple array list, and put some simple one
dimensional data into it.

This is the most simple form of an array, here is an example.



var myArray:Array = ["google", "yahoo", "orkut"];

trace(myArray[0]);
trace(myArray[1]);
trace(myArray[2]);



What we did here was to declare a variable with the name “myArray”
and give it 3 data items, google, yahoo and orkut.

You may have noticed how easy it is to trace an array item just by calling
the myArray[index].

If you think this was simple, just wait to see how simple it is to add items
and much more.




myArray.push("msn");

That”s it, now lets bring it all together, lets try to add
a couple of items to the list, then output all the items
with a loop, we will count how many items the array holds,
then loop through each item.

var myArray:Array = [];

myArray.push("google");
myArray.push("yahoo");
myArray.push("orkut");
myArray.push("msn");
myArray.push("ask");
myArray.push("facebook");

for(var i:uint = 0; i < style="color: rgb(51, 51, 255);">length; i++)
{
trace(myArray[i]);
}


This will output all items >> goolge, yahoo, orkut, msn,
ask, facebook



ActionScript 3 Tweens Tutorial

In this tutorial I’ll be using the Tween Classes already bundled in Flash Cs3.
There are other ways to do this but I find it’s the easiest. You could do the
same using onEnterFrames or Timers.

Ok first thing you will need to do is to draw a circle on the stage and then
convert that shape to a movie clip. After that, give it an identifier name in the
property inspector. Let’s name it “ball_mc”. Now open the actionScript
Window by pressing F9. Create a new layer on the timeline, name it actions,
and start writing your actionscript there. The first thing we will need is to
import the actual classes for tweening. Add these to line of code at the start.

import fl.transitions.Tween;
import fl.transitions.easing.*;


The first line is to import the Tween, the second one is to import
the Easing classes.
Now all we need to do is add one line of code to make the ball_mc move.


var xTween:Tween = new Tween(ball_mc, "x", Strong.easeOut, 0,
300, 3, true);

This create a new tween object with its properties in the parenthesis. The first parameter is the object you want to animate. The second parameter is the property of that object that you want to animate. You can animate a lot of properties for a display object example: x, y, alpha, width, height, xscale, yscale, rotation etc. I’ll give some example later. The third parameter is easing. Fourth and fifth parameters are the starting and ending position of the property you are animating in this case, the rectangle will go from the x position 0 to the x position 500. The sixth parameter is the duration of the tween, in this case 5 seconds. And lastly the last parameter is if you want to use seconds or frames. I’ve always left that to true meaning use seconds, that way if you change the framerate of your movie, it doesn’t change the timing of your animation.

So if you test your movie, your ball_mc will go from left to right in 5 seconds. Pretty boring, but it’s your first animation. What we can do next is affect more than one property at the time. But for that, we have to create a new tween for each property we want to affect.


var xTween:Tween = new Tween(ball_mc, "x", Strong.easeOut,
0, 300, 3, true);

var alphaTween:Tween = new Tween(ball_mc, "alpha", Strong.easeOut,
0, 1, 3, true);

var widthTween:Tween = new Tween(ball_mc, "width", Strong.easeInOut,
ball_mc.width, ball_mc.height + 600, 7, true);

var rotationTween:Tween = new Tween(ball_mc, "rotation",
Strong.easeInOut
, 0, 90, 5, true);



So here our ball_mc in, moves to the left, becomes wider and
turns right. Two things to see here. First the alpha property
doesn’t work like in actionScript 2. Before, it ranged
from 0 to 100; in ActionScript 3, it ranges from 0 to 1.
It’s a minor difference, but you have to know it. Also as
you can see with the width tween, you can put variables in
the fourth and fifth parameters so that you don’t really know
the beginning and ending values.

see preview.
Download .zip

Clear text field when focused on

If you are making an input text field, it's often needed to add hints, such as "Enter your name here" and "Enter your email", etc. If you are a good programmer, you will make this default text dissapear when the field is clicked, like in this example:

Click here to view Preview

The code is quite small and easy to understand.

var startingText = "Enter your text here!";
name_txt.text = startingText;
name_txt.addEventListener(FocusEvent.FOCUS_IN, checkTheText);

function checkTheText(event:FocusEvent):void{
if(name_txt.text == startingText){
name_txt.text="";
}
}


First we enter the default text we want to show, then apply it
to our text field (in this example - an input field with
instance "name_txt"). When the user focuses on the text field,
the default text dissapears.

Download .zip

AS3 Append Text..!

Say, you need to add some text to an already existing textfield... A simple way of doing that is to use the += operator, like this:

var mytextfield_txt:TextField = new TextField();
mytextfield_txt.text = "Hello ";
mytextfield_txt.text += "World..!";

// Hello World..!

The new appendText method does the same, but it is a more
efficient and faster way of doing it.

var mytextfield_txt:TextField = new TextField();
mytextfield_txt.text = "Hello ";
mytextfield_txt.appendText("World..!");

// Hello World..!


Wednesday, September 15, 2010

Why Do Package Names Start With com. In Actionscript 3?

Question:

Why do package names start with com. in Actionscript 3?

By the way, I’m guessing you already know that package names map to folder names. E.g. an as3 source file in the package com.example must be under the folder example, which in turn must be under the folder com..

Answer:

Package names do not have to begin with com. However, it is the convention to do so. E.g. com.lynda.item

What is the significance of com? Well, the package name is simply a domain name reversed. E.g com.lynda.utils

The domain name technically does not have to exist but you should own it. Obviously never use someone else’s domain name!! That’s just rude. It is standard practice to use a domain name because it helps to guarantee that your package names don’t collide with the names of someone else’s package on the other side of the world.

If I release some AS3 code that creates popup windows, I may place the code in a package called com.lynda.utils.popupwindow and not simply popupwindow

Likewise, if I download some third party code to use in my own project I’d expect their code to be packaged properly. E.g. com.google.utils.modalwindow. Then, I can just place their google folder under by own com folder.

Just as importantly, putting your as3 files into packages helps you think about how to organize the files. Often people place all files (their own and 3rd party code) under one folder! The advice is - don’t.

How to create type writer effect using Actionscript 3

In this tutorial you will learn how to create a typing effect using Actionscript 3.

We will create a function that can be later used many times. There will be one paremeter - text you want to type.

First of all, create a text field on stage with an instance name of textF.

Here is the code:

//--------------------------------------------------------------//

var para:String = "As you can see, firstly we create an array,which contains each letter as a separate element. Then we makea 50 millisecond timer (this will be the interval between each letter's appearance). Start the timer and just add a new letter when it completes. When the number of letters reach maximum, timer stops!";
function typeText(str:String) {
paper_txt.text="";
var textarray:Array=str.split("");
var timer:Timer=new Timer(50);
 var i:int=0;
timer.start();
timer.addEventListener(TimerEvent.TIMER, update);
  function update(TimerEvent) {
paper_txt.appendText(textarray[i]);
i++;
if (i==textarray.length) {
timer.stop();
}
}
}

typeText(para);
//--------------------------------------------------------------//

As you can see, firstly we create an array, which contains each letter as a separate element. Then we make a 50 millisecond timer (this will be the interval between each letter's appearance). Start the timer and just add a new letter when it completes. When the number of letters reach maximum, timer stops!

Easy as that. Remember that you can use split(); function differently, depending on what result are you aiming for. If you want not letters, but words to appear like that - change the parameter to space - split(" ").

Preview.
Download .zip


Author : Kirill Poletaev

Flash 0.05 Twip “Issue”

If you ever try to add any number smaller than 0.05 to the x or y properties of any graphic, then you’ll will notice nothing will happen. It will not add anything smaller than 0.05.

Actually, this issue is due to the way Flash deals with pixels. In the wonderful world of typography, 1/20 of a pixel is called a twip, and 1/20 in decimals is not surprisingly 0.05. Graphics in Flash are positioned using twips, so Flash just ignores you if you try to move an object less than a twip.

Well, the solution is simple:

Instead of something like:

  • graphic.y += velocity.y; // velocity.y may be smaller than 0.05
you do something like:
  • yPositionTemp += velocity.y;
  • graphic.y = yPositionTemp;

Using sortOn in AS3 Using sortOn in AS3

We’re working on a project where we had to sort the vector in different ways, depending on the user selection.

So we find the sortOn function in AS3, which is perfect. But there’s a problem!

If you want to sort an array of objects, by one of it’s fild which is numeric, the sortOn sorts them as if the numbers are strings.

The solution is to add an additional parameter, like this:

  • programArray.sortOn("popularity-score", Array.NUMERIC);
Note you can pass more parameters, for example sort them descending:

  • programArray.sortOn("popularity-score", Array.DESCENDING | Array.NUMERIC);
Hope this saves you some time when you need to use it!




Tuesday, September 14, 2010

removeChild Problem in AS 3.0

People are getting insane with removeChild() in AS3. They addChild()
the object in the same level but they can’t remove it.


There are several ways to use removeChild() of course it depends what
you need.

First Method

myMovieClip.parent.removeChild(myMovieClip);

Second Method:

MovieClip(myMovieClip).parent.removeChild(myMovieClip);

Third Method:


function loadPic():void
{
var
myMovieClip:MovieClip = new MovieClip();
var my_Loader:Loader = new Loader();
addChild(my_Loader);
addChild(myMovieClip);
var my_url:URLRequest = new URLRequest("image.png");
my_Loader.
load(my_url);
}



function loadPic():void
{
my_Loader.parent.removeChild(my_Loader);
}



These are the common mistake when using removeChild() of AS3, there are other problems or factors that’s why removeChild is not working in your project.

It probably improper declaring the function or events or objects. Just check the codes, and to make sure it will work use First Method or Second Method as my advise.

Monday, September 13, 2010

Creating a Custom Class

An ActionScript class is basically a text-basedfile with an .as extension
stored somewhere onyour computer, containing ActionScript code.
This code works as the blueprint for an object. Let's see what that
blueprint looks like:

package
{
public class CustomClass
{
public function CustomClass()
{
// Tracing some output..!
trace("My CustomClass is Working..!");
}
}
}


On the first line, you'll find the package statement, followed by an
opening curly bracket and ended with a closing curly bracket at the
bottom of the class. Packages are a way to group classes together
and represent the folder in which you saved the file. Imagine you
have created a folder called com inside the same folder where
you've saved an FLA or inside a defined source folder. In order
to have access to the folder and its classes, you will need to define
the package using the folder's name as shown next:

package com {
...
}


This works the same way for subfolders. Let's imagine a folder called
google has been added to the imaginary folder. The package definition
for classes inside this subfolder should then look like this:


package com.google{
...
}


After the package definition, you'll find the class definition, looks
as follows.


public class CustomClass
{
...
}


The name of the class must be the same name as the class file. In this
example, the file needs to be saved as CustomClass.as

At the top of the class definition you'll see the word public, which is a
keyword defining that the class is accessible to all other code in the
project. This keyword is called, an access modifier.

The defined name of the class will be used to instantiate new copies of
the class. Instantiating this class could be done like this:

var myCustomClass:CustomClass= new CustomClass();

After that we see the creation of a new function called CustomClass in
the class. Functions that have the same name as the name of the class
are known as constructors.

public function CustomClass()
{
// Tracing some output..!
trace
("My CustomClass is Working..!");
}

Constructors always have a public access modifier and are called
automatically each time the class is instantiated. This means that
the code inside this function will be executed automatically.