在项目渲染器中动态分配图像源在 Flex/AS3 中不起作用
我有一个显示图像的自定义项目渲染器:
<mx:DataGrid dataProvider="{friends.friend}" id="friendsGrid" width="240"
rowCount="3" variableRowHeight="true" headerHeight="0"
horizontalCenter="true" backgroundAlpha="0" borderThickness="0"
useRollOver="false" selectable="false">
<mx:columns>
<mx:DataGridColumn width="80" paddingLeft="20">
<mx:itemRenderer>
<mx:Component>
<mx:HBox height="50" horizontalAlign="center"
verticalAlign="middle" horizontalScrollPolicy="off" verticalScrollPolicy="off">
<mx:Image source="{outerDocument.getProfilePic(data)}"/>
</mx:HBox>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
和一个函数 getProfilePic:
public function getProfilePic(data:Object):String{
if(String( data.image_path.text() ) == ""){
return "../assets/no_profile_pic.png";
}else{
return data.image_path;
}
}
问题是,当我分配“无个人资料图片”图像时,它不会显示。我得到了那个看起来很有趣的“找不到图像”图标。如果我将图像放置在服务器上的 ../assets 中,该图像就会显示。嵌入更理想。所以问题是......在这种情况下如何嵌入图像?
I have a custom item renderer that displays images:
<mx:DataGrid dataProvider="{friends.friend}" id="friendsGrid" width="240"
rowCount="3" variableRowHeight="true" headerHeight="0"
horizontalCenter="true" backgroundAlpha="0" borderThickness="0"
useRollOver="false" selectable="false">
<mx:columns>
<mx:DataGridColumn width="80" paddingLeft="20">
<mx:itemRenderer>
<mx:Component>
<mx:HBox height="50" horizontalAlign="center"
verticalAlign="middle" horizontalScrollPolicy="off" verticalScrollPolicy="off">
<mx:Image source="{outerDocument.getProfilePic(data)}"/>
</mx:HBox>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
And a function getProfilePic:
public function getProfilePic(data:Object):String{
if(String( data.image_path.text() ) == ""){
return "../assets/no_profile_pic.png";
}else{
return data.image_path;
}
}
The issue is that when I assign the "no profile pic" image, it does not show up. I get that funny looking "image cannot be found" icon in place. If I place an image in ../assets on my server, the image shows up. Embedding is more ideal. So the question is...how do I embed an image in this case?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许试试这个:
Maybe try this: