Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 图像对象白色背景显示_Actionscript 3_Apache Flex_Flex3 - Fatal编程技术网

Actionscript 3 图像对象白色背景显示

Actionscript 3 图像对象白色背景显示,actionscript-3,apache-flex,flex3,Actionscript 3,Apache Flex,Flex3,我有一个图像对象,当图像加载时,该对象的大小会调整为容器大小。 它将加载的图像在大小上是动态的,因此在调整大小后,我最终会显示一条图像对象的白色背景。 如何使图像对象不具有白色背景且透明。 PNG的部分具有透明部分,但由于加载对象的白色背景而显示为白色 <mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" headerHeight="20" > <mx:Script> <![CDATA[

我有一个图像对象,当图像加载时,该对象的大小会调整为容器大小。
它将加载的图像在大小上是动态的,因此在调整大小后,我最终会显示一条图像对象的白色背景。

如何使图像对象不具有白色背景且透明。
PNG的部分具有透明部分,但由于加载对象的白色背景而显示为白色

<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" headerHeight="20" >

  <mx:Script>
    <![CDATA[
      public function set source( val:String ):void{
        this.img.source = val;
      }
      private function onLoad( e:Event ):void{
        // resize image on load to fit
        var scale:Number = (this.height - 38) / this.img.contentHeight; // 38 is adjustment for headheight and padding
        this.img.scaleX = scale;
        this.img.scaleY = scale;
      }
    ]]> 
  </mx:Script>

  <!-- how do I make this image object have a transparent background -->
  <mx:Image id="img" complete="onLoad(event)" />

</mx:Panel>

[编辑] 在屏幕截图中可以看到我上面发布的代码中的两个对象。
如您所见,有一个白色边框。



这是一个PNG
此png在底部有一个透明的1英寸边框350@PPI这是72 PPI,所以有点小
您无法在此处明显看到边框,但如果将其拖动到桌面并在photoshop中打开,您将看到它

[编辑]
正如SuperSaiyen建议的那样,我在面板中添加了backgroundColor=“#000000”,得到了这个结果。如您所见,我现在有一个黑色边框。


因此,我继续在面板中添加backgroundAlpha=“0”和backgroundColor=“#000000”,得到了这个结果。

所以现在我几乎有了它,但它周围仍然有蓝色。它还不是100%透明。
我真的不知道为什么面板背景会改变图像标签。
我猜某种来自父母的遗传正在发生。

仍然需要去除蓝色。

请尝试以下方法,而不是设置比例:

<mx:Image id="img" height="{this.height-38}" maintainAspectRatio="true" />

我试图重现你的问题,即使是规模,我没有看到白色的边界。

我有一个黑色的边框,因为那是面板的背景

<mx:Panel id="thePanel" headerHeight="20"
              horizontalAlign="center" verticalAlign="middle"
              height="200" width="150"
              backgroundColor="#000000">

        <!-- how do I make this image object have a transparent background -->
        <mx:Image id="img" height="{thePanel.height-38}" maintainAspectRatio="true" />

    </mx:Panel>

编辑: 因此,您看到的背景是面板后面框的背景,而不是图像(请参见面板上的不透明背景道具)。然后,您需要将面板的背景设置为与面板边框相同的颜色。面板是正确的容器吗?有圆角的HBox怎么样

<mx:VBox id="thePanel" cornerRadius="4" backgroundColor="0xd1dbe9"
             horizontalAlign="center" verticalAlign="middle"
             height="200" width="150"
             paddingBottom="5" paddingLeft="5" paddingTop="5">
        <mx:Label text="Bind to title String" />
        <mx:Image id="img" width="100%" height="100%"/>
    </mx:VBox>


Erm,不要使用面板来容纳图像?如果我没记错的话,面板的内容区域有一个白色背景。发布问题的屏幕截图。可能是您的图像没有保存为透明。@JAX我验证了图像和标题都是PNG。所以我编辑了我的问题为你显示更多信息等等。。。是否将面板用作项目渲染器?!同样,不要使用面板,因为默认情况下它有白色背景,我认为还有一些填充。不,项目渲染器是Hbox。上面发布的代码是Hbox内部的一个组件。从上面的屏幕截图中可以看到,其中有两个面板显示在其下方的滚动条中。正如你所看到的,面板默认为灰蓝色背景,图像标签有白色背景边框,透明度在图像上。请注意,这是flex 3,我不知道flex 4或其他库默认为什么…是的,你没有白色边框。你有一个黑色的边界/facepalm。我看到的背景色在图像标签上,而不是面板Supersaiyen。我编辑我的问题是为了向您显示您所说的内容的结果,并将alpha 0添加到其中。它很近,但还没有完全在那里。我想你看到的颜色在图像标签上,这就是为什么我在面板上设置背景,以确认图像是透明的。奇怪的是,它像那样层叠而下。你有没有可能用一些面板CSS来设置面板的边框,而你看到的背景是面板的背景?现在还没有使用CSS。在我看来,蓝色是面板“是HBox”容器的背景色。所有的面板都被添加到Hbox中,所以我试着改变背景颜色,只是为了进行实验,结果红色层叠而下,所有的东西都变成了红色。