Code Snippets for Developers - Page 3 in Themes forum
MyGreatPhone.com


Mobile Phone News Mobile Phone Shop Mobile Phone Forum Mobile Phone Downloads Mobile Phone Wallpapers

  Forums.MyGreatPhone.com > Mobile Phone Manufacturers > LG Forum > LG KU990 > Themes / Wallpapers / Hacking - Customisation > Themes



Code Snippets for Developers Thread

Themes Forum in Themes / Wallpapers / Hacking - Customisation Section


This example demonstrates a method of creating a sliding screen interface similar to that seen on the iPhone. Source code ...

Closed Thread
 
LinkBack Thread Tools Display Modes
  #21  
Old 26-02-2009, 10:23 PM
Moderator
Technical Ambassador
 
Join Date: Mar 2008
Posts: 2,857
Mobile Phone: XDA Ignito, LG KU990
Network: O2
Thanks: 16
Thanked 455 Times in 69 Posts
Default Sliding Screens

This example demonstrates a method of creating a sliding screen interface similar to that seen on the iPhone.

Source code + sample swf attached.

Not intended for use on phone.
Attached Files
File Type: zip Sliding Screens.zip (16.9 KB, 132 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Share with Facebook
  #22  
Old 23-03-2009, 01:29 PM
Moderator
Technical Ambassador
 
Join Date: Mar 2008
Posts: 2,857
Mobile Phone: XDA Ignito, LG KU990
Network: O2
Thanks: 16
Thanked 455 Times in 69 Posts
Default Developing Flash for Mobile Devices

Developing a theme is no different to creating a standard Flash application, though there are some special considerations that must be given as you are publishing to a mobile device (these are taken from the Adobe Flash® CS3 reference):
  • Keep the file and its code as simple as possible. Remove unused movie clips, delete unnecessary frame and code loops, and avoid too many frames or extraneous frames.
  • Using FOR loops can be expensive because of the overhead incurred while the condition is checked with each iteration. When the costs of the iteration and the loop overhead are comparable, execute multiple operations individually instead of using a loop. The code may be longer, but performance will improve.
  • Stop frame-based looping as soon as it is no longer needed.
  • When possible, avoid string and array processing because it can be CPU-intensive.
  • Always try to access properties directly rather than using ActionScript getter and setter methods, which have more overhead than other method calls.
  • Manage events wisely. Keep event listener arrays compact by using conditions to check whether a listener exists (is not null) before calling it. Clear any active intervals by calling clearInterval, and remove any active listeners by calling removeListener before removing content using unloadapplication or removeapplicationClip. Flash does not re-collect SWF data memory (for example, from intervals and listeners) if any ActionScript functions are still referring to the SWF data when a movie clip is unloaded.
  • When variables are no longer needed, delete them or set them to null, which marks them for garbage collection. Deleting variables helps optimize memory use during run time, because unneeded assets are removed from the SWF file. It is better to delete variables than to set them to null.
  • Explicitly remove listeners from objects by calling removeListener before garbage collection.
  • If a file consists of multiple SWF files that use the same ActionScript classes, exclude those classes from select SWF files during compilation. This can help reduce file download time and run-time memory requirements.
  • Avoid using Object.watch and Object.unwatch, because every change to an object property requires the player to determine whether a change notification must be sent.
  • If ActionScript code that executes on a keyframe in the timeline requires more than 1 second to complete, consider splitting up that code to execute over multiple keyframes.
  • Remove trace statements from the code when publishing the SWF file. To do this, select the Omit Trace Actions check box on the Flash tab in the Publish Settings dialog box.
  • When one SWF file loads another SWF file that contains a custom ActionScript class (for example, foo.bar.CustomClass) and then unloads the SWF file, the class definition remains in memory. To save memory, explicitly delete any custom classes in unloaded SWF files. Use the delete statement and specify the fully qualified class name, such as: delete foo.bar.CustomClass.
  • Limit the use of global variables, because they are not marked for garbage collection if the movie clip that defined them is removed.
  • Avoid using the standard user interface components (available in the Components panel in Flash). These components are designed to run on desktop computers and are not optimized to run on mobile devices.
  • Whenever possible, avoid deeply nested functions.
  • Avoid referencing nonexistent variables, objects, or functions. Compared to the desktop version of Flash Player, Flash Lite 2 looks up references to nonexistent variables slowly, which can significantly affect performance.
  • Avoid defining functions using anonymous syntax. For example, myObj.eventName = function{ ...}. Explicitly defined functions are more efficient, such as function myFunc { ...}; my Obj.eventName = myFunc;.
  • Minimize the use of Math functions and floating-point numbers. Calculating these values slows performance. If you must use the Math routines, consider precalculating the values and storing them in an array of variables. Retrieving the values from a data table is much faster than having Flash calculate them at run time.
  • Most devices that support Flash Lite play back content at about 15 to 20 frames per second (fps). The frame rate can be as low as 6 fps. During development, set the document frame rate to approximate the playback speed of the target device. This shows how the content will run on a device with limited performance. Before publishing a final SWF file, set the document frame rate to at least 20 fps or higher to avoid limiting performance in case the device supports a higher frame rate.
  • When using gotoAndPlay, remember that every frame between the current frame and the requested frame needs to be initialized before Flash plays the requested frame. If many of these frames contain different content, it could be more efficient to use different movie clips rather than using the Timeline.
  • Although preloading all content by putting it at the beginning of the file makes sense on the desktop, preloading on a mobile device can delay file startup. Space content throughout the file so that movie clips are initialized as they are used.

Last edited by joe13; 27-03-2009 at 11:03 AM..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Share with Facebook
  #23  
Old 29-03-2009, 04:39 PM
Moderator
Technical Ambassador
 
Join Date: Mar 2008
Posts: 2,857
Mobile Phone: XDA Ignito, LG KU990
Network: O2
Thanks: 16
Thanked 455 Times in 69 Posts
Default Loading/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 FILE:
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'.

Code:
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;

Last edited by joe13; 29-03-2009 at 06:49 PM..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Share with Facebook
The Following User Says Thank You to joe13 For This Useful Post:
Ikarug (30-10-2009)
Closed Thread

Tags
action, actionscript, actionscript help, code, create, develop, guide, info, ku990, script, snippets, themes, viewty

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Buy a proporta case from the MyGreatPhone.com Proporta store and become a site sponsor
Similar Threads
Thread Thread Starter Forum Replies Last Post
A request to theme developers DaveOrNoDave Themes 24 17-06-2009 06:44 PM
Some questions for theme developers! bloody Themes 3 15-06-2009 12:32 PM
For Theme Developers. (attention) nestortoledo Themes 8 27-02-2008 04:09 PM
Calling all Theme Developers!!! BBman Themes 14 21-02-2008 08:09 AM


All times are GMT. The time now is 05:33 AM.

vBulletin, Copyright ©2000 - 2009
Jelsoft Enterprises Limited.

Search Engine Friendly URLs by vBSEO 3.3.1