Home | Help Forums | Web Design Tutorials | Free Swishmax Downloads | All Downloads

 

 

Company

Home

Nework Details

Tutorials

SWiSH 2

SWiSHMax

Flash MX

PHP & MySQL

HTML / JScript

Adobe Photoshop

Corel Draw

Gimp

Miscellaneous

Downloads

Templates

Plugins

Fonts

Wallpapers

Free Images

Scripts and Codes

Products

E-Books

SWiSH BB

SWiSH Templates

SWiSH-DB Newsletter
Subscribe to our newsletter : GO
  Partners / Affiliates

   Swish Templates
   SWiSH Climax
   GimpTalk
   Idea Designs
   Sposatoettore
   Try Acai Berry Diet
   Download Free Ringtones
   Swishzone

Manage your site with Flax Article Content Management System
Creating Magnet Menu
Category : Flash | Level : Intermediate | Language : English
Ask Question | Read Comments | Post tutorial | Previous | Next

Web www.swish-db.com

Hi ther all......This tutorial will tell you how to move objects with a magnetic effect on mouse....:-
First Step:-
1.Create a layer and create three objects and convert them to Movie Clip...

Now we have to give each object a specific co-ordinate value:-
object1 movieclip:- X: 27.8 Y: 131.9
object2 movieclip:- X: 27.8 Y: 158.8
object3 movieclip:- X: 27.8 Y: 185.1

OK.
Now we put a "stop()" action at frame 1 of Layer1 in main movie.
Then we put this action in "object1 movieclip":-
CODE
onClipEvent(load) {
acscriptmouse = 100;
dustymouse = 100;
outragedmouse = 100;

divfactor = 6;
}

onClipEvent(enterFrame) {


// begin actionscript button
if ((_root._ymouse > _root.acscript._y -15) && (_root._ymouse < _root.acscript._y +15)) {
acscriptdist = Math.abs(_root._xmouse - _root.acscript._x);
acscriptmouse = _root._xmouse;
if(_root._xmouse > _root.acscript._x) {
 _root.acscript._x = _root.acscript._x + (acscriptdist/divfactor);
}

if(_root._xmouse < _root.acscript._x) {
 _root.acscript._x = _root.acscript._x - (acscriptdist/divfactor);
}

}
if ((_root._ymouse <= _root.acscript._y -15) || (_root._ymouse > _root.acscript._y +15)) {
acscriptdist = Math.abs(acscriptmouse - _root.acscript._x);
if(acscriptmouse > _root.acscript._x) {
 _root.acscript._x = _root.acscript._x + (acscriptdist/divfactor);
}

if(acscriptmouse < _root.acscript._x) {
 _root.acscript._x = _root.acscript._x - (acscriptdist/divfactor);
}

}
// end actionscript button


// begin dustydesign button
if ((_root._ymouse > _root.dusty._y -15) && (_root._ymouse < _root.dusty._y +15)) {
dustydist = Math.abs(_root._xmouse - _root.dusty._x);
dustymouse = _root._xmouse;
if(_root._xmouse > _root.dusty._x) {
 _root.dusty._x = _root.dusty._x + (dustydist/divfactor);
}

if(_root._xmouse < _root.dusty._x) {
 _root.dusty._x = _root.dusty._x - (dustydist/divfactor);
}

}
if ((_root._ymouse <= _root.dusty._y -15) || (_root._ymouse > _root.dusty._y +15)) {
dustydist = Math.abs(dustymouse - _root.dusty._x);
if(dustymouse > _root.dusty._x) {
 _root.dusty._x = _root.dusty._x + (dustydist/divfactor);
}

if(dustymouse < _root.dusty._x) {
 _root.dusty._x = _root.dusty._x - (dustydist/divfactor);
}

}
// end dustydesign  button


// begin dustyoutraged button
if ((_root._ymouse > _root.outraged._y -15) && (_root._ymouse < _root.outraged._y +15)) {
outrageddist = Math.abs(_root._xmouse - _root.outraged._x);
outragedmouse = _root._xmouse;
if(_root._xmouse > _root.outraged._x) {
 _root.outraged._x = _root.outraged._x + (outrageddist/divfactor);
}

if(_root._xmouse < _root.outraged._x) {
 _root.outraged._x = _root.outraged._x - (outrageddist/divfactor);
}

}
if ((_root._ymouse <= _root.outraged._y -15) || (_root._ymouse > _root.outraged._y +15)) {
outrageddist = Math.abs(outragedmouse - _root.outraged._x);
if(outragedmouse > _root.outraged._x) {
 _root.outraged._x = _root.outraged._x + (outrageddist/divfactor);
}

if(outragedmouse < _root.outraged._x) {
 _root.outraged._x = _root.outraged._x - (outrageddist/divfactor);
}

}
// end dustyoutraged button


//end
}

And thats it....you will see that the objects are following the mouse when you get the cursors in their horizontal line....

REGARDS...... smile.gif



All rights reserved - swish-db.com