调用的方法Embed可能未定义

这个问题好奇怪,一般来说,调用的方法或属性未定义,基本上都是因为某个对象没有被初始化。

 

 

出问题的代码如下:

 

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
<mx:Script>
     <![CDATA[
        import mx.events.ListEvent;
       
        [Bindable]
        private var dp:Array = [
                                {name:"John Smith", position: "developer"},{name:"Ellen Smith", position: "manager"},
                                {name:"Hames Smith", position: "accountant"},{name:"Jane Smith", position: "designer"}
                                ]                  //解决方法:后面加个分号;就可以了,百思不得其解!
                               
        [Embed(source="image/1.jpg")]
        public var managerIcon:Class;
       
        [Embed(source="image/2.jpg")]
        private var designerIcon:Class;
       
        [Embed(source="image/3.jpg")]
        private var accountantIcon:Class;
       
        [Embed(source="image/4.jpg")]
        private var developerIcon:Class;                        

        private function setIcon(value:*):Class
        {
            if(value.position != null)
            {
                switch(value.position)
                {
                    case "manager":
                        return managerIcon;
                        break;
                    case "developer":   
                        return developerIcon;
                        break;
                    case "accountant":   
                        return accountantIcon;
                        break;
                    case "designer":   
                        return designerIcon;
                        break;
                }
            }
            return null;
        }
    ]]>
</mx:Script>
<mx:Canvas width="400" height="300" backgroundColor="0x00ffff">
    <!--<mx:Button click="setEditor()"/>-->
    <mx:List x="50" y="30" width="200" selectedIndex="1" id="listImpl" selectionColor="0xccccff" labelField="name"
         dataProvider="{dp}" editable="true" verticalScrollPolicy="on" iconFunction="setIcon"/>
</mx:Canvas>
</mx:Application>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值