flex-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Harui <aha...@adobe.com>
Subject Re: Flex mx Image source path at runtime
Date Mon, 28 Sep 2015 14:53:51 GMT
Was this project developed in Flash Builder?

For some reason, Flash Builder “taught” folks to put a leading slash on
their paths to assets and then the FB compiler “undid” that during
compilation.  Maybe it made it easier for design view, I don’t know.
Anyway, a fair number of FB project do not compile outside of FB for that
reason, and I just end up removing the forward slash in the code to get it
to work.


On 9/27/15, 11:37 PM, "brutfood" <brutfood@yahoo.com> wrote:

>I'm wading through a Flex AIR desktop project that someone else wrote. The
>original author has used several mx.controls.Image components. Runtime
>paths assigned like this:
>image.source = "/assets/book.png";
>BUT - It doesn't work - I just get the broken image icon.
>I've never used the above approach in my own code. Personally, I've always
>used compile-time embedded images or URLLoader/Loader for runtime images.
>So, I'd like to learn how to get this image path approach working.
>I wrote a simple test program. Here is my .mxml -
><?xml version="1.0" encoding="utf-8"?>
> <pf:LearningAS xmlns:fx="http://ns.adobe.com/mxml/2009"
>      xmlns:mx="library://ns.adobe.com/flex/mx"
>      xmlns:pf="com.powerflasher.*">
>      <mx:Image id="myImage"/>
> </pf:LearningAS>
>Here is my connected .as
>public class LearningAS extends WindowedApplication {
>    public var myImage:Image;
>    public function LearningAS() {
>        super();
>        addEventListener(FlexEvent.CREATION_COMPLETE, init);
>    }
>    protected function init(event:FlexEvent):void {
>        myImage.source = '/assets/myimage.png';
>    }
>I also added the src/assets folder to AIR package contents. And I added
>-use-network=false to my compiler directives. (I'm using FDT, and Flex
>(PS: I know that the spark image is preferred to the mx Image nowadays.
>the Spark image definitely doesn't support runtime image paths like this.)
>View this message in context:
>Sent from the Apache Flex Users mailing list archive at Nabble.com.

View raw message