Productive week
22:01 | Posted by
Bret Lanius |
Edit Post
Well I've had a good week with Flash stuff. Not only did I get that CD-ROM project done. I put together a custom video player setup using XML data for a site coming online next week called http://Cleverstories.com.
I've had a WeatherBug application sitting idle for a while due to flash player's new security policies for cross domain loading of content. In the past as long as the host site had a policy file all was good, Well I got WeatherBug to add one but then I got new error and had to read up on Flash Policy files and since I was using an image loader class from http://calypso88.com I either had to modify his code or write my own loader. So first I figured I try to modify his and that fixed it. So now here it is.
http://bretlanius.com/flash/lab/weatherbug/weatherbug2.html
Ok that is still not all, I was working on something a week ago and the idea of using fullscreen on the web was discussed but the inablility to input text was an issue. I had seen a tutorial on doing a on screen keyboard but I had trouble following it. So I thought the SimpleTable component included withKM7 might make it fairly easy, and turns out it did. This approach may not have been the best way to go but it works and for allowing a user to input say a name and email address it will suffice.
You can see it at http://bretlanius.com/flash/km7stuff/keyboardtest.html now this I did as an actual component so that all I have to do is this in KM:
import com.bretlanius.ui.*;
import flash.stage.*;
import gs.*;
var k:keyboard=new keyboard();
k.visible=false;
addChild(k);
k.x=-200;
k.y=30;
txt1.addEventListener(FocusEvent.FOCUS_IN,tready);
txt2.addEventListener(FocusEvent.FOCUS_IN,tready);
btn1.addEventListener(MouseEvent.CLICK, fullScreen);
//stage.focus = txt1;
function fullScreen(event:MouseEvent):void {
stage.displayState=StageDisplayState.FULL_SCREEN;
}
function tready(e:FocusEvent){
TweenLite.to(k, 1, {autoAlpha:1,x:e.currentTarget.x-k.width, y:e.currentTarget.y});
k.setSrc(e.currentTarget);
}
Here is the source for the keyboard.
package com.bretlanius.ui
{
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.text.TextFormat;
import km.display.*;
import km.components.*;
import km.skins.*;
/**
* ...
* @author Bret Lanius
*/
public class keyboard extends Sprite
{
var _txt:TextField;
var rows:Array = new Array;
var shift:Boolean;
var table:SimpleTable;
function keyboard() {
shift = false;
rows[0] = Array('1', '2', '3', '4', '5', '6', '7', '8', '9', '0');
rows[1] = Array('q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p');
rows[2] = Array('a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';');
rows[3] = Array('z', 'x', 'v', 'c','b', 'n', 'm', '.', '/','DEL');
rows[4] = Array('Sft', '\\','@','.com', 'Space',', ',' - ','_',' !','
rows[5]= Array('~', '`', '#', '$','%', '^', '&', '*', '(',')');
table = new SimpleTable();
table.onCellCreate = fn;
table.setSize(500, 200,rows[0].length,rows.length);
table.cellPadding = 2;
table.update();
addChild(table);
table.cell(4, 4).span(2, 1);
table.update();
}
private function fn(cell:SimpleTableCell):void {
cell.content = new LabelButton();
//var fmt:TextFormat = new TextFormat;
//fmt.bold = true;
//cell.content.label.text.setTextFormat(fmt);
cell.content.label.text =rows[cell.row][cell.col];
cell.vars.value =rows[cell.row][cell.col];
ScriptedSkin.applyTo(cell.content);
cell.content.addEventListener(MouseEvent.CLICK, bClicked);
}
private function bClicked(e:MouseEvent) {
switch (e.currentTarget.parent.vars.value) {
case 'Space':
_txt.text += " ";
break;
case '
_txt.text = _txt.text = _txt.text.substr(0, _txt.text.length - 1);
break;
case 'Sft':
shift = !shift;
if (shift) {
e.currentTarget.label.text = "SHFT";
upperKeys(true);
}else {
e.currentTarget.label.text = "Sft";
upperKeys(false);
}
break;
case 'Alt':
break;
case 'DEL':
break;
case " ":
break;
default:
if (shift) {
_txt.text += e.currentTarget.parent.vars.value.toUpperCase();
//shift = false;
}else{
_txt.text += e.currentTarget.parent.vars.value;
}
}
}
private function upperKeys(toggle) {
for (var i = 0; i < table.colCount; i++){
for (var x = 0; x < table.rowCount;x++ ){
if (toggle) {
table.cell(i, x).content.label.text = table.cell(i, x).content.label.text.toUpperCase();
}else {
table.cell(i, x).content.label.text = table.cell(i, x).content.label.text.toLowerCase();
}
}
}
}
public function setSrc(t:TextField) {
_txt = t;
}
}
}
I'd be interested in seeing any ideas on how to improve this component.
I've had a WeatherBug application sitting idle for a while due to flash player's new security policies for cross domain loading of content. In the past as long as the host site had a policy file all was good, Well I got WeatherBug to add one but then I got new error and had to read up on Flash Policy files and since I was using an image loader class from http://calypso88.com I either had to modify his code or write my own loader. So first I figured I try to modify his and that fixed it. So now here it is.http://bretlanius.com/flash/lab/weatherbug/weatherbug2.html
Ok that is still not all, I was working on something a week ago and the idea of using fullscreen on the web was discussed but the inablility to input text was an issue. I had seen a tutorial on doing a on screen keyboard but I had trouble following it. So I thought the SimpleTable component included withKM7 might make it fairly easy, and turns out it did. This approach may not have been the best way to go but it works and for allowing a user to input say a name and email address it will suffice.
You can see it at http://bretlanius.com/flash/km7stuff/keyboardtest.html now this I did as an actual component so that all I have to do is this in KM:
import com.bretlanius.ui.*;
import flash.stage.*;
import gs.*;
var k:keyboard=new keyboard();
k.visible=false;
addChild(k);
k.x=-200;
k.y=30;
txt1.addEventListener(FocusEvent.FOCUS_IN,tready);
txt2.addEventListener(FocusEvent.FOCUS_IN,tready);
btn1.addEventListener(MouseEvent.CLICK, fullScreen);
//stage.focus = txt1;
function fullScreen(event:MouseEvent):void {
stage.displayState=StageDisplayState.FULL_SCREEN;
}
function tready(e:FocusEvent){
TweenLite.to(k, 1, {autoAlpha:1,x:e.currentTarget.x-k.width, y:e.currentTarget.y});
k.setSrc(e.currentTarget);
}
Here is the source for the keyboard.
package com.bretlanius.ui
{
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.text.TextFormat;
import km.display.*;
import km.components.*;
import km.skins.*;
/**
* ...
* @author Bret Lanius
*/
public class keyboard extends Sprite
{
var _txt:TextField;
var rows:Array = new Array;
var shift:Boolean;
var table:SimpleTable;
function keyboard() {
shift = false;
rows[0] = Array('1', '2', '3', '4', '5', '6', '7', '8', '9', '0');
rows[1] = Array('q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p');
rows[2] = Array('a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';');
rows[3] = Array('z', 'x', 'v', 'c','b', 'n', 'm', '.', '/','DEL');
rows[4] = Array('Sft', '\\','@','.com', 'Space',', ',' - ','_',' !','
rows[5]= Array('~', '`', '#', '$','%', '^', '&', '*', '(',')');
table = new SimpleTable();
table.onCellCreate = fn;
table.setSize(500, 200,rows[0].length,rows.length);
table.cellPadding = 2;
table.update();
addChild(table);
table.cell(4, 4).span(2, 1);
table.update();
}
private function fn(cell:SimpleTableCell):void {
cell.content = new LabelButton();
//var fmt:TextFormat = new TextFormat;
//fmt.bold = true;
//cell.content.label.text.setTextFormat(fmt);
cell.content.label.text =rows[cell.row][cell.col];
cell.vars.value =rows[cell.row][cell.col];
ScriptedSkin.applyTo(cell.content);
cell.content.addEventListener(MouseEvent.CLICK, bClicked);
}
private function bClicked(e:MouseEvent) {
switch (e.currentTarget.parent.vars.value) {
case 'Space':
_txt.text += " ";
break;
case '
_txt.text = _txt.text = _txt.text.substr(0, _txt.text.length - 1);
break;
case 'Sft':
shift = !shift;
if (shift) {
e.currentTarget.label.text = "SHFT";
upperKeys(true);
}else {
e.currentTarget.label.text = "Sft";
upperKeys(false);
}
break;
case 'Alt':
break;
case 'DEL':
break;
case " ":
break;
default:
if (shift) {
_txt.text += e.currentTarget.parent.vars.value.toUpperCase();
//shift = false;
}else{
_txt.text += e.currentTarget.parent.vars.value;
}
}
}
private function upperKeys(toggle) {
for (var i = 0; i < table.colCount; i++){
for (var x = 0; x < table.rowCount;x++ ){
if (toggle) {
table.cell(i, x).content.label.text = table.cell(i, x).content.label.text.toUpperCase();
}else {
table.cell(i, x).content.label.text = table.cell(i, x).content.label.text.toLowerCase();
}
}
}
}
public function setSrc(t:TextField) {
_txt = t;
}
}
}
I'd be interested in seeing any ideas on how to improve this component.
| Reactions: |
Subscribe to:
Post Comments (Atom)


0 comments:
Post a Comment