Esato Mobile
Sony Ericsson / Sony : Software, Firmware and Drivers : How to make auto-rotate function in Flash Lite 2.0 (K850i)
> New Topic
> Reply
< Esato Forum Index > Sony Ericsson / Sony > Software, Firmware and Drivers > How to make auto-rotate function in Flash Lite 2.0 (K850i) Bookmark topic
Page12345678>

LCARS-Expert Posts: 194

Here I'll try to explain how to make your Flash animation do the auto rotate function with a very simple script.
You can then use this script in any way you wish.

Creating a K850i compatible Flash document
To begin start your Adobe/Macromedia Flash and press CTRL+N to create a new document. Pick "Flash file (ActionScript 2.0)" and press OK.
Set size to 240x320, background is your pick (I'll use black for this tutorial) and set frame rate to acceptable value (I mostly use 25).
After that (this is very important) click on Settings button and set Version to Flash Lite 2.0.

The tutorial
For this tutorial I'll make a flash file with 1 image in 2 sizes:

And they'll change depending on the phone rotation.
You can use your own images (240x320 for portrait and 320x240 for landscape mode)

Scripting
First thing are the scripts. In the first layer add 3 more frames all keyframes (now ou should have 1 layer with 4 keyframes).
Scripts go like this:

Frame 1:
fscommand2("ExtendBacklightDuration");
fscommand2("FullScreen");

loadVariables("accelerometer://data", _root);
if ((accX > 800) && (accY gotoAndPlay(3);
}

Frame 2:
gotoAndPlay(1);

Frame 3:
fscommand2("ExtendBacklightDuration");
fscommand2("FullScreen");

loadVariables("accelerometer://data", _root);
if ((accX 800)) {
gotoAndPlay(1);
}

Frame 4:
gotoAndPlay(3);

Elaborating the script
fscommand2 does exactly what it says – Extends Backlight Duration, which makes max light stay a little longer and sets the animation to full screen which is not really required but you never know.
loadVariables("accelerometer://data", _root); - It loads variables from Accelerometer. These are accX, accY, and accZ and they represent gravitational force applied to them (which makes maximum of 990 when phone is static).
if ((accX > 800) && (accY gotoAndPlay(3);
}
This script does the auto rotate, if your phone is placed exactly landscape the accX is 990 and accY is 0 which agrees with the condition above and the script sends the animation to frame 3.
Frame 2 has the script that does the loop; it sends the animation back to frame 1.
Frame 3 has the script that is very similar to the one in frame 1 but the difference is in numbers which changed the place. When phone is placed exactly portrait the accX is 0 and accY is 990.
Frame 4 has the script that does the same thing as the script in Frame 2, it loops.
Why the loop? – Every time the animation is sent back the script works again and it reads new accelerometer data, if there was no loop the animation would read accelerometer data only once – when you start the animation and the rotation would never happen.

Adding images
Now create a 2nd layer. Make keyframes on frame 1 and 3. Your timeline should look like this now:

Now all you have to do is add images. Put portrait image on the 2nd layer you created in Frame 1, make sure it's coordinates are X: 0.0 and Y: 0.0.
Go to the Frame 3 of the same layer and put the landscape image on it, while its selected press CTRL + SHIFT + 9 (that will rotate the image 90° CW), now set it's coordinates X: 0.0 and Y: 0.0.
That’s it! Now it's time to test the animation. Press CTRL + ALT + SHIFT + S (or click File, Export >, Export movie…) and click save (make sure SWF was set as the file type).
Completed FLA (source) file:
Link
Exported SWF file:
Link

Please post your works here.

[ This Message was edited by: LCARS-Expert on 2007-12-31 16:27 ]
--
Posted: 2007-12-11 19:21:01
Edit : Quote

adamnguyen Posts: 22

Nicely done! This thread is as useful as the one discussing accelerometer and flashlite.
--
Posted: 2007-12-12 07:39:53
Edit : Quote

NightBlade Posts: > 500

Thank you. Once I learn how to use Flash, it'll be really fun!
--
Posted: 2007-12-12 16:56:25
Edit : Quote

zaxan Posts: 418


On 2007-12-12 16:56:25, NightBlade wrote:
Thank you. Once I learn how to use Flash, it'll be really fun!


Sure you'll find it easy once you get some practice in Flash, and if not there are many free tutorials all over the internet anyway - including this one

@LCARS - Nice tutorial, really makes the actionscript seem simple now

EDIT - I've got Flash 8 and the highest option I get for flash lite is 1.1, is flash lite 2.0 only is CS3?

[ This Message was edited by: zaxan on 2007-12-12 16:39 ]
--
Posted: 2007-12-12 17:38:17
Edit : Quote

LCARS-Expert Posts: 194

It appears so, do you have Flash 8 Professional or Lite? I suggest you go to CS3, I find it much better!
--
Posted: 2007-12-12 17:46:04
Edit : Quote

zaxan Posts: 418

I think it's pro but I'll go to CS3 anyway - been meaning to upgrade for a while now.
--
Posted: 2007-12-12 17:59:31
Edit : Quote

LCARS-Expert Posts: 194

Here is my first animation that uses auto-rotate:
LCARS Screensaver
I worked on it for a while, only auto-rotate script was missing. It is fully animated, like a real LCARS and it matches my web site.
There are 4 modes:
Blue Portrait (when phone is portrait and battery is >10%)
Blue Landscape (when phone is landscape and battery is >10%)
Red Portrait (when phone is portrait and battery isRed Landscape (when phone is landscape and battery is Screenshots:

Features:
Signal strength meter (represented by a bar), battery meter (also represented by a bar), low battery warning, clock (HH:MM:SS), animations (low-range scan, particle sensor activity - similar to equaliser effect, interface activity, red alert animation), and interface auto rotate (as mentioned above).
Post any questions, comments, and/or error reports you may have.

Edit: I made a video of it in action on my K850i for those who don't have K850i and want to check it out: Link.

[ This Message was edited by: LCARS-Expert on 2007-12-13 17:30 ]
--
Posted: 2007-12-12 20:03:32
Edit : Quote

zaxan Posts: 418

Umm, seems like a dead link :S
--
Posted: 2007-12-12 20:09:22
Edit : Quote

LCARS-Expert Posts: 194

Actually, its not working yet... Takes long for it to start functioning.
Ah! It works now (Use Right click -> Save target as...)

[ This Message was edited by: LCARS-Expert on 2007-12-12 19:12 ]
--
Posted: 2007-12-12 20:11:09
Edit : Quote

zaxan Posts: 418

Yep, works now. Looks good - nice design
--
Posted: 2007-12-12 20:20:00
Edit : Quote
Page12345678>

New Topic   Reply
Forum Index

Esato home