1个回答
展开全部
<fx:Script>
<![CDATA[
protected function button1_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
image.visible =true;
}
protected function image_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
image.visible=false;
}
]]>
</fx:Script>
<s:VGroup>
<!--<mx:Image id="image" scaleContent="true" source="@Embed('assets/dairy_mike.jpg')"/>-->
<mx:Image id="image" visible="false" source="assets/dairy_milk.jpg" click="image_clickHandler(event)"/>
<s:Button label="显示图片" click="button1_clickHandler(event)"/>
</s:VGroup>
这是一种方案,图片默认隐藏,点击按钮让图片显示,点击图片又恢复隐藏。
第二种方案,建立两个state,分别把按钮和图片放进两个state里面,来回切换就可以了
<s:states>
<s:State name="button"/>
<s:State name="image"/>
</s:states>
<s:VGroup>
<s:Button label="显示图片" click.button="this.currentState='image'" includeIn="button"/>
</s:VGroup>
<s:VGroup>
<mx:Image id="image" source="assets/dairy_milk.jpg" click.image="this.currentState='button'" includeIn="image"/>
</s:VGroup>
<![CDATA[
protected function button1_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
image.visible =true;
}
protected function image_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
image.visible=false;
}
]]>
</fx:Script>
<s:VGroup>
<!--<mx:Image id="image" scaleContent="true" source="@Embed('assets/dairy_mike.jpg')"/>-->
<mx:Image id="image" visible="false" source="assets/dairy_milk.jpg" click="image_clickHandler(event)"/>
<s:Button label="显示图片" click="button1_clickHandler(event)"/>
</s:VGroup>
这是一种方案,图片默认隐藏,点击按钮让图片显示,点击图片又恢复隐藏。
第二种方案,建立两个state,分别把按钮和图片放进两个state里面,来回切换就可以了
<s:states>
<s:State name="button"/>
<s:State name="image"/>
</s:states>
<s:VGroup>
<s:Button label="显示图片" click.button="this.currentState='image'" includeIn="button"/>
</s:VGroup>
<s:VGroup>
<mx:Image id="image" source="assets/dairy_milk.jpg" click.image="this.currentState='button'" includeIn="image"/>
</s:VGroup>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询