This tutorial will show you how to apply some action on any text,word,picture... using the Action Script. For this example, I will apply some action on the words. When you drag your mouse over the words something happens! let's go to see what happens!
Example:
Step 1Open a new Flash document and write something. For this example I'll write this:
Step 2Select the "word", and press F8 key (Concert to Symbol) to convert that "word" into a Movie Clip Symbol. See the picture below.
Step 3While the "word" is still selected, open the Properties Panel (Ctrl+F3) and for <Instance name> type toxiclab.
Step 4Create a new layer above layer 1, and name it Action.
Step 5Using the "drag and drop technique", move the Action layer beneath layer 1 (For my example toxiclab.org).
Step 6Click on first frame of Action layer, open the Action Script Panel (F9) and paste this script:
function proximity(clip,music) {
var x:Number = _root._xmouse;
var y:Number = _root._ymouse;
var cx:Number = clip._x;
var cy:Number = clip._y;
var prox:Number = Math.sqrt((x-cx)*(x-cx) + (y-cy)*(y-cy));
if(prox<70) {
music.setVolume(70-prox);
clip._xscale = 145 - prox;
clip._yscale = clip._xscale;
}
else {
music.setVolume(0);
clip._xscale = 70;
clip._yscale = clip._xscale;
}
}
var toxiclabSound:Sound = new Sound(toxiclab);
this.onEnterFrame = function() {
proximity(toxiclab,toxiclabSound);
}
toxiclab.onRollOver = function() {
this.swapDepths(_root.getNextHighestDepth());
}
We're done for the first word. You must repeat a previous steps for all other words. I'll make only the one "word", to see what is the different in Action Script code.
Step 7So create a new layer above layer 1 and name it which you like.
Step 8Write any text, take the Selection Tool (V), select it and press F8 key (Convert to Symbol) to convert it into a Movie Clip Symbol.
Step 9Open the Properties Panel (Ctrl+F3) and for <Instance name> type tutorialized
Step 10Click on the first frame of Action layer, open the Action Script Panel (F9) and add this Script in already existing Script: (I'm bold a new script to see the difference) See the picture below.
function proximity(clip,music) {
var x:Number = _root._xmouse;
var y:Number = _root._ymouse;
var cx:Number = clip._x;
var cy:Number = clip._y;
var prox:Number = Math.sqrt((x-cx)*(x-cx) + (y-cy)*(y-cy));
if(prox<70) {
music.setVolume(70-prox);
clip._xscale = 145 - prox;
clip._yscale = clip._xscale;
}
else {
music.setVolume(0);
clip._xscale = 70;
clip._yscale = clip._xscale;
}
}
var toxiclabSound:Sound = new Sound(toxiclab);
var tutorializedSound:Sound = new Sound(tutorialized);
this.onEnterFrame = function() {
proximity(toxiclab,toxiclabSound);
proximity(tutorialized,tutorializedSound);
}
toxiclab.onRollOver = tutorialized.onRollOver = function() {
this.swapDepths(_root.getNextHighestDepth());
}
I hope that you have seen what are the differences between the first and the second Script, and what you must to do, for all other words. If you still don't understeand Script, and don't know how to next, please download fla, to see what to do
Have a nice day!
Download example (29 KB)