Skip to main content

Accessing data from a parent class and databinding from components

3 replies [Last post]
sjoedzj
Offline
Joined: 2008-10-02
Points: 0

I try to bind from my 'Application' class on custom components I built. This doesn't work so I tried to access data from a Child component that is available in the parent component/class but I cannot find a way to get this done either.

<br />
var customComponent:CustomComponent = new CustomComponent();<br />
var testString:String = "testString that cannot be accessed from customComponent";</p>
<p>Widget {<br />
    stage: Stage {<br />
        content: [customComponent,<br />
            Rectangle{height:bind customComponent.height}//no data binding<br />
        ]<br />
    }<br />
}<br />

Message was edited by: sjoedzj

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
sjoedzj
Offline
Joined: 2008-10-02
Points: 0

I understand I have to extend the CustomNode class, that's what I did. My CustomComponent actually looks quite the same but it doesn't do what it supposed to do.

Might it be the Widget class?

shagus
Offline
Joined: 2007-05-10
Points: 0

To create a custom component you should extend the CustomNode class.

[code]
import javafx.application.Frame;
import javafx.application.Stage;
import javafx.scene.*;
import javafx.scene.geometry.*;

public class MyCustomComponent extends CustomNode{
attribute height:Integer = 100;
public function create():Node {Group {} }
}

var customComponent:MyCustomComponent = MyCustomComponent{};
var testString:String = "testString that cannot be accessed from customComponent";

Frame {
width: 50
height: 50
visible: true
stage: Stage {
content: [customComponent,
Rectangle{height: bind customComponent.height}
]
}

}

[/code]

sjoedzj
Offline
Joined: 2008-10-02
Points: 0

I understand I have to extend the CustomNode class, that's what I did. My CustomComponent actually looks quite the same but it doesn't do what it supposed to do.

Might it be the Widget class?