Skip to main content
Orlando-Junior
Participant
January 9, 2015
Question

Rotating movieclip and changing to a particular frame (S.O.S)

  • January 9, 2015
  • 1 reply
  • 742 views

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


This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
January 10, 2015

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);

}

}