Forum: Log-In | Register | Contact | Shop


SwishMax Tutorials And Resources
Where Imagination Is The Creation

 


Add


Welcome To Swish-Designs.co.uk Have a Nice Friday

OnMouseDown Simulation - Swishmax

Learn how to substitute the OnMouseDown function in swishmax.



First Of All

Open swishmax and set the size for the movie, i have used 189 x 233

and frame rate of 25 fps..



Step.1

Create your object to control, as you can see i have created a helicopter for the purpose of this demonstration, if you do not have an object or cannot think of an object feel free to download an animated gif of the vector helicopter used in the demonstartion movie above.
Right click on the image below and save image as



Step.2

Import the helicopter.gif into swishmax and name the sprite as helicopter
and place the following code onto Scene_1

CODE:

onLoad () {
/*on (OnMouseDown) {
swishmax Work-a-round Code By Craig Lowe
http://www.swish-designs.co.uk
for more help or tuorials visit www.swish-designs.co.uk/forums
this credit must stay in place.
}
*/
scrollSpeed=5;
//sets up to false when the movie starts
up=false;
//hides system cursor
mouse.hide();
//hides custom cursor at runtime
cursor._visible=false;
//sets friction
}
on (press) {
//sets up to true when mouse button is down
if (_root.up==false) {
_root.up=true;
}
}
on (release) {
//sets up to false when mouse button is up(released)
if (_root.up==true) {
_root.up = false;
}
}
onEnterFrame() {
//checks every frame (looping)
if (up==true) {
//moves object up
helicopter._y = helicopter._y -4;
//rotates the object by 10 pixels
helicopter._rotation = -10;
} else if (up==false) {
//moves object down
helicopter._y=helicopter._y + 4;
////rotates the object by 10 pixels
helicopter._rotation = 10;
}
}
onEnterFrame() {
//sets boundaries
if (helicopter._y<26) {
helicopter._y=26;
helicopter._rotation = 0;
}
if (helicopter._y>208) {
helicopter._y=208;
helicopter._rotation = 0;
}
}
on (rollOver,dragOver) {
cursor._visible=true;
}
on (rollOut,dragOut,dragOver) {
cursor._visible=false;
}

 

Press CTRL+T to see it work in the flash player.