You Are Here:

Community: Wiki

This page was last modified on 14 December 2007, at 20:38.

Como detectar eventos de tecla em Flash Lite

From Forum Nokia Wiki

O Flash Lite, igualmente a outras tecnologias, disponibiliza eventos de teclado que podem ser utilizados através de manipuladores de evento e constantes utilizadas para representar as teclas do dispositivo.

Contents

Independente da Plataforma

O mecanismo de detecção implementado na tecnologia Flash Lite é independente da plataforma onde o conteúdo seja executado, ao contrário de implementações Java ME existentes no mercado. Isto implica diretamente na velocidade de criação, simplicidade no desenvolvimento e diminuição da curva de fragmentação do conteúdo.

Eventos e Constantes

A classe Key e a ExtendedKey são responsáveis por definir todas as constantes respectivas para cada teclado. Os dois eventos que podem ser lançados são o onKeyDown e o onKeyUp.

Exemplo

// seta o conteúdo para tela inteira
fscommand2("FullScreen", true);
 
// habilita o uso das softkeys em seu projeto mobile
fscommand2("SetSoftKeys", "Left", "Right");
 
// define um ouvinte dos eventos de tecla
var objOuvinte:Object = new Object();
 
// define a função onKeyDown
objOuvinte.onKeyDown = function() {
getKey("Pressed");
}
 
// define a função onKeyUp
objOuvinte.onKeyUp = function() {
getKey("Released");
}
 
// escreve no textfield o conjunto tecla pressionada/ação realizada
function getKey(pAction:String):Void {
switch(Key.getCode()) {
case 53:
fscommand2("Quit");
case Key.ENTER:
txtTeclas.text = "Enter Key " + pAction;
break;
case Key.UP:
txtTeclas.text = "Up Key " + pAction;
break;
case Key.DOWN:
txtTeclas.text = "Down Key " + pAction;
break;
case Key.LEFT:
txtTeclas.text = "Left Key " + pAction;
break;
case Key.RIGHT:
txtTeclas.text = "Right Key " + pAction;
break;
case ExtendedKey.SOFT1:
txtTeclas.text = "SoftKey Left " + pAction;
break;
case ExtendedKey.SOFT2:
txtTeclas.text = "SoftKey Right " + pAction;
break;
default :
txtTeclas.text = "Key " + Key.getAscii() + " " + pAction;
}
}
 
// adiciona um observador ao eventos de teclado
Key.addListener(objOuvinte);
 
// criacao de um objeto textfield dinamicamente
this.createTextField("txtTeclas",
this.getNextHighestDepth(),
0,
0,
Stage.width,
Stage.height);
 
txtTeclas.text = "Application started\nPress '5' to quit.";

Autor

FelipeAndrade 17:36, 14 December 2007

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fTalkE3aE4cargeE5fscreenE5fsaverX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ