【发布时间】:2012-10-29 05:28:27
【问题描述】:
所以我正在使用 FlashDevelop 和 flex,但我无法让源代码正常工作。当我嵌入图像时它工作得很好,但如果我只是去 source="../img/Koala.jpg" 我用于工作嵌入的相同路径它不起作用。在 flash builder 中,我所要做的就是 source="/img/Koala.jpg" ,它工作得很好。如果我输入路径“D:\flashDevelop\FlexMobileProject\src\img\Koala.jpg”,这可以正常工作。谁能解释一下我在这里缺少什么?
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
title="HomeView" creationComplete="init()">
<fx:Script>
<![CDATA[
[Embed(source = "../img/Koala.jpg")]
[Bindable] public var img:Class;
public function init():void {
var s:String = new String();
label.text = String(imgstage.sourceHeight);
trace(imgstage.source);
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<!-- can't find the image even if that path is the same as the embed -->
<s:Image id="imgstage" source="../img/Koala.jpg" y="0" x="0"/>
<s:Label id="label" text="name"></s:Label>
</s:View>
【问题讨论】:
-
Philippe 的回答是正确的。还考虑到这个限制,使用 flex 是完全可以的(服务器部署,您可以参考父路径),但考虑一下 AIR。它只是直接打包AIR项目的src,绝对不能将这些图像安装在INSTALLED DIR的父目录中,因此AIR(包括移动应用程序)不可能。
标签: actionscript-3 apache-flex flex4.5 flashdevelop