Copy link to clipboard
Copied
I would apreciate if someone help me with some coding.
I have this code that I previously get to rotate a movieclip with the mouse, and get to another frame, for a college work (we only did the tweens, just learned the basic coding) but I cant get no result.
import flash.events.Event;
import flash.events.MouseEvent;
leme_mc.addEventListener(MouseEvent.MOUSE_DOWN, rotate);
stage.addEventListener(MouseEvent.MOUSE_UP, endrotate );
var angulo:Number=0
function rotate(e:Event😞void
{
stage.addEventListener(MouseEvent.MOUSE_MOVE,rotate);
var position:Number = Math.atan2(mouseY - knob_mc.y,mouseX - knob_mc.x);
angle=(position/Math.PI) *180;
knob_mc.rotation = angle;
}
function endrotate(e:MouseEvent😞void
{
knob_mc.removeEventListener(MouseEvent.MOUSE_DOWN, rotate);
stage.removeEventListener(MouseEvent.MOUSE_UP, menu);
stage.removeEventListener(MouseEvent.MOUSE_MOVE,rotate);
knob_mc.addEventListener(MouseEvent.MOUSE_DOWN,rotate);
}
function menu(e:MouseEvent😞void
{
if ( angle >=1 && angle <= 100 )
{
gotoAndPlay(2);
}
else if (angle >=100 && angle < 340) {
gotoAndPlay(2);
I made the movieclip move with the mouse, the knob_mc rotate when i press and move the mouse but i can't get the AS3 script to make the angle in the If's jump to another frame.
the swf is this http://www.fastswf.com/AMrZieU
Copy link to clipboard
Copied
use:
import flash.events.MouseEvent;
knob_mc.addEventListener(MouseEvent.MOUSE_DOWN, rotate);
var angle:Number=0
function rotate(e:MouseEvent):void
{
var position:Number = Math.atan2(mouseY - knob_mc.y,mouseX - knob_mc.x);
angle=(position/Math.PI) *180;
knob_mc.rotation = angle;
endrotate(e);
menu(e);
}
function endrotate(e:MouseEvent):void
{
knob_mc.removeEventListener(MouseEvent.MOUSE_DOWN, rotate); // i'm not sure you want to do this
}
function menu(e:MouseEvent):void
{
// this if-else statement adds nothing. you're always going to frame 2 so you can remove the if-else
if ( angle >=1 && angle <= 100 )
{
gotoAndPlay(2);
}
else if (angle >=100 && angle < 340) {
gotoAndPlay(2);
}
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now