无法让我使用 flashDevelop 和 flex 的相对路径 [英] Can't get my relative paths to work with flashDevelop and flex

查看:22
本文介绍了无法让我使用 flashDevelop 和 flex 的相对路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我正在使用 FlashDevelop 和 flex,但我无法让源代码正常工作.当我嵌入图像时,它工作得很好,但如果我只是去 source=".​​./img/Koala.jpg" 与我用于工作嵌入的相同路径,它就不起作用.在 Flash Builder 中,我所要做的就是 source="/img/Koala.jpg" 并且它工作得很好.如果我输入路径D:\flashDevelop\FlexMobileProject\src\img\Koala.jpg",这工作正常.谁能解释一下我在这里遗漏了什么?

So i am using FlashDevelop and flex but i can't get the source to work correctly. When ever i Embed a image it works just fine but if i just go source="../img/Koala.jpg" same path that i used for the working embed it doesn't work. In flash builder all i would have to do is source="/img/Koala.jpg" and it work work just fine. If i type in the path "D:\flashDevelop\FlexMobileProject\src\img\Koala.jpg" this works fine. Can anyone please explain what i'm missing here?

<?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>

推荐答案

当您为图像指定 'source' 时,该文件将在运行时加载.但是,FlashDevelop 不会将文件从 src/复制到 bin/- 您必须使用要在运行时加载的元素手动填充 bin/目录.运行时的路径是相对于 HTML 页面解析的.

When you specify 'source' for an Image, the file will be loaded at run time. However, FlashDevelop doesn't copy the files from src/ to bin/ - you must populate the bin/ directory manually with the elements you want to load at run time. Paths at run time are resolved relatively to the HTML page.

嵌入在编译时解析,需要注意的是,在使用 FlashDevelop 时,路径总是相对于 class/mxml 文件而不是相对于项目根来解析.如果路径以/"开头,它将相对于类路径的根.

Embeds are resolved at compile time, and it should be noted that when using FlashDevelop the path is always resolved relatively to the class/mxml file and not relatively to the project root. If the path starts with "/" it will be relative to the classpath's root.

PS:这些限制实际上是在 Flex SDK 中.

PS: these limitations are actually in the Flex SDK.

这篇关于无法让我使用 flashDevelop 和 flex 的相对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆