- 浏览: 288637 次
- 性别:
- 来自: 深圳
文章分类
最新评论
-
xisuchi:
咋没人收藏阿
前端开发大众手册(包括工具、网址、经验等) -
past2010yeah:
太好了,解决了我纠结很久的问题!!!非常感谢!
解决Flex跨域"访问URL时遇到安全性错误" -
shlei:
xiao_kai 写道这样会不会牺牲性能啊~~会,但是这是暂时 ...
解决flex4 spark 找不到外观错误 -
xiao_kai:
这样会不会牺牲性能啊~~
解决flex4 spark 找不到外观错误 -
jcl860:
兄台:左边面板是图片,还是用mxml画出来的图形?
仿IBM-BPM Editor实现的WorkFlowEditor
Anyone missed the old simple method for skinning a simple button?
//mainButtonHitArea() : Is a generic function that generates the hit area
The problem im having is that, this method of creating a simple button with skin is being phased out : Infact it is no longer supported in flex 4.5 mobile projects.
So the question: Is there a simple way to perform this, with spark buttons (which is suppose to be the new way to go). As simple as possible.
Basically i only need a button with 2 images : down/over & up. And i want to keep the code as simple as possible : The new skinning methods, seems to really adds way too much lines for something that used to be as simple as the example above.
You can create a skin, i.e. (as MyButtonSkin.mxml):
Then you can assign that skin to some button:
Here's a basic image button that's more general:
ImageButtonSkin.mxml
ImageSkinnableButton.as
Then you can set the images as styles on the button in either CSS (preferred) or in mxml:
You can also define a ButtonImageSkin for the default spark.components.Button component, for example in the imageskins package:
Simply define a style on the skin class itself, and bind the source of the image to it. Now, you can control the actual images using CSS pseudo selectors:
<mx:Button x="10" y="10" label="" upSkin="@Embed('imgs/mainButton_std.png')" overSkin="@Embed('imgs/mainButton_over.png')" downSkin="@Embed('imgs/mainButton_over.png')" disabledSkin="@Embed('imgs/mainButton_std.png')" creationComplete="mainButtonHitArea()" width="75" height="75" id="menuButton" enabled="true"/>
//mainButtonHitArea() : Is a generic function that generates the hit area
The problem im having is that, this method of creating a simple button with skin is being phased out : Infact it is no longer supported in flex 4.5 mobile projects.
So the question: Is there a simple way to perform this, with spark buttons (which is suppose to be the new way to go). As simple as possible.
Basically i only need a button with 2 images : down/over & up. And i want to keep the code as simple as possible : The new skinning methods, seems to really adds way too much lines for something that used to be as simple as the example above.
You can create a skin, i.e. (as MyButtonSkin.mxml):
<?xml version="1.0" encoding="utf-8"?> <s:SparkSkin name="MyButtonSkin" xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:fb="http://ns.adobe.com/flashbuilder/2009"> <s:states> <s:State name="up" /> <s:State name="over" /> <s:State name="down" /> <s:State name="disabled" /> </s:states> <fx:Metadata> <![CDATA[ [HostComponent("spark.components.Button")] ]]> </fx:Metadata> <s:BitmapImage source.disabled="@Embed('assets/image1.png')" source.down="@Embed('assets/image2.png')" source.up="@Embed('assets/image3.png')" source.over="@Embed('assets/image4.png')" /> </s:SparkSkin>
Then you can assign that skin to some button:
<s:Button skinClass="MyButtonSkin"/>
Here's a basic image button that's more general:
ImageButtonSkin.mxml
<s:SparkButtonSkin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:fb="http://ns.adobe.com/flashbuilder/2009"> <fx:Metadata> [HostComponent("com.instantdelay.flex.commons.ImageSkinnableButton")] </fx:Metadata> <s:states> <s:State name="up" /> <s:State name="over" /> <s:State name="down" /> <s:State name="disabled" /> </s:states> <s:BitmapImage id="image" source.up="{getStyle('upImage')}" source.down="{getStyle('downImage')}" source.over="{getStyle('overImage')}" source.disabled="{getStyle('disabledImage')}" /> </s:SparkButtonSkin>
ImageSkinnableButton.as
[Style(name="upImage", inherit="no", type="Class")] [Style(name="downImage", inherit="no", type="Class")] [Style(name="overImage", inherit="no", type="Class")] [Style(name="disabledImage", inherit="no", type="Class")] public class ImageSkinnableButton extends Button { public function ImageSkinnableButton() { super(); setStyle("skinClass", ImageButtonSkin); } }
Then you can set the images as styles on the button in either CSS (preferred) or in mxml:
<commons:ImageSkinnableButton upImage="@Embed('imgs/mainButton_std.png')" overImage="@Embed('imgs/mainButton_over.png')" downImage="@Embed('imgs/mainButton_over.png')" disabledImage="@Embed('imgs/mainButton_std.png')" />
You can also define a ButtonImageSkin for the default spark.components.Button component, for example in the imageskins package:
<s:SparkButtonSkin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:fb="http://ns.adobe.com/flashbuilder/2009"> <fx:Metadata> [HostComponent("spark.components.Button")] </fx:Metadata> <s:states> <s:State name="up" /> <s:State name="over" /> <s:State name="down" /> <s:State name="disabled" /> </s:states> <s:BitmapImage source="{getStyle('backgroundImage')}"/> </s:SparkButtonSkin>
Simply define a style on the skin class itself, and bind the source of the image to it. Now, you can control the actual images using CSS pseudo selectors:
@namespace imageskins "imageskins.*"; s|Button { skinClass: ClassReference("imageskins.ButtonImageSkin"); } imageskins|ButtonImageSkin:up { backgroundImage: Embed(source="assets/images/button-up.png"); } imageskins|ButtonImageSkin:down { backgroundImage: Embed(source="assets/images/button-down.png"); } imageskins|ButtonImageSkin:over { backgroundImage: Embed(source="assets/images/button-over.png"); } imageskins|ButtonImageSkin:disabled { backgroundImage: Embed(source="assets/images/button-disabled.png"); }From http://stackoverflow.com/questions/6477137/flex-4-5-simple-spark-button-skinning
发表评论
-
Flex4之皮肤定制【Skin类和Skin类】
2013-10-05 19:19 1152第一、关于spark.skin.SparkSkin类的 ... -
基于 Cairngorm MVC 框架的 Flex 程序设计与开发
2013-10-05 18:38 1007翟 峰, 开发工程师, IBM 吴 镝, IBM 实习生, I ... -
swf复制到其他文件夹出现安全错误的解决办法
2012-08-16 10:06 1226相信用Flash Builder/Flex Builder做开 ... -
在flex中使用model标签读取配置文件的方法
2012-08-16 09:54 9941.使用 Model标签 <mx:Model id=& ... -
Flex利用渲染器动态修改tree的icon图标
2012-08-16 09:50 1781Tree: <mx:Tree dataProvide ... -
flex xml操作
2012-04-25 10:48 1174今天我们来看看AS3中新的XML处理方法:E4X,直到现在,E ... -
Flex 创建过滤特定文件的FileReference
2012-03-01 16:13 1661下面的代码演示了Flex中如何创建一个可以过滤特定后缀文件的F ... -
Flex 根据图片url获取bitmapdata并绑定到多个Image
2012-03-01 14:40 3051private function getImage(url ... -
Flex 开始日期与结束日期DateField组件
2012-03-01 13:45 1831<?xml version="1.0&qu ... -
匹配已选中数据的某字段和下拉框数据
2012-03-01 08:41 1309package YD.Web.Common.Utils ... -
解决flex4 spark 找不到外观错误
2012-02-27 14:01 1912spark组件为了提高性能adobe做了很多努力,同 ... -
Flex垃圾回收和性能优化的一些总结
2012-02-27 11:30 1212本文是Kenshin根据一些对 ... -
【转】关于Flex未来走向的问答
2011-11-22 09:50 1780•转自:http://www.riadev.com/flex- ... -
Flex 关于validateNow方法
2011-11-18 10:42 2303validateNow(); 官方解释:验证并更新此对 ... -
Flex 数值转IP
2011-11-18 10:19 914package common { public cl ... -
Flex 关于遍历
2011-11-18 10:15 1047获取XML属性名、值 var x : XML = < ... -
Flash Builder编译的swf为什么在bin-debug下运行正常,复制到其他文件夹就不正常?
2011-11-08 16:54 1620相信用Flash Builder/Flex Bui ... -
Flex HttpService重用2
2011-09-28 13:30 1204HttpService工具类: package commo ... -
动态配置AMF与后台接口调用
2011-09-28 11:47 1515以下是一个AMF调用类: package common ... -
Unix时间戳转化AS3日期格式
2011-09-21 16:14 2301Unix时间戳:1254671828 返回:2009-10-1 ...
相关推荐
在Flex 4.5中,有许多关键的改进和新特性,包括Spark组件模型、Skinning和Styling的增强,以及数据服务的优化。 1. **Spark组件模型**:Spark组件模型是Flex 4.5的核心,它与以前的 Halo 组件模型相比,提供了更...
5. **Mobile Skinning and Theming**:Flex 4.5提供了移动皮肤和主题机制,允许开发者根据目标设备和用户界面需求定制应用的外观和行为。通过修改CSS样式的SkinClass,可以实现组件在不同设备上的差异化显示。 6. *...
4. **Skinning和 Theming**:在Flex 4.5中,通过皮肤和主题可以改变组件的外观和感觉。开发者可以创建自定义皮肤,或者使用预定义的主题来改变整个应用的视觉样式。 5. **数据绑定**:Flex支持双向数据绑定,使得...
Flex 4.5引入了Spark组件模型和Skinning,提供了更丰富的用户界面设计和更好的性能。它使用MXML和ActionScript 3.0进行开发,能够创建交互性强、图形丰富的Web应用前端。 2. **SSH框架**: - **Struts2**:这是一...
Flex4.5 skins学习主要关注的是Adobe Flex框架中Spark Skins的使用和定制。Spark Skins是Flex 4引入的一种全新的皮肤机制,旨在提供更高效、更灵活的界面设计能力,使得开发者能够更容易地改变应用程序的外观和感觉...
Flex 4.5中的Skinning和States机制也使得开发者能够根据不同的用户操作状态改变界面的外观和行为。 总的来说,"WeiboTrends 仿TwitterTrends"项目不仅是一个学习Flex 4.5的好素材,同时也展示了如何使用Flex技术来...
- **Spark Skinning**:详细讲解了 Spark 框架下的皮肤设计方法。 - **MX 组件皮肤化**:讲述了如何对 MX 框架下的组件进行皮肤化处理。 - **嵌入资产**:介绍了如何将图片、音频等资源嵌入到 Flex 应用中。 - **FXG...
例如,使用Spark VGroup和HGroup进行布局管理,使用Label和Button组件实现交互,使用List或DataGrid展示动态数据等。 其次,Flex4中的MXML和ActionScript 3.0的结合是另一个关键点。MXML是一种声明式语言,使得界面...
Flex Skinning机制是Adobe Flex框架中的一个重要特性,它允许开发者为UI组件自定义外观和行为,从而实现应用程序的独特设计和交互体验。通过深入理解并实践Flex Skinning,开发者可以更灵活地控制用户界面的视觉样式...
12. **Mobile支持**:Flex 4扩展到了移动领域,Flex 4.5引入了针对Android和iOS设备的Air SDK,允许开发者创建跨平台的移动应用。 通过《Flex4权威指南》的源代码,开发者可以学习到如何有效地运用这些技术,从简单...
2. **Spark 组件架构**:Flex 4 引入了 Spark 组件集,与之前的 Halo 组件相比,Spark 组件更灵活,性能更高,并且支持更加丰富的视觉样式和动画效果。 3. **Skinning 和 Theming**:Flex 4 提供了强大的皮肤和主题...
7. **Spark Components**:Spark组件库包括一系列新的UI组件,如Button、Label、List等,这些组件更加现代,性能更好,并且与Halo组件兼容,方便开发者混合使用。 8. ** Cairngorm、BlazeDS和LiveCycle Data ...
在Flex 4.0版本中,引入了全新的Spark组件模型,与之前的 Halo组件相比,Spark组件提供了更高级的定制能力和更好的性能。此外,Flex 4.0还引入了Skinning和States机制,使得界面设计更加灵活,能够根据不同的应用...
Flex 4还引入了Skinning和 Theming系统,允许开发者创建和应用自定义界面主题,而不必深入到组件内部代码。通过分离表现和逻辑,开发者可以轻松地更改应用的视觉风格,以适应不同品牌或用户需求。 在Flex 4中,...
例如,Flex 4.0的Skinning和Styling机制让开发者可以定制组件的外观和行为,而不必深入到组件的源代码中。 此外,Flex 4.0还引入了Graphical User Interface(GUI)构建的新概念——Gumbo,后来被称为Flex 4。Gumbo...
2. **Flex Component Hierarchy**:Spark组件库包含了一系列基础组件,如Button、Label、Layout等,它们构成了Flex UI的基础。每个组件都有自己的生命周期,包括creationComplete、initialize、render等关键阶段,...
Spark组件包括基础组件(如Button、Label)以及更复杂的组件(如DataGrid)。 2. **MXML和ActionScript混合编程**:Flex 4.0允许开发者在MXML和ActionScript之间自由切换,MXML用于界面布局和组件声明,...
新的骨骼动画系统(Skinning and States)也是Flex 4的一大亮点,允许开发者通过状态管理轻松实现UI组件在不同场景下的动态变换。 本书将带领读者深入学习Flex 4的构建环境Flash Builder,讲解如何创建项目、编写...