• Flex 开发移动


    1.启动画面

     

    1 <?xml version="1.0" encoding="utf-8"?>
    2 <s:ViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
    3 xmlns:s="library://ns.adobe.com/flex/spark" firstView="views.MainView" applicationDPI="240"
    4 splashScreenImage="@Embed('图片地址')">
    5 <fx:Declarations>
    6 <!-- 将非可视元素(例如服务、值对象)放在此处 -->
    7 </fx:Declarations>
    8 </s:ViewNavigatorApplication>

     2.增加HTTPService 连接XML  

    在界面启动完后 添加完成事件来发送HTTPService服务

     

    <?xml version="1.0" encoding="utf-8"?>
    <s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
            xmlns:s="library://ns.adobe.com/flex/spark" title="Explore California"
            creationComplete="getTrips.send()">
    1     <fx:Declarations>
    2         <!-- 将非可视元素(例如服务、值对象)放在此处 -->
    3             <s:HTTPService url="http://services.explorecalifornia.org/rest/tours.php"
    4                    id="getTrips"
    5                    result="getTrips_resultHandler(event)"/>
    6     </fx:Declarations>    

    3.声明一个myTrips的ArrayCollection 来装内容     生成result事件  把收到的内容放到myTrips

     1 <fx:Script>
     2         <![CDATA[
     3             import mx.collections.ArrayCollection;
     4             import mx.rpc.events.ResultEvent;
     5             [Bindable]
     6             protected var myTrips:ArrayCollection;
     7             protected function getTrips_resultHandler(event:ResultEvent):void
     8             {
     9                 // TODO Auto-generated method stub
    10                 myTrips=event.result.tours.tour;
    11             }
    12             
    13         ]]>
    14     </fx:Script>

    4.拉一个list  来绑定显示 myTrips 

     1     <s:List left="0" right="0" top="0" bottom="0"
     2             dataProvider="{myTrips}">
     3       
     4     </s:List>

    5.在List中每一个XML对象会有一张图片作为标题图片

     这里用iconFunction 覆盖 iconField 

    iconFunction 主要是返回一个图片的方法来覆盖iconField

    <s:List left="0" right="0" top="0" bottom="0"
                dataProvider="{myTrips}">
                <s:itemRenderer>
                    <fx:Component>
                        <s:IconItemRenderer iconFunction="getPhotoURL" iconWidth="72"
                                            iconHeight="72" height="110" verticalAlign="top">
                            <fx:Script>
                                <![CDATA[
                                    protected function getPhotoURL(item:Object):String
                                    {
                                    return "images/"+item.image;
                                    }                
                                ]]>
                            </fx:Script>
                            
                        </s:IconItemRenderer>
                    </fx:Component>
                </s:itemRenderer>    
        </s:List>

     6.为List添加点击出现详细页面

    这是我们新建一个自定义组建 TripDetails

    在上面 list 添加 id 和 change事件

    <s:List id="tripList" change="tripList_changeHandler(event)" left="0" right="0" top="0" bottom="0"
        </s:List>

     

                protected function tripList_changeHandler(event:IndexChangeEvent):void
                {
                    // TODO Auto-generated method stub
                    navigator.pushView(views.TripDetails,tripList.selectedItem)
                }

     

    7.在TripDetails里添加内容

     

     

    <?xml version="1.0" encoding="utf-8"?>
    <s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
            xmlns:s="library://ns.adobe.com/flex/spark" title="TripDetails">
        <fx:Declarations>
            <!-- 将非可视元素(例如服务、值对象)放在此处 -->
        </fx:Declarations>
        
        <s:layout>
            <s:VerticalLayout/>
        </s:layout>
        <s:BitmapImage source="images/{data.image}"/>
        <s:TextArea editable="false" text="{data.description}"/>
        <s:Label text="{data.price}"/>
        <s:Button label="Go to Site"/>    
    </s:View>
  • 相关阅读:
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
    并行导致的进程数过大无法连接数据库
    Oracle 等待事件(Wait Event):Sync ASM rebalance 解析
    2套RAC环境修改scanip后客户端连接异常
    数据流通技术工具
    Hack The Box——Scavenger
    MySQL中InnoDB引擎对索引的扩展
    30分钟,教你从0到1搞定一次完整的数据可视化分析!
    【2020-MOOC-浙江大学-陈越、何钦铭-数据结构】树和堆(第五周的笔记和编程作业)
  • 原文地址:https://www.cnblogs.com/bulolo/p/2753442.html
Copyright © 2020-2023  润新知