Author |
Using the accelerometer to rotate |
Toeler Joined: Sep 23, 2008 Posts: 2 PM |
Alright, well I found a wallpaper of a linken park logo that would rotate based on how the phone was held, and I'm trying to create my own version of this, I've managed to get the image to rotate based on my mouse when on the pc, and I've decompiled the original .swf to try to get the code to work but it wont work.
Code:
| 1;
1;
onEnterFrame = function ()
{
displayDevice = substring(eval("/:$version"), 0, 2) == "FL" ? "phone" : "pc";
if (displayDevice == "phone")
{
loadVariables("accelerometer://data", _root);
var angle = Math.round(Math.atan2(_root.accX, _root.accY) * 10000) / 100000;
rotAngle = angle * 57.2958;
var dr = rotAngle - logo._rotation;
if (Math.abs(dr) > 180)
{
dr = dr <= 0 ? 360 + dr : dr - 360;
}
logo._rotation = logo.rotation + dr / 5;
return;
}
var angle = Math.atan2(_root._xmouse - 120, _root._ymouse - 160);
logo.rotation = angle * - 57.2959;
}
; |
|
The code is from Trekker Reactor. That is the code I am using, but the error I get is that var angle is already defined (Which I know it is), but that is how is set out in the original and I can't seem to get it to work, can anybody help me?
[ This Message was edited by: Toeler on 2008-09-23 20:35 ] |
|
KeeF! Joined: May 22, 2008 Posts: 81 PM |
if you got this from Trekker Reactor , shouldn't you credit him ? |
Toeler Joined: Sep 23, 2008 Posts: 2 PM |
Original post edited.
[ This Message was edited by: Toeler on 2008-09-23 20:43 ] |
|
Access the forum with a mobile phone via esato.mobi
|