惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Cyberwarzone
Cyberwarzone
Vercel News
Vercel News
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
aimingoo的专栏
aimingoo的专栏
B
Blog RSS Feed
A
About on SuperTechFans
T
The Blog of Author Tim Ferriss
爱范儿
爱范儿
腾讯CDC
S
SegmentFault 最新的问题
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
The Hacker News
The Hacker News
J
Java Code Geeks
大猫的无限游戏
大猫的无限游戏
B
Blog
IT之家
IT之家
Spread Privacy
Spread Privacy
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
C
Cisco Blogs
Recent Announcements
Recent Announcements
H
Hacker News: Front Page
AI
AI
I
InfoQ
H
Heimdal Security Blog
T
Threatpost
Cisco Talos Blog
Cisco Talos Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
I
Intezer
W
WeLiveSecurity
SecWiki News
SecWiki News
MongoDB | Blog
MongoDB | Blog
宝玉的分享
宝玉的分享
博客园 - 【当耐特】
云风的 BLOG
云风的 BLOG
T
Threat Research - Cisco Blogs
V2EX - 技术
V2EX - 技术
N
News and Events Feed by Topic
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
O
OpenAI News
阮一峰的网络日志
阮一峰的网络日志
T
Troy Hunt's Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
博客园 - 司徒正美
Apple Machine Learning Research
Apple Machine Learning Research
雷峰网
雷峰网
T
Tor Project blog
有赞技术团队
有赞技术团队
Schneier on Security
Schneier on Security
Last Week in AI
Last Week in AI

博客园 - 帅死活该

Flex各类型坐标转换(全局、本地、内容坐标间转换) Oracle Spatial中的空间索引 [转] ORACLE纯SQL实现多行合并一行[转] Oracle提供的序号函数 FLEX动态创建事件 自定义组件开发 第二节 MXML组件开发 Flex项目调试及日志记录 Flex或Flash的跨域访问的解决方案 - 帅死活该 - 博客园 ArcEngine数据删除几种方法和性能比较[转] - 帅死活该 - 博客园 组件服务-计算机-我的电脑右键无属性,组件服务打不开 FLEX中使用BitmapFill的source属性指定SVG类文件 - 帅死活该 - 博客园 [转]ArcSDE数据被锁定后的解锁方法 ArcGIS server如何将自己的小地图叠加到Google maps或者Virtual Earth上[转] 一个ArcGIS网络分析的最短路径例子||A Network Analyst Shortest Route of ArcGIS[转] ArcGIS的网络分析[转] Flex的动画效果与变换!(二)[转] Flex动画效果与变换(一)[转] Microsoft 解决方案框架 — MSF 项目管理准则 v. 1.1[转] 如何在Silverlight中与HTML DOM交互
Flex动画效果与变换(三)[转]
帅死活该 · 2009-09-21 · via 博客园 - 帅死活该

这篇文章是Flex动画效果变换的最后一编了,这篇将会讲述Flex中的“变面”技术,即是Transitions!
如果看过Flex SDK里面的自带的例子程序,有一个叫“Flex Store”的应用,在里面的手机列表中看某一个手机的详细时,就是这种效果,不多说,这篇会比较简单,先看看效果:在线播放
看到了效果了吧,这种的变换不难实现,再来看看代码再解析:
<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute” width=”695″ height=”555″>
<mx:states>
<mx:State name=”A”>
<mx:SetProperty target=”{windowA}” name=”width” value=”500″/>
<mx:SetProperty target=”{windowA}” name=”height” value=”300″/>
<mx:SetProperty target=”{windowC}” name=”width” value=”150″/>
<mx:SetProperty target=”{windowC}” name=”height” value=”150″/>
<mx:SetProperty target=”{windowC}” name=”y” value=”333″/>
<mx:SetProperty target=”{windowD}” name=”x” value=”373″/>
<mx:SetProperty target=”{windowD}” name=”width” value=”150″/>
<mx:SetProperty target=”{windowD}” name=”height” value=”150″/>
<mx:SetProperty target=”{windowD}” name=”y” value=”333″/>
<mx:SetProperty target=”{windowB}” name=”x” value=”23″/>
<mx:SetProperty target=”{windowB}” name=”y” value=”333″/>
<mx:SetProperty target=”{windowB}” name=”width” value=”150″/>
<mx:SetProperty target=”{windowB}” name=”height” value=”150″/>
<mx:SetProperty target=”{windowC}” name=”x” value=”200″/>
</mx:State>
<mx:State name=”B”>
<mx:SetProperty target=”{windowD}” name=”width” value=”150″/>
<mx:SetProperty target=”{windowD}” name=”height” value=”150″/>
<mx:SetProperty target=”{windowC}” name=”width” value=”150″/>
<mx:SetProperty target=”{windowC}” name=”height” value=”150″/>
<mx:SetProperty target=”{windowA}” name=”width” value=”150″/>
<mx:SetProperty target=”{windowA}” name=”height” value=”150″/>
<mx:SetProperty target=”{windowB}” name=”width” value=”500″/>
<mx:SetProperty target=”{windowB}” name=”height” value=”300″/>
<mx:SetProperty target=”{windowA}” name=”y” value=”333″/>
<mx:SetProperty target=”{windowC}” name=”x” value=”200″/>
<mx:SetProperty target=”{windowC}” name=”y” value=”333″/>
<mx:SetProperty target=”{windowB}” name=”x” value=”23″/>
<mx:SetProperty target=”{windowD}” name=”x” value=”373″/>
<mx:SetProperty target=”{windowD}” name=”y” value=”333″/>
</mx:State>
<mx:State name=”C”>
<mx:SetProperty target=”{windowD}” name=”width” value=”150″/>
<mx:SetProperty target=”{windowD}” name=”height” value=”150″/>
<mx:SetProperty target=”{windowB}” name=”width” value=”150″/>
<mx:SetProperty target=”{windowB}” name=”height” value=”150″/>
<mx:SetProperty target=”{windowA}” name=”width” value=”150″/>
<mx:SetProperty target=”{windowA}” name=”height” value=”150″/>
<mx:SetProperty target=”{windowC}” name=”width” value=”500″/>
<mx:SetProperty target=”{windowC}” name=”height” value=”300″/>
<mx:SetProperty target=”{windowA}” name=”y” value=”333″/>
<mx:SetProperty target=”{windowB}” name=”x” value=”200″/>
<mx:SetProperty target=”{windowB}” name=”y” value=”333″/>
<mx:SetProperty target=”{windowC}” name=”x” value=”23″/>
<mx:SetProperty target=”{windowC}” name=”y” value=”19″/>
<mx:SetProperty target=”{windowD}” name=”x” value=”373″/>
<mx:SetProperty target=”{windowD}” name=”y” value=”333″/>
</mx:State>
<mx:State name=”D”>
<mx:SetProperty target=”{windowC}” name=”width” value=”150″/>
<mx:SetProperty target=”{windowC}” name=”height” value=”150″/>
<mx:SetProperty target=”{windowB}” name=”width” value=”150″/>
<mx:SetProperty target=”{windowB}” name=”height” value=”150″/>
<mx:SetProperty target=”{windowA}” name=”width” value=”150″/>
<mx:SetProperty target=”{windowA}” name=”height” value=”150″/>
<mx:SetProperty target=”{windowD}” name=”width” value=”500″/>
<mx:SetProperty target=”{windowD}” name=”height” value=”300″/>
<mx:SetProperty target=”{windowA}” name=”y” value=”333″/>
<mx:SetProperty target=”{windowB}” name=”x” value=”200″/>
<mx:SetProperty target=”{windowB}” name=”y” value=”333″/>
<mx:SetProperty target=”{windowD}” name=”x” value=”23″/>
<mx:SetProperty target=”{windowD}” name=”y” value=”19″/>
<mx:SetProperty target=”{windowC}” name=”x” value=”373″/>
<mx:SetProperty target=”{windowC}” name=”y” value=”333″/>
</mx:State>
</mx:states>
<mx:transitions>
<mx:Transition fromState=”*” toState=”*”>
<mx:Parallel targets=”{[windowA, windowB, windowC, windowD]}”>
<mx:Move />
<mx:Resize />
</mx:Parallel>
</mx:Transition>
</mx:transitions>
<mx:TitleWindow x=”23″ y=”19″ width=”250″ height=”200″ layout=”absolute” title=”A” id=”windowA” click=”currentState=’A'” />
<mx:TitleWindow x=”309″ y=”19″ width=”250″ height=”200″ layout=”absolute” title=”B” id=”windowB” click=”currentState=’B'” />
<mx:TitleWindow x=”23″ y=”260″ width=”250″ height=”200″ layout=”absolute” title=”C” id=”windowC” click=”currentState=’C'” />
<mx:TitleWindow x=”309″ y=”260″ width=”250″ height=”200″ layout=”absolute” title=”D” id=”windowD” click=”currentState=’D'” />
</mx:Application>
代 码会比较多,我们先看看<mx:states>标签,它是一个集合,就是你的程序有多少个状态,什么是状态呢?我自已理解就即是有多少个“面 谱”,即是现在程序里面有四个显示界面状态,所以里面有四个<mx:State>标签,每个<mx:State>状态都需要有一 个名字name属性,以区分是哪个界面状态,在每个状态里面都有很多<mx:SetProperty>的标签,看英文都知道了,该标签用于设 置这个状态下的所有界面元素的属性(组件的属性),因为每个界面状态中各个组件的大小布局都不同,所以在状态标签里就要预先设置好该状态下的组件的位置与 大小,那个target=”{windowC}”属性就是设置你要设置的哪个组件的名字拉,name=”height”就是你要设置的属性value= “333″就是你要设置该属性的值,我们细心看看的话,可能会发现,每个状态里面设置的属性,都是width,height,x,y这四个属性,我们看看 上面的最终效果就知道无论切换哪个状态,组件间的变换来来去去都是移动位置与大小改变,就是说当你变换状态时,需要改动哪些属性的,就将它的目标值设置在 <mx:SetProperty>标签里。再看看下面的<mx:transitions>标签,这个也是个集合,里面放着不同的 变换方法<mx:Transition>,我们来看看变换标签的代码:
<mx:Transition fromState=”*” toState=”*”>
<mx:Parallel targets=”{[windowA, windowB, windowC, windowD]}”>
<mx:Move />
<mx:Resize />
</mx:Parallel>
</mx:Transition>
formState 与toState属性是要设置该状态变换是怎样触发的,里面要填上状态的名字,<mx:State name=”C”>   C就是状态的名字,即是如果你formState=”A”,toState=”C”的话,只有从A状态切换到C状态时,才会产生以上的变换动画效果,如果 不附合该规则如A切换到B状态的话,则只会按状态的属性设置值来直接生成视图,而没有动画渐变效果了。如果填上“*”的话,就是无论是哪个状态切换到哪 个,都会运行动画效果,至于变换期间用到哪种动画效果来进行渐变,就在它的下级标签里定义了,这里它用到了<mx:Parallel>并列播 放移动与重整大小的动画效果,之前文章讲过,这里不多说了。基本上,一个变换就做好了,但我们还需要触发它,也就是去改变程序当前的显示状态:click =”currentState=’A'” 在每个组件的click事件里,改变程序的currentState值,就是改变程序的当前显示状态!之后动画效果就会触发了!

posted on 2009-09-21 11:27  帅死活该  阅读(331)  评论()    收藏  举报