PDA

View Full Version : "unable to bind to property 'last' on class 'XML' (class is not an IEventDispatcher)


atoyebi9381
05-12-2010, 07:22 PM
I am using MXMLto create drop down menus and ASú for other elements as the background. The MXML drop down works but debugging gives me this:"unable to bind to property 'last' on class 'XML' (class is not an IEventDispatcher)".

Also the AS3 does not display at all.

XML:
<?xml version="1.0" encoding="utf-8"?>

<database>
<enrollment name="Student">
<first code="JE" name="Jenny">
<last name="Smith" />
<last name="Jones" />
</first>
<first code="JO" name="John">
<last name="Williams" />
<last name="Brown" />
<last name="Green" />
</first>
<first code="RA" name="Rachel">
<last name="Scott" />
<last name="Miller" />
</first>
<first code="PH" name="Phil">
<last name="Myer" />
</first>
<first code="JI" name="Jill">
<last name="Phelps" />
</first>
</enrollment>

<enrollment name="Faculty">
<first code="JN" name="Jean">
<last name="Gray" />
</first>
<first code="RO" name="Rod">
<last name="King" />
<last name="Davies" />
<last name="Larson" />
</first>
<first code="DE" name="Dennis">
<last name="Berger" />
</first>
<first code="RA" name="Rachel">
<last name="James" />
</first>
<first code="NI" name="Nick">
<last name="Morales" />
<last name="Fulton" />
</first>


</enrollment>
</database>

atoyebi9381
05-12-2010, 07:23 PM
The Code:

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"


layout="vertical"
verticalAlign="middle"
backgroundColor="white" >
<mx:Script>
<![CDATA[




import flash.display.Shape;
import flash.display.Sprite;

import net.philau.UIOne;
[Bindable]

private var mySprite:Sprite

private var ui:UIOne
private var viewList:Array;
private var txt:UIOne;
private var txtList:Array = new Array();
private var txtList1:Array = new Array();
private var yOffset:Number = 0;
private var xOffset:Number = 90;
public function Action():void
{
viewList = new Array(3)
viewList[0]=[20,30,0xCCCCCC]
viewList[1]=[20,10,0xAA2299]
viewList[2]=[10,10,0xFFFFFF]
init();

}


function init():void{
//forward loop o to 9
for(var x:Number = 0;x<9;x++){

txtList[x] = new UIOne()
txtList1[x] = new UIOne()
//add to stage
this.addChild(txtList[x])
this.addChild(txtList1[x])
//its y position
txtList[x].y = yOffset
txtList1[x].x = xOffset
//display text
txtList[x].myText = "Video";
txtList1[x].myText = "Interface";

yOffset += 30
xOffset += 90

ui = new UIOne();

this.addChild(ui);

mySprite = new Sprite();
this.addChild(mySprite)
this.addChild(triangle);


drawRect();
drawPoint();
}

function drawRect():void
{
mySprite.graphics.lineStyle(2);
mySprite.graphics.beginFill(0XFFFFFF);
mySprite.graphics.drawRect(0,30,500,300);
}

function drawPoint():void
{

mySprite.graphics.lineStyle(2);
mySprite.graphics.beginFill(0XFF0000);
mySprite.graphics.drawCircle(80,300,10);


}

]]>
</mx:Script>
<mx:XML id="dp" source="students.xml" format="e4x" />

<mx:Form>
<mx:FormItem label="Enrollment:">
<mx:ComboBox id="enrolCB"
dataProvider="{dp.enrollment}"
labelField="@name" />
</mx:FormItem>
<mx:FormItem label="First Name:">
<mx:ComboBox id="firstCB" dataProvider="{enrolCB.selectedItem.first}" labelField="@name" />
</mx:FormItem>
<mx:FormItem label="Last Name:">
<mx:ComboBox id="lastCB" dataProvider="{firstCB.selectedItem.last}"
labelField="@name" />
</mx:FormItem>
</mx:Form>


</mx:Application>

atoyebi9381
05-12-2010, 07:30 PM
Thank you!

drkstr
05-15-2010, 06:37 PM
You need to use strongly typed classes for property binding.

package
{
[Bindable]
public class SomeModel
{

public var property1:String;

public var property2:String;
}
}

You can also use ObjectProxy, but it's easier, and more processor efficient, to use strongly typed classes.