Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Flex > Flex 2, 3 & 4

Reply
 
Thread Tools Rate Thread Display Modes
Old 05-12-2010, 07:22 PM   #1
atoyebi9381
Registered User
 
Join Date: Jan 2010
Posts: 3
Default "unable to bind to property 'last' on class 'XML' (class is not an IEventDispatcher)

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>

Last edited by atoyebi9381; 05-12-2010 at 07:30 PM.
atoyebi9381 is offline   Reply With Quote
Old 05-12-2010, 07:23 PM   #2
atoyebi9381
Registered User
 
Join Date: Jan 2010
Posts: 3
Default

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>

Last edited by atoyebi9381; 05-12-2010 at 07:32 PM.
atoyebi9381 is offline   Reply With Quote
Old 05-12-2010, 07:30 PM   #3
atoyebi9381
Registered User
 
Join Date: Jan 2010
Posts: 3
Default

Thank you!
atoyebi9381 is offline   Reply With Quote
Old 05-15-2010, 06:37 PM   #4
drkstr
Flexpert
 
drkstr's Avatar
 
Join Date: Sep 2006
Location: Seattle, WA: USA
Posts: 1,587
Default

You need to use strongly typed classes for property binding.

ActionScript Code:
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.
drkstr is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:26 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.