Java Reference
In-Depth Information
The CustomNode uses the same structure as used in Fader . The node is included
in a Group that has a Scale transform that is bound to the scale instance vari-
able that is used in the timeline. Listing 12.14 depicts how this is accomplished.
Listing 12.14
Magnify - create()
public override function create(): Node {
var group: Group;
return group = Group {
transforms: Scale {
x: bind scale
y: bind scale
}
content: bind node
};
}
To use this class in a stage, just instantiate it with a node and include it in the
scene's contents. Listing 12.15 shows a way to do this.
Listing 12.15
Magnify - Usage
var scene: Scene;
var magnify: Node;
Stage {
title: "Magnify"
width: 500
height: 500
scene: scene = Scene {
content: magnify = Magnify {
// Center in scene
translateX: bind (scene.width -
magnify.layoutBounds.width)/2.0
translateY: bind (scene.height -
magnify.layoutBounds.height)/2.0
node: node
}
}
}
When this is run, the node is centered in the scene at normal size. This is shown
in Figure 12.5.
When the mouse is moved over the node, it grows to 1.5 times its normal size.
This is demonstrated in Figure 12.6.
 
Search WWH ::




Custom Search