Creating Magnet Menu - Flash Tutorials
 
  Buy Ebooks, Video Games, DVDs, Electronics and more !
Home | Help Forums | Web Design Tutorials | Free Swishmax Downloads Make Money Online Blog . Free Image and Photo Sharing and Hosting

 

 

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

   Free image hosting
   Web Design Pakistan
   Swish Templates
   SWiSH Climax
   Talkfreelance Community
   Template Desire
   Lite boards
   Script Sector
   GimpTalk
   13dots
   Idea Designs
   PHP Cafe
   Sposatoettore
   Free swishmax templates
   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



© 2002-2005 Flaxweb Network | Article Manager | Gimp Tutorials Library | RAD C++ Library | Free C/C++ Sourcecode |
Sites of interest : Web Design Blog | Swish Templates | Swishmax Ebook | Photoshop Templates | Gimp Tutorials | Text Forum | Make Money Online