Flash Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignFlash Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 8th, 2004, 05:12 AM
Captain Planet's Avatar
Captain Planet Captain Planet is offline
Senior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 328 Captain Planet User rank is Lance Corporal (50 - 100 Reputation Level)Captain Planet User rank is Lance Corporal (50 - 100 Reputation Level)Captain Planet User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Day 14 h 15 m 15 sec
Reputation Power: 5
Angry arrow graphic pointing to wherever mouse cursor is.

Hi guys.

I have a graphic (arrow) which spins round on the same spot pointing to wherever the mouse go's.

Instead of the arrow pointing to every single angle (360 degrees) I want it to either point up, down, left or right. I think it might need rounding up/down some how to the nearest 90 degrees?

Here's my code that I use just to spin the arrow graphic.


onClipEvent (load) {
_x += Number(2);
friction = .7;
speedratio = .2;
xspeed = 0;
yspeed = 0;
xgoal = this._x;
ygoal = this._y;
}
onClipEvent (enterFrame) {
// figure out our slope
var slope = (_root._ymouse-_y)/(_root._xmouse-_x);
// get it in usable form...
var radians = Math.atan(slope);
var theta = (radians*180)/Math.PI;
theta += (_root._xmouse<_x) ? 180 : 0;
// set the rotation
_rotation = theta;
}



Can anyone help?? Much appreciated.
__________________
Captain Planet.

Last edited by Captain Planet : January 8th, 2004 at 07:52 AM.

Reply With Quote
  #2  
Old January 8th, 2004, 09:40 AM
Tann San Tann San is offline
Gotta get to the next screen..
Click here for more information.
 
Join Date: Nov 2003
Location: Legion of Dynamic Discord
Posts: 4,457 Tann San User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Tann San User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Tann San User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Tann San User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Tann San User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Tann San User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Tann San User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Tann San User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Tann San User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Tann San User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Tann San User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)  Folding Points: 6414 Folding Title: Novice Folder
Time spent in forums: 2 Weeks 6 Days 5 h 46 m 34 sec
Reputation Power: 503
Facebook MySpace
Hi, this should do it:
Code:
onClipEvent (enterFrame) {
var slope = (_root._ymouse-_y)/(_root._xmouse-_x);
var radians = Math.atan(slope);
var theta = (radians*180)/Math.PI;
theta += (_root._xmouse<_x) ? 180 : 0;
if(theta == 0 || theta == 90 || theta == 180 || theata == 270)
  {
      // set the rotation
     _rotation = theta;
  }
}

You can use Math.floor(theta) or Math.ceil(theta) if you need to round it up/down. I wrote the above here so I havent tested it. Not sure if theta would == 0 || 360..think its zero though.
__________________
-Tann

-Vote for your favorite ActionScript editor here.

Reply With Quote
  #3  
Old January 8th, 2004, 09:58 AM
Captain Planet's Avatar
Captain Planet Captain Planet is offline
Senior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 328 Captain Planet User rank is Lance Corporal (50 - 100 Reputation Level)Captain Planet User rank is Lance Corporal (50 - 100 Reputation Level)Captain Planet User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Day 14 h 15 m 15 sec
Reputation Power: 5
It stopped working Tann, obviously it never got into the if statement. I was thinking, the arrow is pointing to 4 different images. Could I reference it to them and say something like:
if mouseOver image1
begin
rotate arrow x degrees
end
If so how????

Reply With Quote
  #4  
Old January 8th, 2004, 10:32 AM
Tann San Tann San is offline
Gotta get to the next screen..
Click here for more information.
 
Join Date: Nov 2003
Location: Legion of Dynamic Discord
Posts: 4,457 Tann San User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Tann San User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Tann San User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Tann San User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Tann San User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Tann San User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Tann San User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Tann San User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Tann San User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Tann San User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Tann San User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)  Folding Points: 6414 Folding Title: Novice Folder
Time spent in forums: 2 Weeks 6 Days 5 h 46 m 34 sec
Reputation Power: 503
Facebook MySpace
Hi, yer that would definately work. The easiest and quickest way would be to make each of the four images into a button. Just manually do it. Then for each button use:

on(rollOver)
{
myArrow._rotation = 0;
myArrow._rotation = 90;
myArrow._rotation = 180;
myArrow._rotation = 270;
}

Obviously you only use one of those four statements for each button, which one depends on the angle your arrow starts in i.e. up, left etc...

If you have dynamically loaded the images then you should definately look into assigning mouse events that way otherwise dont worry about it.

Reply With Quote
  #5  
Old January 8th, 2004, 10:45 AM
Captain Planet's Avatar
Captain Planet Captain Planet is offline
Senior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 328 Captain Planet User rank is Lance Corporal (50 - 100 Reputation Level)Captain Planet User rank is Lance Corporal (50 - 100 Reputation Level)Captain Planet User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Day 14 h 15 m 15 sec
Reputation Power: 5
I'll give that a shot now. Cheers tan.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignFlash Help > round up/down to nearest 90 degrees.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

IBM developerWorks




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway