Building a BMI Calculator Application in Flash Lite – Step By Step Walkthrough
Code:
Screen 1 Â – “actions” layer frame 1 :
Stage.scaleMode = "noScale";
fscommand2("FullScreen",true);
var mode:String = null;
var softKeyListener:Object = new Object();
/* Softkey component configure */
softKeys_mc.onSoftKeyDown = Delegate.create(this,onSoftKeyPress);
softKeys_mc._LSK = "Start";
softKeys_mc._MSK = "";
softKeys_mc._RSK = "Quit";
softKeys_mc._isLSKEnabled = true;
softKeys_mc._isMSKEnabled = false;
softKeys_mc._isRSKEnabled = true;
The above code goes into the first frame of “actions” layer. We prepare our application by importing the Delegates class for scope resolution. Next we set the stage’s scale mode to “noscale” and switch our application to full screen mode. The mode variable will hold the selected unit scale of calculation. softKeyListener is a generic object that will listen for key-press events.
softKeys_mc is the softkeys component from Sony Ericsson’s component set. We create our key handler function for the Softkeys component using the delegate class, and then configure the three sofkeys that the component has to offer.
LSK – Left Soft Key
MSK – Middle Soft Key
RSK – Right Soft Key
function onSoftKeyPress(keyPressed:String)
{
switch(keyPressed)
{
case "LSK":
this.gotoAndStop(this.nextFrame());
break;
case "RSK":
status = fscommand2("Quit");
break;
}
}
The onSoftKeyPress() function:
The onSoftKeyPress handler is triggered with user presses a Softkey or the Enter key (for MSK). We then check which key was pressed and take the appropriate action. Since this is only our first screen , so we provide user with only two options – “Move to next screen” or “Quit”.
Screen 2 Â – “actions” layer frame 2 :
/* SingleListRow component configure */
metricTypeSelector.onSelect = Delegate.create(this,onTypeSelect);
/* Softkey component configure */
delete softKeys_mc.onSoftKeyDown;
softKeys_mc.onSoftKeyDown = Delegate.create(this,onSoftKeyPress);
softKeys_mc._LSK = "";
softKeys_mc._MSK = "Select";
softKeys_mc._RSK = "Quit";
softKeys_mc._isLSKEnabled = false;
softKeys_mc._isMSKEnabled = true;
softKeys_mc._isRSKEnabled = true;
The above code applies to the second screen (frame 2). Here we first delete the previous handler for our Softkey component. Then we create a new SoftKey handler using the delegate class, and then configure the keys as before.
function onSoftKeyPress(keyPressed:String)
{
switch(keyPressed)
{
case "RSK":
status = fscommand2("Quit");
break;
}
}
The onSoftKeyPress() function:
The onSoftKeyPress handler is triggered with user presses Left/Right Softkey or the Enter key (MSK). We then check which key was pressed and take the appropriate action. Here we handle only the Right Soft Key (RSK). This is because the unit selector –  metricTypeSelector, implemented using the SingleListRow component already handles the MSK (Enter Key).
function onTypeSelect(sender:MovieClip, label:String, position:Number)
{
mode = label;
delete metricTypeSelector.onSelect;
this.gotoAndStop(this.nextFrame());
}
Finally when the user presses the MSK (Enter Key), we store the selected unit scale into our variable – mode. Then we delete the handler on metricTypeSelector, and move to the third screen.
Popularity: 66% [?]
June 6, 2010
Tags: Actionscript 2.0, Flash, Flash Lite, Mobile, Nokia Posted in: Actionscript 2.0, Flash Lite, Mobile, Nokia, Sony Ericsson




24 Responses
Tweets that mention Building a BMI Calculator Application in Flash Lite – Step By Step Walkthrough | Flashvisions -- Topsy.com - June 6, 2010
[...] This post was mentioned on Twitter by MojoGeeks, FMC Washington DC and fmchicago, Juan. Juan said: Building a BMI Calculator Application in Flash Lite – Step By Step Walkthrough http://dlvr.it/1Tzp6 [...]
HTC HD2 – Day 3 | GPS FANS - June 7, 2010
[...] Building a BMI Calculator Application in Flash Lite – Step By Step … [...]
Detecto ProDoc PD300DHR Digital Professional Doctor Scale – Model PD300DHR – Each | Local Doctors - June 8, 2010
[...] Building a BMI Calculator Application in Flash Lite – Step By Step Walkthrough | Flashvisions [...]
Hei,
Guys does any body know how to use shared object to create a history page for the Bmi calculations done? If anyone has any idea please leave a reply
Thanks !
download Monsterwolf full download Monsterwolf full Monsterwolf ipod
Biss Zum Ende Der Nacht - March 9, 2011
Affordable Web Hosting…
[...]below you’ll find the link to some sites that we think you should visit[...]…
slope - March 9, 2011
Affordable Web Hosting…
[...]below you’ll find the link to some sites that we think you should visit[...]…
Paycheck loan - March 13, 2011
payday cash loan…
[...]Do you have to uncover any data on this page to be inaccurate please e-mail us with corrections or updates.[...]…
local mobile monopoly - March 16, 2011
local mobile monopoly…
[...]below you’ll find the link to some sites that we think you should visit[...]…
Magniwork - March 19, 2011
Magniwork…
I found your blog via blog catalog. I thought I’d check out the post as I just wrote on this subject today. You add some great suggestions that I didn’t have. Thanks for the tips….
buy viagra - March 21, 2011
Hello!…
[...]You made some clear points there[...]…
Milwaukee Bankruptcy Lawyers - March 23, 2011
Attorneys Referral…
[...]the inclination to visit the sites we have shown you here[...]…
generic viagra - March 25, 2011
Hello…
[...]This website is the most excellent website.[...]…
la ink tattoos - March 29, 2011
Trackback, Thanks very much…
la ink tattoo designs, has linked to your web page….
the diet solution program - March 31, 2011
the diet solution program…
Thanks for the excellent blog post….
viagra - March 31, 2011
Hello…
[...]This website is the most excellent website.[...]…
granite countertops - April 1, 2011
german shepherd…
[...]followed below there can be the website link towards a world-wide-web sites i visualise be certain to use[...]…
golf prints - April 3, 2011
richard chorley golf…
Thanks for such an excellent page, bookmarked, ill visit soon!…
check it out - April 4, 2011
fantastic website…
[...] the time to read or visit the content or sites we have linked to below the [...]…
Acupressure To Induce Labor - April 6, 2011
Acupressure To Induce Labor…
Thanks for such a brilliant blog post, bookmarked and shared!…
7 Day Programmable Thermostat - April 6, 2011
7 Day Programmable Thermostat…
Thanks for such a brilliant blog post, bookmarked and shared!…
Dremel Stylus - April 6, 2011
Dremel Stylus…
Bookmarked your site, so I can visit frequently, thank you!…
Hunstanton - April 6, 2011
Hunstanton…
Trackback, I have linked to your site, thank you!…
market place - April 7, 2011
market place…
Trackback, I have linked to your site, thank you!…
Leave a Reply