Important READ!!!

CodedCreativity has been moved to flashbuff.blogspot.com

kindly cooperate and visit flashbuff.blogspot.com here on

-inconvenience regretted

Manipulating Objects in Flash AS3

This is a basic tutorial that aims at teaching those who are new to Flash, ways to move objects (MovieClips,Buttons etc.) on the Stage and throws light on the various properties of movieclips and buttons and the ways to manipulate them...

Let's start off by creating a new Flash file (Ctrl+N). Now add/create a movie clip onto the stage of the main movie. I have imported this image (Ctrl+R) onto the stage and converted it into a movieclip (F8).
This should be the Object that we will be manipulating with the help of actionscript. Now we need to give this movieclip an instance name so that we can refer to it while writing our code. To do so, fire up the properties window/pane (Ctrl+F3) and set the instance name to "myObj_mc".


Now we will add buttons onto the stage which will control the movement and properties like transparency (alpha). Add 4 buttons to move the Object in the four directions respectively to act as controls to move the movieclip around and add another button to control transparency as show below.

 Now change the instance names of the button with the left arrow to "left_btn", right arrow button to "right_btn", up arrow button to "up_btn", down arrow button to "down_btn" and the button that says transparent to "alpha_btn".
Once we are done with this, we can proceed to the actionscript part. 


Code ::

up_btn.addEventListener(MouseEvent.MOUSE_DOWN,up_fn);
down_btn.addEventListener(MouseEvent.MOUSE_DOWN,down_fn);
left_btn.addEventListener(MouseEvent.MOUSE_DOWN,left_fn);
right_btn.addEventListener(MouseEvent.MOUSE_DOWN,right_fn);

alpha_btn.addEventListener(MouseEvent.MOUSE_DOWN,alpha_fn);

function up_fn(e:MouseEvent)
{    myObj_mc.y-=10;
   
// this  is equivalent to: myObj_mc.y=myObj_mc.y-10; }
   
function down_fn(e:MouseEvent)
{    myObj_mc.y+=10;
    }
   
function left_fn(e:MouseEvent)
{    myObj_mc.x-=10;
    }
   
function right_fn(e:MouseEvent)
{    myObj_mc.x+=10;
    }
   
function alpha_fn(e:MouseEvent)
{    myObj_mc.alpha=0.5;
    }


Code description ::

up_btn.addEventListener(MouseEvent.MOUSE_DOWN,up_fn);
down_btn.addEventListener(MouseEvent.MOUSE_DOWN,down_fn);
left_btn.addEventListener(MouseEvent.MOUSE_DOWN,left_fn);
right_btn.addEventListener(MouseEvent.MOUSE_DOWN,right_fn);


alpha_btn.addEventListener(MouseEvent.MOUSE_DOWN,alpha_fn);


In these first few lines, we are creating eventListeners to detect events from the event stream and when a "MOUSE_DOWN" event is detected, it calls the corresponding functions wherein we define how it should react to such an event.
MOUSE_DOWN is a subset of class MouseEvent and when the event is recorded, it calls the corresponding function with arguments as a MouseEvent...


function up_fn(e:MouseEvent)
{    myObj_mc.y-=10;
   // this  is equivalent to: myObj_mc.y=myObj_mc.y-10; }
   
function down_fn(e:MouseEvent)
{    myObj_mc.y+=10;
    }
   
function left_fn(e:MouseEvent)
{    myObj_mc.x-=10;
   

}
   
function right_fn(e:MouseEvent)
{    myObj_mc.x+=10;
    }
   
function alpha_fn(e:MouseEvent)
{    myObj_mc.alpha=0.5; //sets transparency to half
    }



In the above code, "x" "y" and "alpha" marked in green, are properties of movielips that define the placement along X-axis , along Y-axis and the transparency respectively.
When we say myObj_mc.y-=10; This means that we are moving the movieclip by 10pixels, upwards. Similarly, the movements along other directions are written in the other functions and the transparency is set to half when the corresponding button is pressed (refer alpha_fn function).

Note:: The origin is considered to be at the top-left corner and as we move right, x-coordinate increases and as we move down, y-coordinate increases.
And alpha (transparency) takes values from 0-1, 0 corresponding to full transparency and 1 corresponding to no transparency.


  The functions defined are that the event listeners would call on recording a mouse event. We are defining functions with a parameters "e" which is a MouseEvent Object, this is because when an eventListener calls the functions, it sends the MouseEvent as an argument and if we don't define parameter "e", flash would detect an Argument Mismatch Error.


To download the source files, clik here (movement.fla).
 This tutorial can be extended to buttons and graphics too as they carry almost the same properties.
In case of doubts or any problems faced while trying out this tutorial, feel free to leave a comment below.

Nokia Point & Find follows the trail laid by Google Goggles

For those of you who havent heard of either Google goggles or Nokia Point and Find, these are both augmented-reality projects being developed by Google and Nokia Europe respectively, which aim to bring smart image recognition features to smartphone users. What this means is that users can point their smart phones to any object and the phone wold identify it and provide relevant content.

Google Goggles ::
Google initially started the Google Goggles project at Googlelabs to deploy the application targeting their new mobile operating system, Android which they expect to launch to other OS's like Symbian in the near future.
Though it is still under the beta pahse, it can be downloaded from the googleLabs website and currently features recognition of landmarks, text, posters, logos and barcodes.
Apart from identifying these, the application also populates relevant content and links from it's vast online database. 
One can scan a barcode and get Product Information and also the best buy price around your location by parsing your GPS data.
It's text recognition can help tourists understand foreign language and can also double up as a virtual guide with its landmark recognition feature.
It can also parse text from off cards and save them as contacts.
GoogleLabs seem pretty ambitious with their project and wish to extend the recognition capabilities to virtually every object possible in the near futue.
http://www.google.com/mobile/goggles/



Nokia Point & find ::
Seeing the great fortitude of possibilities that such an application can provide it's users, Nokia has set a foot forward and started the development of Nokia Point and Find.
Like Google Goggles, Nokia Point and Find is still in it's beta version and hence offers limited functionality. As of now its ability to detect objects is limited to detecting Movie Posters and provides relevant information and lets users book tickets online.
Nokia Point and Find also promises to recognize barcodes and monuments in the future. But as it is in it's beta phases, the recognition accuracy is below par and has a long way to go.
http://europe.nokia.com/services-and-apps/nokia-point-and-find

Conclusion :: 
Both the Applications have a lot of potential and we can expect to see a full release in about a year or so with reasonable detection success and as more people start using them, their image recognition algorithms can learn and result in better detection and with user submitted data, the database can get very accurate over time.
At this point of time, Google Goggles is miles ahead and Nokia has to do a lot of coping up to prove their mettle and please their loyal users.  

At this point of time all we can say is that augmented reality has a lot to achieve but then it sure will find a place in our day to day lives...

Related Posts with Thumbnails