Code snippets for LG KU990 Viewty themes & apps
These code snippets are only compatible with the LG KU990 Viewty and related models, such as the KU990i and KU990GO.
Haptic feedback on button presses
This simple snippet makes the screen vibrate when called - generally used with the onPress action of buttons.
- platform.touch_sound();
Example usage
- my_btn.onPress = function() {
- platform.touch_sound();
- }
- // makes the button with the instance name 'my_btn' vibrate when pressed on the phone.
Open the NYX menu or launch applications
Use the following function below with either a Dep or Id value (you can find these in LGAPP/Media/swf/en-UK.xml) to launch a menu page or application.
- function eventCall(dep:String, id:String) {
- if (id == undefined || id == "") {
- //No id - open menu Nyx page
- platform.setMenuOn();
- _root.idleQuick = true;
- _root.QuickSet(dep);
- } else {
- //Open application
- platform.launch_module(id);
- }
- };
Example usage
- eventCall("") // Open main NYX menu
- eventCall("", "0x27e00000"); // Open Inbox
- eventCall("3,1,1", ""); //Open browser submenu page
Displaying the 'Touch Ring' animation
Use the following two functions to show & hide the default style 'Touch Ring' animation.
To show the touch ring animation at a location xPos,yPos with a scaling factor scalePercent (100 is original size):
- show_pressAni(xPos:Number, yPos:Number, scalePercent:Number);
To hide the touch ring animation, simply call:
- out_pressAni();
Example usage
- my_btn.onPress = function() {
- show_pressAni(120, 200, 50);
- }
- my_btn.onReleaseOutside = function() {
- out_pressAni();
- }
- my_btn.onRelease = function() {
- out_pressAni();
- //Do something else
- }
This will show the touch ring animation at the center of the LG KU990 Viewty screen (120, 200) at half its original size when the button "my_btn" is pressed. It then hides the animation when the button is released.
Launching the Dialpad
If you want to open the Dialpad to let users call a number, simply use this little snippet.
- platform.launch_module("event:dialing");
Example usage
- my_btn.onRelease = function() {
- platform.launch_module("event:dialing");
- }
Get SMS/Message counts
- function getMessages() {
- _root.GetMessageCount(); //Call to Nyx - updates message counts
- var inboxCount:Number = _root.inboxCount;
- var newInboxCount:Number = _root.newInboxCount;
- var draftCount:Number = _root.draftCount;
- var sentCount:Number = _root.sentCount;
- var outboxCount:Number = _root.outboxCount;
- //Check to see if message counts have loaded yet
- //it can take a few seconds at phone startup
- if (isNaN(inboxCount)) {
- inboxCount = 0;
- newInboxCount = 0;
- draftCount = 0;
- sentCount = 0;
- outboxCount = 0;
- }
- //Now do what you like with the inboxCount, newInboxCount
- //draftCount, sentCount and outboxCount variables
- //You probably want to update you messages counts every
- //5 seconds or so.
- }
Example usage
- getMessages();
Call this function everytime you want to update your message counters.
At the end of the function you would normally add a few statements to put the message counts into text-boxes, such as
- //put this at the end of the getMessages function
- my_text.text = newInboxCount + "/" + inboxCount
would update the 'my_text' text-box with the number of new messages and total messages in the users inbox.
You cannot get message counts for e-mails. Also it is not possible to retrieve the number of missed calls etc.
Get the current profile
To determine which profile the user currently has set, use the following snippet:
- function getProfile():Number {
- //Update profile info
- _root.GetProfileInfo();
- var profileNum:Number = _root.profileType;
- if (isNaN(profileNum)) {
- //Not a Number
- profileNum = 1;
- }
- return profileNum;
- }
profileNum is a number from 1 - 8.
Example usage
- var currentProfileNum:Number = getProfile();
Set the current profile
Unlike most menu options, the profiles do not have an associated 'dep' and 'id' (the ones listed in XML files do not do anything).
In order to set profiles, you'll need to use the following code:
- function setProfile(profileNum:Number) {
- platform.setMenuOn();
- platform.setDepth(2);
- platform.setMenuNum();
- platform.setProfileNum(profileNum);
- platform.activateCall();
- var iCount = 0;
- timer_mc.onEnterFrame = function() {
- iCount++;
- if (iCount >= 3) {
- _global.platform.setMenuReady();
- _global.platform.setDepth(0);
- _global.platform.setMenuNum();
- _global.platform.setMenuReady();
- delete this.onEnterFrame;
- }
- }
- }
You'll also need a MovieClip with the instance name 'timer_mc' in the same scene as the code, and it should span all the frames which contain interfaces that allow the user to change profiles.
profileNum is a number from 1 - 8: 1 = Normal, 2 = Silent, 3 = Vibrate, 4 = Outside, 5 = Headset, 6 & 7 & 8 = User defined profiles.
Example usage
- setProfile(1); //Sets the 'Normal' profile
Bear in mind that if the user has a headset plugged in, only the headset profile can be set, and if the user does not have the headset plugged in, the headset profile cannot be set.
Get the names of the user defined profiles
The names for most profiles are hard-coded in the language files, but for the user-defined ones you can detect their current names as follows:
- function getCustomProfileNames():Array {
- platform.getUserdefineList();
- var userNameArr:Array = _root.userdefine_arr;
- if (userNameArr[0] == undefined || userNameArr.length != 3) {
- //Error - names may not be loaded yet
- userNameArr = new Array("Custom 1", "Custom 2", "Custom 3");
- }
- return userNameArr;
- }
The array returned by the function has 3 elements - the names of the three custom profiles.
Example usage
- var customArr:Array = getCustomProfileNames();
- //Set profile names to text boxes
- //You'll need to create these text boxes in your theme
- //or use the array in your own way
- custom1_txt.text = customArr[0];
- custom2_txt.text = customArr[1];
- custom3_txt.text = customArr[2];
Detect whether the headset is plugged in
Use the following handy snippet to detect whether the user has their headset plugged in.
- function getHeadsetStatus():Boolean {
- var headSta:Boolean = false;
- //Update profile info
- _root.GetProfileInfo();
- var hSta = _root.headsetSta;
- if (hSta == "on" || hSta == 1 || hSta == true) {
- headSta = true;
- }
- return headSta;
- }
Example usage
- var headsetOn:Boolean = getHeadsetStatus();
- if (headsetOn) {
- //User has headset plugged in
- } else {
- //No headset plugged in
- }
Gridlock theme
GridLock is a simple theme that combines the Lock Slider and Grid Menu. It also detects when the Nyx menu is opened, and hides the grid menu and lockscreen. Source code and sample swf included in the download (works on the mobile phone - but you must enter Dep and Id values in settings.txt for the items to function properly)
Loading and saving data using fscommand2
NOTE: All variables saved/loaded must be Numbers, and can be from -999999999 to 999999999. NOTE2: All methods with 'Recommended' next to them do not affect any saved user preferences.
How to read this list
For SET (Save) commands, the variable that you save is
named 'saveVar'.
For GET (Load) commands, the saved data is loaded into
a variabled named 'loadVar'.
- Command 1 (Do not use as conflicts with CYL, Recommended)
- -----------------------------------------------------------------
- SET:
- fscommand2("SetVars", "widget", "analogClockSkin", saveVar);
- GET:
- fscommand2("GetVars", "widget", "analogClockSkin", "/");
- loadVar = _root.analogClockSkin;
- Command 2 (Recommended)
- -----------------------------------------------------------------
- SET:
- fscommand2("SetVars", "widget", "digitalClockSkin", saveVar);
- GET:
- fscommand2("GetVars", "widget", "digitalClockSkin", "/");
- loadVar = _root.digitalClockSkin;
- Command 3 (Recommended)
- -----------------------------------------------------------------
- SET:
- fscommand2("SetVars", "widget", "dualClockSkin", saveVar);
- GET:
- fscommand2("GetVars", "widget", "dualClockSkin", "/");
- loadVar = _root.dualClockSkin;
- Commands 4 & 5
- -----------------------------------------------------------------
- SET:
- var saveStr:String = "widget_x="+saveVar1+"&widget_y="+saveVar2;
- platform.setWidgetData(saveStr);
- GET:
- platform.getWidgetXY();
- loadVar1 = _root.widget.widget_x;
- loadVar2 = _root.widget.widget_y;
- Commands 6 & 7
- -----------------------------------------------------------------
- SET:
- var saveStr:String = "calandar_x="+saveVar1+"&calandar_y="+saveVar2;
- platform.setWidgetCalandarData(saveStr);
- GET:
- platform.getWidgetCalandarXY();
- loadVar1 = _root.widgetCalandar.calandar_x;
- loadVar2 = _root.widgetCalandar.calandar_y;
- Command 8
- -----------------------------------------------------------------
- SET:
- fscommand2("SetVars", "menu", "widgetNum", saveVar);
- GET:
- platform.getWidgetNum();
- loadVar = _root.widgetNum;
- Command 9
- -----------------------------------------------------------------
- SET:
- fscommand2("SetVars", "widget", "calandarNum", saveVar);
- GET:
- fscommand2("GetVars", "widget", "calandarNum", "/");
- loadVar = _root.calandarNum;
comments (0)
2390
Share this page:
