求flex编程程序

来源:百度知道 编辑:UC知道 时间:2024/07/03 00:24:24
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" visible="true">
<mx:Label text="picture" width="152" height="51"
fontSize="17" x="69" y="53" fontWeight="bold"
mosemove="image.source='file:///E|/照片、图片/dreamwear所有背景图片/bg-0021.gif'
autoLoad='true'"
/>
<mx:Label text="not picture" height="42" width="132" fontSize="17" x="360" y="50" fontWeight="bold"/>
<mx:Image width="120" height="115"
/>
</mx:Application>

要求是:显示一行文字,鼠标放在上面显示一张图片,图片的名称和文字名称一样,图片如果不存在就显示提示!!!

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
<mx:Script>
<![CDATA[
import flash.filesystem.File;
import mx.controls.Alert;

private function mouseOverHandler():void{
var file:File=new File("yourPath");
if(file.exists){
myImage.source=file;
}else{
Alert.show("图片不存在","提示");
}
}
]]>
</mx:Script>
<mx:Label text="logo.gif" mouseOver="mouseOverHandler()"/>
<mx:Image id="myImage"/>
</mx:Application>