tags:

views:

360

answers:

1

Here's the example:

var cartesian:CartesianChart = new CartesianChart(); 
cartesian.width = 100;
var column:ColumnChart = new ColumnChart();
column = cartesian as ColumnChart;

Why does this not work? "column" ends up null. ColumnChart is a derived class of CartesianChart, so I would have thought I'd end up with a ColumnChart with a width of 100.

A: 

ColumnChart extends CartesianChart? I don't believe you can cast an object from a parent class to an object of it's child class. Your best bet is to write a class function on ColumnChart called something like copyFromCartesianChart that takes the CartesianChart object as a param and gets and sets all the props you need.

greg
right, Column extends Cartesian. Apparently you can only cast child as parent, shedding any properties that aren't inherited. Good idea on extending the derived class with a method that accomplishes this.
SkippyFlipjack