Author |
K850i Accelerometer + Flash Lite 2.0 |
LCARS-Expert Joined: Aug 24, 2007 Posts: 194 From: Croatia PM, WWW
|
Every one who owns K850i noticed that wallpapers in Laster Precision and Crystal themes react depending on which side is the phone turned to.
I managed to extract those Flash files and obtain their ActionScript but, unfortunately, only partial.
It's missing how the animation gets accelometer data from the phone. If you test those animations on your computer you will notice they react on position of your cursor when it's above the animation. It interprets "that side up" for where the cursor is.
I guess will never answer what's the ActionScript for accessing the Accelometer.
If you have any ideas please post them! |
|
zaxan Joined: Jun 01, 2007 Posts: 417 From: United Kingdom PM |
Could you possibley post the action script / swf / fla (depending on which of these you have) so I (and any others who are interested) can see what action script you have found so far and how this changes the view of the theme on the computer.
Cheers |
LCARS-Expert Joined: Aug 24, 2007 Posts: 194 From: Croatia PM, WWW
|
Of course!
Here is a RAR archive, it contains original flash wallpapers from theme files and directory where I converted them to FLA with Flash Decompiler.
Link
When publishing those FLA to SWF the result doesn't match the original SWF, as you will notice. That means the SWF wasn't converted back to FLA completely. |
zaxan Joined: Jun 01, 2007 Posts: 417 From: United Kingdom PM |
Thanks for uploading those files, I've had a look at them. Some of the code in there is above my ability in action script and rather confusing although I do understand sections of the script which seem to read accelerometer data. I have found in the Precision_standby.swf.flp file there is accelerometer.as which contains the following code:
_root.onEnterFrame = function ()
{
if (classes.AccelerometerManager.mMode == "phone")
{
loadVariables("accelerometer://data", _root);
this.accX = Number(this.accX);
this.accY = Number(this.accY);
this.accZ = Number(this.accZ);
var __reg3 = undefined;
This code seems to be reading an accelerometer variable and setting X, Y and Z possitions although more of the code after this uses code I can't really understand, but the above section would be my best guess for reading the accelerometer data .
[ This Message was edited by: zaxan on 2007-12-09 12:03 ] |
melk Joined: Jan 08, 2002 Posts: 165 From: Romania PM, WWW
|
Good thing that you started this thread, I never noticed that the standby flash animation moves according to the phone's position. It's so useless, but also very cool.
Good luck cracking the code.
Once you start down the path, forever will it dominate your destiny!!! |
Duran Joined: Aug 25, 2006 Posts: > 500 From: Netherlands PM |
so soon we're getting the "accelerometer-ball-game" just like nokia's?;p |
gregface Joined: Mar 05, 2004 Posts: > 500 PM |
On 2007-12-09 13:54:05, Duran wrote:
so soon we're getting the "accelerometer-ball-game" just like nokia's?;p
The w910i already has this.
|
zaxan Joined: Jun 01, 2007 Posts: 417 From: United Kingdom PM |
On 2007-12-09 14:11:35, gregface wrote:
On 2007-12-09 13:54:05, Duran wrote:
so soon we're getting the "accelerometer-ball-game" just like nokia's?;p
The w910i already has this.
Yeah, called Marble Madness afaik (I thought the K850 had this aswell?), although I think that game would use java to read the accelerometer data rather than flash actionscript, so either way the data from the accelerometer has to be accessible by external applications / files - just I'm not totally sure how yet lol
[ This Message was edited by: zaxan on 2007-12-09 13:21 ] |
LCARS-Expert Joined: Aug 24, 2007 Posts: 194 From: Croatia PM, WWW
|
@zaxan, I was looking at that too... It seems that accelerometer returns a non-numeric value:
if (classes.AccelerometerManager.mMode == "phone")
{
loadVariables("accelerometer://data", _root);
this.accX = Number(this.accX);
this.accY = Number(this.accY);
this.accZ = Number(this.accZ);
var __reg3 = undefined;
That script would say something like "If animation is loaded on the phone load variables from accelometer accX, accY and accZ." If you set the phone to write them you'll get "NaN" in each field which would be Not a Number. That means the each "Number(this.accX)" returns NaN. Since "Number(expression)" converts the parameter expression to a number and returns a value... It gives NaN only "If expression is NaN, the return value is NaN."
This is next:
if (!isNaN(this.accX) && !isNaN(this.accY) && !isNaN(this.accZ))
{
__reg3 = Math.round(Math.atan2(this.accZ, this.accX) * 10000) / 10000 + 3.14159;
this.Alpha = isNaN(__reg3) ? this.Alpha : __reg3;
__reg3 = Math.round(Math.atan2(this.accZ, this.accY) * 10000) / 10000 + 3.14159;
this.Beta = isNaN(__reg3) ? this.Beta : __reg3;
__reg3 = Math.round(Math.atan2(this.accX, this.accY) * 10000) / 10000;
this.Gamma = isNaN(__reg3) ? this.Gamma : __reg3;
var __reg5 = 0 - Math.cos(this.Alpha);
var __reg4 = Math.cos(this.Beta);
classes.Application.mAccManager.updateComponents(__reg5, __reg4);
}
return;
}
So, the script checks "isNaN" which returns true if the variable (accX, accY and accZ) is not a number. Which in this case is true. Now it gets difficult. I don't understand this second part completely but I get that it generates a numeric value, an angle in radians to be exact.
Math.atan2(this.accZ, this.accX) "Computes and returns the angle of the point y/x in radians, when measured counterclockwise from a circle's x axis (where 0,0 represents the center of the circle). The return value is between positive pi and negative pi." Now I got "oh shit, its trigonometry" in my head.
__reg3 = Math.round(Math.atan2(this.accZ, this.accX) * 10000) / 10000 + 3.14159;
Now... If I get this correctly, the angle is multiplied by 10000 and then converted to a round number. That number is divided back by 10000 and pi is added to it. I can't get it in my head how does __reg3 number look like after that. And what is this:
this.Alpha = isNaN(__reg3) ? this.Alpha : __reg3; |
LCARS-Expert Joined: Aug 24, 2007 Posts: 194 From: Croatia PM, WWW
|
WOOHHOOOH!!! Just got numbers out of it!
http://www.trekker-reactor.isq-networks-server.com/forum/acc-data.zip
Unpack this and put it on your phone! You'll see it reacts on the side you turn it to. |
zaxan Joined: Jun 01, 2007 Posts: 417 From: United Kingdom PM |
DUUUDE!! Great to see you've worked it out Now I'll just have to wait till I've got a k850 (or hopefully k860 if it's released anytime soon) to check it myself.
Nice one |
Pakzal Joined: May 28, 2007 Posts: 39 From: The Netherlands PM |
You can also see this, by going into the service menu |
LCARS-Expert Joined: Aug 24, 2007 Posts: 194 From: Croatia PM, WWW
|
On 2007-12-09 18:55:30, Pakzal wrote:
You can also see this, by going into the service menu
Of course you can but you can't use the service menu in Flash.
Check this out:
http://www.trekker-reactor.isq-networks-server.com/forum/gravity.rar
Put it on your phone (if its K850i) and try turning and shaking it |
LCARS-Expert Joined: Aug 24, 2007 Posts: 194 From: Croatia PM, WWW
|
Everyone who don't have K850i and want to know what is this about, I made a video for you:
http://www.youtube.com/watch?v=YG0WiGQ5THc |
NightBlade Joined: Jul 29, 2007 Posts: > 500 From: Nessebar, Bulgaria PM |
Cool! I didn't know K850's accelerometre worked so smooth! Like the iPhone's!
Man, that means that someone could make cool accelerometre apps for SE phones like on the iPhone.
Far out, man!! (lol, ignore that)
[ This Message was edited by: NightBlade on 2007-12-09 20:47 ] |
|