Vector renamed to ArrayList

As days before i posted about AsWing Flash Player 10 compatibility, i saw that the new FP class Vector is not top class yet in Flex SDK 4, but today, fudo posted a issue at aswing forum, i notice that in Flash CS4, it is already a top class.

So i did the renaming, the new name is org.aswing.util.ArrayList, please update from svn if you want to get this change. If you just want swc file, you can download it here http://svn.aswing.org/aswing/trunk/AsWing/swc/AsWing.swc.


How to make a Popup always on top?

Some guys asked me about this question for times, i thought i should make a post here since you want to know this too.:)

Well, all the Popups in AsWing, including JPopup and all its sub classes such as JWindow JFrame, has their owner — the first param of their constructor, for example new JFrame(owner, …), the owner specified where the popups create their assets. You can set a default owner for all popups by calling AsWingManager.init(defaultOwner, …) or AsWingManager.setRoot(defaultOwner), if there’s a default owner set, you can pass null to the popup constructors, null means to use default one.

So, how to make a popup on top of others? Yes, you already know, just make its owner on top of others, for example, there’s two sprite on your stage, sprite2 is on top of sprite1, if you call AsWingManager.setRoot(sprite1) to make sprite1 as default owner, then you created a popup with sprite2 as its owner for example topFrame = new JFrame(sprite2, …), then you’ll got topFrame always on top of other popups which created with default owner.

BTW, the owner can be a JPopup instance too, if a owner is a popup, the created popup will be its sub popup, always on top of parent popup and if parent popup hide or minimized the sub popup will be non-visible.

Here’s a demo:

public class TopPopup extends Sprite{

private var sprite1:Sprite;
private var sprite2:Sprite;

public function TopPopup(){
super();
sprite1 = new Sprite();
sprite2 = new Sprite();
addChild(sprite1);
addChild(sprite2);

AsWingManager.initAsStandard(sprite1);
createFrame(null, "Normal Frame1");
createFrame(null, "Normal Frame2");
createFrame(createFrame(null, "Parent"), "Sub").setSizeWH(100, 80);
createFrame(sprite2, "Top Frame").setSizeWH(200, 140);
}

private function createFrame(owner:*, title:String):JFrame{
var frame:JFrame = new JFrame(owner, title);
frame.setDragDirectly(true);
frame.setSizeWH(140, 100);
frame.setLocationXY(Math.random()*200, Math.random()*100);
frame.show();
return frame;
}

}

TopPopup
(Click here to run the SWF)


Create a AsWing’s NumericStepper

Although we have JAdjuster component for AsWing, but sometimes people ask us for NumericStepper, most time, we tell them just use JAdjuster, we know it’s different, but most time they are replacable.

Well, if you do want a NumericStepper component, it’s easy to create by your self, just combine with JTextField+2Button, with a BoundedRangeModel, a basic MVC NumericStepper component born.

Here’s a example implementation, see the demo screenshot below:
NumericStepper

The test App source code:

package{

import flash.display.Sprite;
import flash.events.Event;

import org.aswing.*;

public class NumericStepperTest extends Sprite{

private var infoText:JTextArea;
private var ns:NumericStepper;

public function NumericStepperTest(){
super();
AsWingManager.initAsStandard(this);
var frame:JFrame = new JFrame(null, "NumericStepperTest");
var topPane:JPanel = new JPanel();
ns = new NumericStepper();
var button:JButton = new JButton("Reset");
topPane.appendAll(button, ns);

infoText = new JTextArea();
frame.getContentPane().append(topPane, BorderLayout.NORTH);
frame.getContentPane().append(
new JScrollPane(infoText), BorderLayout.CENTER);
frame.setSizeWH(300, 300);
frame.show();

ns.addStateListener(__nsStateChanged);
button.addActionListener(__resetValue);
}

private function __resetValue(e:Event):void{
ns.getModel().setValue(50);
}

private function __nsStateChanged(e:Event):void{
infoText.appendByReplace("value : " + ns.getModel().getValue()+"\n");
infoText.scrollToBottomLeft();
}
}
}

Well, for copyright reason, i can’t post all of the component codes, maybe after the book published, there will be a downloadable version.

But trust me, if you want, you can implement it easily by yourself, a Container with a BorderLayout, left is a JTextField(lost border and background), right is a Box contains two JButton with Arrow Icons, and with a BoundedRangeModel to hold the data(you can take JAdjuster as example), finally create a Border to your NumericStepper, it is!


AsWing Flash Player 10 compatibility

Some days ago, Stef and Oliver told about the flash player 10 new class Vector conflict with AsWing’s org.aswing.util.Vector, seems we need to rename AsWing one to another name. Some like ASVector(since we have ASFont, ASColor etc.) or just ArrayList.

But today i finally got a chance to try Flex4 SDK, i compiled a SWF with AsWing component and FP10 Vector, in fact it is __AS3__.vec.Vector, not a top class. There’s not any problem, every thing runs very well.

So, i guess, maybe after Flex 4 SDK formal version released, Vector will become a top class?
Then, there will not have problem too, just, if you use two Vector class in same class file, you have to always use the full name of org.aswing.util.Vector, it’s not really a problem, just, hmmm, not convenient.

I can’t just rename the class name right now before more full test, but i guess i will finally rename our Vector to ArrayList, and maybe replace most our Vector use to Adobe’s, since it is much faster?

Except this, i have not found any other compatibility problem of AsWing on FP10, if you found some, please must tell me!:)


AsWing Flash Player 10 compatibility

Some days ago, Stef and Oliver told about the flash player 10 new class Vector conflict with AsWing’s org.aswing.util.Vector, seems we need to rename AsWing one to another name. Some like ASVector(since we have ASFont, ASColor etc.) or just ArrayList.

But today i finally got a chance to try Flex4 SDK, i compiled a SWF with AsWing component and FP10 Vector, in fact it is __AS3__.vec.Vector, not a top class. There’s not any problem, every thing runs very well.

So, i guess, maybe after Flex 4 SDK formal version released, Vector will become a top class?
Then, there will not have problem too, just, if you use two Vector class in same class file, you have to always use the full name of org.aswing.util.Vector, it’s not really a problem, just, hmmm, not convenient.

I can’t just rename the class name right now before more full test, but i guess i will finally rename our Vector to ArrayList, and maybe replace most our Vector use to Adobe’s, since it is much faster?

Except this, i have not found any other compatibility problem of AsWing on FP10, if you found some, please must tell me!:)


new LookAndFeel - ChromeLAF & BlueLAF

based on SkinBuilderLAF

1 ChromeLAF

You can get the source from the svn http://svn.aswing.org/aswing/trunk/ChromeLAF/  Some screenshot here:
chromeLAF

2 BlueLAF

You can get the source from the svn http://svn.aswing.org/aswing/trunk/BlueLAF/  Some screenshot here:

bluenessLAF


new LookAndFeel - PPZhaoLAF

zppsky has contributed PPZhaoLAF yesterday, it is a very beautiful Skin based on SkinBuilderLAF.

Some screenshot here:

You can download it from here now(Included source and swc files):

Thanks zppsky very much for sharing his product.


Important bugfix please update

Well, from AsWing 1.4, we fixed a important bug(a preferred size cache bug that a non-valid component invalidate will not get cache fresh), but sadly we brought another bug : JList/JTree/JTable’s CellPane will always make JList/JTree/JTable not valid, so JList/JTree/JTable will do validating/layouting every frame, we can hard to see this problem, because it generally will not course eyeable problem, but it make application doing useless extra counting, but some case, it cause eyeable problem too, for example your if ListCell load resources when set value, it may continuously start loading every frame, then you can’t see anything been loaded, that’s how i found this bug.

Now, it is fixed on svn, please update it to make your application more friendly.
If you use swc, you can download it from here : http://svn.aswing.org/aswing/trunk/AsWing/swc/AsWing.swc


GuiBuilder 1.4.2 with haXe code generator released

We are happy to announce AsWing GuiBuilder 1.4.2 release, with the haXe code generator contributed by Johan Coppens, now GuiBuilder may be more useful for haXe coders. (see also Using AsWing/as3 with Haxe)

Thanks Johan Coppens for the generator implementation to make us a chance to release this version.

guihaxe

code generator

You can download it here now: http://code.google.com/p/aswing/downloads/list
The newest source code is in svn.
Enjoy!!


Tip 2, Unregular Window, JWindow+GraphicsAsset

Some times, our art designer prefer a unregular window, especially for a game UI or some cool application.

Well, here is a tip:


package{

import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.filters.DropShadowFilter;
import flash.geom.Rectangle;

import org.aswing.*;
import org.aswing.border.EmptyBorder;

public class UnregularWindow extends Sprite{

[Embed(source="windowbg.png")]
private var imgClass:Class;

private var window:JWindow;

public function UnregularWindow(){
super();

AsWingManager.initAsStandard(this);

window = new JWindow();
var img:DisplayObject = new imgClass() as DisplayObject;
img.filters = [new DropShadowFilter()];
//make some blank space leave to the img shadow
window.setBorder(new EmptyBorder(null, new Insets(0, 0, 4, 4)));
window.setBackgroundDecorator(new AssetBackground(img));
//or even you can directly call addChild to append a image
//window.addChild(img);

var buttonPane:JPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
buttonPane.appendAll(new JButton("OK"), new JButton("Cancel"));
window.getContentPane().append(buttonPane, BorderLayout.SOUTH);
window.getContentPane().append(new JLabel("This is a JWindow"), BorderLayout.CENTER);
window.setSizeWH(300, 300);
window.show();
//simplly make the window dragable
window.addEventListener(MouseEvent.MOUSE_DOWN, __mouseDown);
window.addEventListener(MouseEvent.MOUSE_UP, __mouseUp);
}

private function __mouseDown(e:Event):void{
window.startDrag(false, new Rectangle(0, 0, stage.stageWidth, stage.stageHeight));
}

private function __mouseUp(e:Event):void{
window.stopDrag();
}
}
}

unregular window
(Click here to run the swf)
It is simple, just add a Image to the background of the JWindow, we added a Picture in this demo, but you, you even can add a Movie to be the background. Or even a MovieClip with Shapes, Buttons created by Flash IDE…