Skip to main content

Image width binding

3 replies [Last post]
kram
Offline
Joined: 2007-10-23

I have a very basic app that I beleive should change the width of an image, but it does nothing... can anyone tell me why, when I click on the image, nothing happens to the image?

<br />
import javafx.application.Frame;<br />
import javafx.application.Stage;<br />
import javafx.scene.image.ImageView;<br />
import javafx.scene.image.Image;<br />
import javafx.input.MouseEvent;</p>
<p>var w:Number = 250;</p>
<p>Frame {<br />
    title: "Image View Sample"<br />
    width: 500<br />
    height: 500<br />
    closeAction: function() {<br />
        java.lang.System.exit( 0 );<br />
    }<br />
    visible: true</p>
<p>    stage: Stage {<br />
        content: [<br />
            ImageView {<br />
                x: 200;<br />
                y: 200;<br />
                image: Image {<br />
                    url: "{__DIR__}/c1.png"<br />
                    width: bind w;<br />
                }</p>
<p>                onMouseClicked: function( e: MouseEvent ):Void {<br />
                    w = 100;<br />
                }<br />
            }<br />
        ]<br />
    }<br />
}<br />

Thanks heaps!

Mark

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
gazman
Offline
Joined: 2008-01-25

Hey,

I had the same problem and think that this is either a bug or the width-attribute is a read-only attribute.

My solution: i manipulated the scaleX and/or scaleY-attributes of the ImageView-object.

gasi

alexsch
Offline
Joined: 2007-07-12

The code below should work:

[code]
ImageView {
x: 200;
y: 200;
image: bind Image {
url: "{__DIR__}/c1.png"
width: w;
}

onMouseClicked: function( e: MouseEvent ):Void {
w = 100;
}
}
[/code]

kram
Offline
Joined: 2007-10-23

Thanks Alex, that did the trick... although a bit miss-leading