Arthar_93
01-04-2008, 22:48
Mam pytanie... jak i czym można zrobić takie tapetki które poprzez obrót telefonu zmieniają położenie lub coś w tym stylu? (mowie tu o telefonach typu w910i, k850i..)
np takie cos:
Gravity (Sony Ericsson K850i and W910i compatible)
The animation that can be used for showoff only, there is no actual use of it. It consists of one movie clip that contains an arrow which points the direction from which the strongest gravity is applied (Z axis excluded).
Used script:
Frame 1:
fscommand2("FullScreen");
onEnterFrame = function () {
displayDevice = substring(eval("/:$version"), 0, 2) == "FL" ? "phone" : "pc";
if (displayDevice == "phone") {
loadVariables("accelerometer://data", _root);
var angle = Math.atan2(-_root.accX, -_root.accY);
Garrow._rotation = angle*57.295779513082320876798154814105;
} else {
var angle = Math.atan2(-(_root._xmouse-120), -(_root._ymouse-160));
Garrow._rotation = angle*-57.295779513082320876798154814105;
}
}
Frame 2:
gotoAndPlay(1);
Code explanation:
This script is rather easy. The condition: if "displayDevice" is the phone then variables get loaded from accelerometer and used to determine the angle with Math.atan2 which gives the angle in radians. You can see that there is a - (minus) in front of accX and accY, if there was no minus the arrow would point the side up. To rotate the arrow properly it is necessary to multiply angle in radians with that long decimal number which is actually 180/PI. Sony Ericsson team multiplied the angle with 60 in their Flash animations, which was slightly off and noticeable on the arrow so I used the correct number.
If "displayDevice" is the PC, the arrow will point in direction of the cursor.
źr.: http://www.trekker-reactor.isq-networks-server.com/projects/gravity/