如何为flex 3中的按钮提供功能?

时间:2010-11-25 08:13:24

标签: flex flex3

我是flex的新手。我想创建一些按钮,当v点击该按钮时,它应该打开一些图像。如何在flex builder 3中提供此功能。感谢您的时间

3 个答案:

答案 0 :(得分:0)

你好了按钮的点击处理程序。在点击处理程序的功能中通过切换可见性来处理图像的显示。将图像嵌入到设计之前。然后按下按钮点击它的可见性。

答案 1 :(得分:0)

如果有帮助,请尝试此示例。 重要的是在使用之前嵌入图像。另一种嵌入方式是内嵌在mx:Image标签中。请注意图像位置的路径。

       <?xml version="1.0" encoding="utf-8"?>
         <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
    <![CDATA[
        /*in the source put the absolute path(like directory:/folder/image.gif) or the relative path (../image.gif where ../ is your project directory )to the location of your image
         */
        [Embed (source="../src/assets/images/image.gif")]
         [Bindable]
         //this variable of type Class is used to refer to the aboveimage..
         public var img:Class;
         public function buttonClickHandler():void{
          if(image.visible)
          image.visible = false;
          else
          image.visible = true;
          }
          ]]>
</mx:Script>
<mx:Image source="{img}" visible="false" id="image"/>
<mx:Button x="172" y="225" label="Button" id="button" click="buttonClickHandler()"/>
</mx:Application>

答案 2 :(得分:0)

尝试浏览这里的示例。解释所有类型的资产嵌入,包括声音 http://livedocs.adobe.com/flex/3/html/help.html?content=04_OO_Programming_09.html