This is Tutorial-Center's Cache of http://blog.0tutor.com/post.aspx?id=192&titel=Cellphone-vibrator-with-actionscript-3.
Tutorial-Center's Cache is an alterntive root
way to acccess a tutorial. The other way is http://www.tutorial-center.com/tutorials/view/10336/Cellphone_vibrator_with_actionscript_3
This page may not display images, flash, text, or coding properly. To display them please click here.
To link to or bookmark this page, use the following url: http://www.tutorial-center.com/tutorial_cache/10336/Cellphone_vibrator_with_actionscript_3


Tutorial-Center is neither affiliated with the authors of this page nor responsible for its content.
148 visitors online
Our Sponcors: Halo 2 Bridging Tutorials | Your LINK HERE? Only $7 A MONTH!

0tutor.com: Cellphone vibrator with actionscript 3
RSS link icon

Cellphone vibrator with actionscript 3 

 

In this flash actionscript and animation tutorial we will make a cellphone vibrate using actionscript and some simple calculations and random values.

And this is how the vibrating phone will look.

First we need to import an image of a cellphone, it can just be a jpg or any other supported image files, you can use photoshop or your favorite image manipulations software to cut away background as I did.

Now when you have imported the phone image to the stage, right click it, and convert it to a movie clip.

In the properties panel give it an instance name, I named mine "phone_mc".

cellphone vibrate animation with flash actionscript

 

Now we are ready to do the simple actionscript code for this animation effect, I have made some inline code descriptions for you to better understand the code.

You can just copy and paste the code into your own flash project and it should work.

// first we define the current positions of the phone, both x and y axis.
var posx:Number = phone_mc.x;
var posy:Number = phone_mc.y;

// here we make an eventlistenser to call the shake function with an enter frame event.
phone_mc.addEventListener(Event.ENTER_FRAME, shakeIt);

// here is the shake function
function shakeIt(event:Event):void {
// quite simple just changes the current phone position and takes a random number (7/8) to add to it.
phone_mc.x = posx+(Math.floor(Math.random()*7));
phone_mc.y = posy+(Math.floor(Math.random()*8));
// also a random rotation to make it more interesting.
phone_mc.rotation = Math.random()*10;
}

Admin Bob says: Wednesday, September 03, 2008

Hi tomm, It would be easier to see if you email me your source code, so I can see what you did wrong, (my guess is, you put a bracket wrong, or one to many or few).


tomm says: Thursday, August 28, 2008

pliz help me out. here is my output
Error Scene=Scene 1, layer=Layer 3, frame=1:Line 17: The class or interface Chr(34)EventChr(34) could not be loaded.
function shakeIt (event:Event):void {

Total ActionScript Errors: 1 Reported Errors: 1


ashish says: Tuesday, July 01, 2008

thanks.


Anube says: Tuesday, July 01, 2008

very nice, simple and clear enough

   


 

 

 

 8

 
 
   Web Premium
 
 

All rights reserved, Copyright 2008. Contact