| iiley's profileAll about iiley and AsWi...PhotosBlogLists | Help |
|
August 03 Plan to leave from this blogFinally, I decide to move, the MSN blog is disappointing.
最终,我决定离开这里了,MSN Blog让我太失望了。 July 10 AsWing Extension CollectionFor the problem whether puting XFolder into core AsWing or not, we have another idea, is a AsWing Extensions Collection page at www.aswing.org It's here: http://aswing.wiki.adaptavist.com/display/AsWing/AsWing+Extensions The idea is cool that some simple and useful component or any other aswing useful classes and be shared here easily. This will not enlarge the core AsWing library, but make people have more useful components. We'll add some other useful classes later, And we encourage and hope you to share your component very much! Hope you like. June 29 Serveral AsWing new demo are onlineThey are JCholorChooser, pallette, and component resizer, they are here:
June 20 Real single line TextField??You create a TextField with multiline = false, and then publish it, well, you think the textfield just accept single line text, you press Enter, no newline entered, you paste a new line, it is filtered. Seems every thing runs well...
But how about when you press Ctrl+Enter when your swf runs in Internet Explorer? On my machine, new line is entered, the single line textfield became a two line textfield.(Tested on Windows2000+IE6+FP8 plugin)
This is weird and annoying, but here is a solution:
Add a handler to the onScroller event, when your single line textfield scrolled, means newline is entered, then you can find out the newline code and deleted it from your textfield text, sample code:
yourTextField.onScroller = function(textField:TextField){
var str:String = textField.text; //only check it when Ctrl or Enter pressed
if(Key.getCode() == Key.CONTROL || Key.getCode() == Key.ENTER){ for(var i:Number=0; i<str.length; i++){ if(str.charCodeAt(i) == 13){ textField.text = str.substring(0, i) + str.substring(i+1); return; } } } } Well, maybe adding some thing to prototype to make all TextField avoid this issue is cool, but i'v not fixed it out in a while, welcome to discuss. June 06 JSlider DoneJSlider component is done today, it's on svn now. It come with most features from swing JSlider except value labes, but we added a new feature to replace it, it is value tip(similar to flex slider component's value tip).
See the demo here:
May 29 Brevity - a very simple syntax to create ActionScript 3 based SWFs很久没去bit-101blog了,今天一去,就发现了这个。
Brevity——使用简单的语法创建基于AS3的Flash。
Brevity相当于是一种新的简化了的AS3语言来的,bit-101估计大多做flash的都知道,作者在几年间使用flash制作了不计其数的试验动画程序(以离子效果,物理仿真为主),随着AS3,FlashPlayer9的逐渐普及,作者感觉到AS3太过于大型,对于开发大型RIA项目来说,是非常有利的,但是对于作者想要开发这种小型的试验效果的程序,就显得不是那么方便了,毕竟一个灵感突然涌上来,能够用最简便的语法快速表达出来是非常必要的,但是flashplayuer9的第二代虚拟机VM2带来的更快的速度,更多的特性,又不想错失,所以作者开发了Brevity这样的东西。
据说这相当于是Flash的Processing(Processing for Flash),以前简单看过一些Processing的东西,看来玩视觉/模拟仿真的程序玩家还挺多的。
对这方面有兴趣的可以看看bit-101的blog:
这里有个例子
可以看到,这语法,基本上和AS2就是一样,而且作者还提供了很多方便有用的类可以直接使用,爽阿。但是目前还没有公开下载的版本,网站上对于语法的介绍也很少,具体可能也还在演化之中,期待公开版本早日推出,这样我也可以玩玩了。:)
function init()
{
for(var i:int = 0; i < 1000; i++)
{
var size:Number = random(1, 10);
var color:Number = random(0, 0xffffff);
var dot:Circle = new Circle(size, color);
show(dot);
dot.randomPosition();
dot.randomVelocity(1, 5); // (min, max)
dot.move();
}
}
May 07 AsWing Beta1 Released!From more than 3 months works(not every day, yes not very fast:)), we implemented many new features to AsWing, include FocusManager, new Components, Igor Sadovskiy joined us and lead to implemented the pretty AWML support, then we are pleased to announce Beta1 was released!
Main Change Log:
----------------------------------------------------------------------------- 1. FocusManager added. 2. Keybord control functions added to every exist components. 3. AWML(AsWing Markup Language) supported. 4. Event handler way changed. Before, you just can receive one. 5. New components: JTabbedPane, JTable. 6. Many bug fixes, exists component improvements. Comments of point 4:
parammeter with you handler method, now, the way is more similar to flash core api's. For example to add clickEvent to a button: Before Beta1: button.addEventListener(Component.ON_CLICKED, __theHandler, this); ... private function __theHandler(event:Event):Void{ var theButton:JButton = JButton(event.getSource()); var clickCount:Number = Number(event.clickCount); ... } Now with Beta1: button.addEventListener(Component.ON_CLICKED, __theHandler, this); ... private function __theHandler(source:JButton, clickCount:Number):Void{ var theButton:JButton = source; ... } You can see the new way is much more convenient, you dont need object casting. ----------------------------------------------------------------------------- You can download it here now: http://aswing.wiki.adaptavist.com/display/AsWing/Downloads Demos: http://aswing.wiki.adaptavist.com/display/AsWing/Demos Online api doc: http://doc.aswing.org/api/ April 25 Next Release of AsWing will come soonJTable is almost finished now, support default/custom cell, default/custom editor, TableSorter...:)
And JList was refactored too, added set/getSelectionForeground, set/getSelectionBackground methods. ListCell changed, Cell interface added to be the super interface of TableCell and ListCell, so if you want to move to new AsWing, you need to change you ListCell implementation too.
Here's a simple MVC demo about JTable:
We plan to release a new verson after JTable and its awml support finished since there were many changes since alpha2, release a new version will be better to us and users. :) Well, about next week or in this week, we'll do the releasing. April 07 税前后工资计算器前天公司同事因为工作需要,要通过税后工资计算税前工资,手工计算比较麻烦,我就帮忙写了一个计算器,后来想着可能对其他人也许也有用,就又加上了通过税前工资计算税后工资的功能,并同时发现了一个原来的bug(变量域算错了,因此有的工资计算会得到错误的结果),好险啊,幸好我重新检查了一下,要不然以后有同事工资不对头,那可能不好了。
这里放出这个小软件,希望能对人有用。;]
软件功能:通过税后工资计算税前金额,通过税前工资计算税后金额,通过税后或者税前工资计算个人所得税。
软件采用AsWing作的界面,代码不多,如果需要源代码,请给我留言。
下载 (当前1.1版,请保持最新版)
(申明,此软件为免费软件,由此软件直接或者间接带来的经济或者非经济损失,软件作者不负任何责任不做任何赔偿) March 10 [] is different from new Array(), {} new Object() too?var n:Number = 100000; var time:Number = getTimer(); for(var i:Number=n; i>0; i--){ } trace("empty time used : " + (getTimer() - time)); time = getTimer(); for(var i:Number=n; i>0; i--){ var arr:Array = new Array(); } trace((getTimer() - time) + " ms used : new Array() 100,000 times."); time = getTimer(); for(var i:Number=n; i>0; i--){ var arr2:Array = []; } trace((getTimer() - time) + " ms used : [] 100,000 times."); time = getTimer(); for(var i:Number=n; i>0; i--){ var obj:Object = new Object(); } trace((getTimer() - time) + " ms used : new Object() 100,000 times."); time = getTimer(); for(var i:Number=n; i>0; i--){ var obj2:Object = {}; } trace((getTimer() - time) + " ms used : {} 100,000 times."); -------------------------------------------output----------------------------------------------------
empty time used : 70 713 ms used : new Array() 100,000 times. 478 ms used : [] 100,000 times. 595 ms used : new Object() 100,000 times. 386 ms used : {} 100,000 times. Then you can see, create an array by "[]" is very faster than "new Array()", and create an object by "{}" is very faster than "new Object()" too. :)
Why? aren't they same? February 26 Write Real Desktop Application with Flash And Third-party toolsYou know, the flash security makes you can't write a real desktop application with it, you can't write data to the specified location of the disk, you can't load data from the file not located at the same forlder of swf(flash6+?). Anyway, you can't do many thing as C/C++, java... can do.
I wrote a demo with JFlashPlayer , you can open and save text files with this Flash/Java application, UI based on AsWing:)
Download runable and source include package. (Don't run it at an path include blankspace or un-ASCII chars, it will make dll loaded faild, it's java problem)
//java file package iiley.desktop;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JScrollBar;
import jflashplayer.FlashPanel;
import jflashplayer.FlashPanelListener;
public class JFPSample extends JFrame implements FlashPanelListener {
private FlashPanel flashPanel;
public JFPSample(){
super("HomeEnvGenerator");
FlashPanel.setRequiredFlashVersion("7");
//create the flash panel with scrollbar.swf and an error image
flashPanel = new FlashPanel(new File ("./flash.swf"), createErrorImage(), true);
getContentPane().add(flashPanel, BorderLayout.CENTER);
//init handler
flashPanel.addFlashPanelListener(this);
}
private Image createErrorImage(){
BufferedImage img = new BufferedImage(500, 200, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = img.createGraphics();
g.setFont(new Font("Aral", Font.PLAIN, 36));
g.setColor(Color.RED);
g.drawString("Can't Load the SWF!", 200, 300);
g.dispose();
return img;
}
//receive the flash command, if it is a scrollBarValue, then adjust
public void FSCommand(String cmd, String param) {
if(cmd.endsWith("OpenText")){
chooseFileAndPassPathToFlash();
}else if(cmd.endsWith("SaveText")){
saveText(param);
}
}
private void chooseFileAndPassPathToFlash(){
JFileChooser chooser = new JFileChooser();
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
chooser.setDialogTitle("Select a xml file to open");
chooser.showOpenDialog(this);
File file = chooser.getSelectedFile();
if(file == null){
return;
}
//changed flash movieclip's variable to notify opening a file
flashPanel.setVariable("textFilePath", file.getAbsolutePath());
}
private void saveText(String text){
JFileChooser chooser = new JFileChooser();
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
chooser.setDialogTitle("Select a path to save the file");
chooser.showSaveDialog(this);
File file = chooser.getSelectedFile();
if(file == null){
return;
}
if(file.exists()){
String msg = file.getParentFile().getName() + "/" + file.getName() + " already esists, cover it?";
int cover = JOptionPane.showConfirmDialog(this, msg);
if(cover != JOptionPane.YES_OPTION){
return;
}
}
try {
PrintWriter writer = new PrintWriter(
new OutputStreamWriter(
new FileOutputStream(file),
"UTF-8"));
writer.print(text);
writer.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
}
}
public static void main(String[] args){
JFPSample sample = new JFPSample();
sample.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
sample.setBounds(10, 100, 520, 220);
sample.setVisible(true);
}
}
//------AS file---- import org.aswing.BorderLayout;
import org.aswing.FlowLayout;
import org.aswing.JButton;
import org.aswing.JLabel;
import org.aswing.JPanel;
import org.aswing.JScrollPane;
import org.aswing.JTextArea;
import org.aswing.JWindow;
import org.aswing.utils.Delegate;
/**
* @author iiley
*/
class iiley.desktop.JFPSample extends JWindow {
private var root:MovieClip;
private var loader:XML;
private var xmlText:JTextArea;
private var openButton:JButton;
private var saveButton:JButton;
public function JFPSample(root:MovieClip) {
super(root);
//init handler to java(Note that Java App will change the property)
root["textFilePath"] = "";
root.watch("textFilePath", Delegate.create(this, __pathGot));
//This is important, make window keep same size to the Stage, Because JFlashPlayer may change the stage size
Stage.scaleMode = "noScale";
Stage.align = "TL";
Stage.addListener({onResize:Delegate.create(this, __onStageResized)});
//create and layout components
xmlText = new JTextArea();
openButton = new JButton("Open Text");
saveButton = new JButton("Save Text");
getContentPane().append(new JLabel("The text:"), BorderLayout.NORTH);
getContentPane().append(new JScrollPane(xmlText), BorderLayout.CENTER);
var buttonPane:JPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 20));
buttonPane.append(openButton);
buttonPane.append(saveButton);
getContentPane().append(buttonPane, BorderLayout.SOUTH);
//init handlers for components
openButton.addActionListener(__openTextFile, this);
saveButton.addActionListener(__saveTextFile, this);
//init loader handler
loader = new XML();
loader.onData = Delegate.create(this, __onTextData);
}
/**
* Java changed xmlFilePath variable, means file path got
*/
private function __pathGot(prop, oldVal, newVal):Void{
var path:String = newVal;
loader.load(path);
}
private function __onTextData(src:String):Void{
xmlText.setText(src);
}
/**
* Fire command to java app let it save the xml text
*/
private function __saveTextFile():Void{
fscommand("SaveText", xmlText.getText());
}
/**
* Fire command to java app let it open dialog to choose a xml file path
*/
private function __openTextFile():Void{
fscommand("OpenText");
}
private function __onStageResized():Void{
setSize(Stage.width, Stage.height);
}
public static function main(entry:MovieClip):Void{
var sample:JFPSample = new JFPSample(entry);
sample.setSize(Stage.width, Stage.height);
sample.setVisible(true);
}
}
So third-party tools borns to make you can do these, they are:
JFlashPlayer (Windows Java Swing)
SWTFlash (Windows Java SWT)
mdm ZINC (Commercial, powerful)
....
*referrence:
February 16 AsWing source repository moved to OSFlash SVNThe old cvs repository is at sourceforge, it'll not be maintained any more. The new subversion repository is here: see www.aswing.org for details.
With this moving, i also did some big refactors, many package names refactore, org.aswing.events renamed to org.aswing.event, org.aswing.utils renamed to org.aswing.util, etc. And also after alpha2, there's FocusManager finished now, you can press keybord Tab/Ctrl+Tab/Shift+Tab to navigating and focus components now. February 05 Really MovieClip.hitTest(globalX,globalY) ?Well from flash8 livedocs, we can see this:
hitTest (MovieClip.hitTest method)
Parameters
It said that x, y are defined in the global coordinate space. If i am not understanding wrong, the global coordinate space should be the MovieClip.localToGlobal() returned point's coordinate space. Well, if it is, i should say, the livedocs has mistakes. lets make a test: First create a read rectangle movieclip at root stage. named aMC. Then add these code at frame1: //-------------------------------------------------------------------------- var mouseLis:Object = new Object(); //-------------------------------------------------------------------------- Test this movie, well, you think if mc hit the mouse point(in global coordinate space), it will trace "Hit"? No, it will trace "Not hit!". If i replace var p:Object = {x:mc._xmouse, y:mc._ymouse}; to: var p:Object = {x:_root._xmouse, y:_root._ymouse}; //mc.localToGlobal(p);//don't call here. Then, it will be runs well. So you can see, the livedocs's explanation has problems. But, in fact what coordinate space it use indeed? I just know normally it is _root coordinate, but when there's other _level for example you loaded a swf to _level2, the mcs in _level2 should use what coordinate space to do hitTest??? _level0 ? or _level2? January 23 AsWing Alpha2 Released!For a long time, AsWing alpha2 final released with a new nicer website and 8 more components than alpha1, there's new projects comes too, AsIcon and AsIO created by Guy Fraser, pretty cool projects. More details here : http://www.aswing.org January 09 继续活着在经过为期1周的病痛折磨后
我依旧顽强的活着
面对明天的拆线工作
我满怀继续活着的希望
准备踏上这个充满离奇故事的征程
为了迎接并庆祝一个可能还算美好的将来
我必须先让自己抽上两根儿——白沙
|
|
|