Java Reference
In-Depth Information
How to do it...
The code listing given next is abbreviated to show the essential portions that drive the
application. You can get the full listing of this code from
ch05/source-code/src/image/
ImageBlendDemo.fx
.
var scene:Scene;
def w = 800; def h = 600;
def maxW = w * 0.4; def maxH = h * 0.5;
def
img1
=
ImageView
{
translateX:10 translateY:10
preserveRatio:true
fitWidth:maxW fitHeight:maxH
}
def
img2
=
ImageView
{
translateX:w - maxW translateY:10
preserveRatio:true
fitWidth:maxW fitHeight:maxH
}
def
imgPanel
=
Group
{content:[img1, img2]}
def
anim
=
Timeline
{
keyFrames: [
KeyFrame{time:1s
values: [
img1
.translateX => (w - img1.fitWidth)/2
]
}
KeyFrame{time:1s
values: [
img2
.translateX => (w - img2.fitWidth)/2
]
}
]
}
// fn to load img
function loadImg
(view:ImageView,url:String){
view.effect = null;
view.image = Image{
backgroundLoading:true
url:url
}