quarta-feira, 26 de outubro de 2011

Aprenda Flex em uma semana

Aprenda FLex em uma semana.
http://www.adobe.com/devnet/flex/videotraining.html

alguns videos sobre o Flex.

vale a pena conferir...


Vitor Yudi Hansen

Abrir Página da internet no Flex Mobile

<?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="HTML Content" viewActivate="view1_viewActivateHandler(event)">
   
    <fx:Script>
        <![CDATA[
            import flash.media.StageWebView;
            import flash.net.URLRequest;
            import spark.events.ViewNavigatorEvent;
           
            protected var webView:StageWebView = new StageWebView();
            protected var openBrowser:Boolean = false;
           
           
            protected function view1_viewActivateHandler(event:ViewNavigatorEvent):void
            {
                if (StageWebView.isSupported)
                {
                    currentState = "normal";
                    webView.stage = stage;
                    webView.viewPort = new Rectangle(20, 100, 450, 450);
                    webView.addEventListener(LocationChangeEvent.LOCATION_CHANGE,onURLChange);   
                    webView.loadURL("http://vitorhansen.blogspot.com");   
                    addEventListener(ViewNavigatorEvent.REMOVING,onRemove);
                }
                else {
                    currentState = "unsupported";
                    lblSupport.text = "StageWebView feature not supported";
                }   
            }
           
            protected function onURLChange(event:LocationChangeEvent):void
            {
                trace("URL change");
                // Uncomment the following line to load in the default browser instead...
                //navigateToURL(new URLRequest(event.location));
            }
           
            protected function onRemove(event:ViewNavigatorEvent):void
            {
                this.webView.dispose();
            }
        ]]>
    </fx:Script>
   
    <s:states>
        <s:State name="normal"/>
        <s:State name="unsupported"/>
    </s:states>
   
    <s:Label id="lblSupport" includeIn="unsupported" width="95%" horizontalCenter="0" verticalCenter="0"/>
    <s:TextArea bottom="5" width="95%" includeIn="normal" horizontalCenter="0" enabled="false" editable="false"
                text="Exemplo Página Flex."/>
</s:View>

Vitor Yudi Hansen

Geolocalização Flex Mobile

Exemplo de Geolocalização com o Flex Mobile!

<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009" viewActivate="view1_viewActivateHandler(event)"
        xmlns:s="library://ns.adobe.com/flex/spark" title="Geolocation">
   
    <fx:Script>
        <![CDATA[
            import flash.sensors.Geolocation;
           
            import spark.components.supportClasses.StyleableTextField;
            import spark.events.ViewNavigatorEvent;
           
            protected var g:Geolocation = new Geolocation();   
           
            protected function view1_viewActivateHandler(event:ViewNavigatorEvent):void
            {
                if (Geolocation.isSupported)
                {
                    // Note: un-comment the muted check for android OS, however there is currently a bug on iOS where it will always return
                    //      muted and not update the location if left uncommented.
                    /* if (g.muted)
                    {
                    log.text = "Access to GPS has been muted";
                    return;
                    } */
                   
                    log.text = "Finding Location...";
                    g.addEventListener(GeolocationEvent.UPDATE, onUpdate);
                    addEventListener(ViewNavigatorEvent.REMOVING,onRemove);
                }
                else
                {
                    currentState = "unsupported";
                    lblSupport.text = "Geolocation is not supported on this device.";
                }   
            }
           
            protected function onUpdate(event:GeolocationEvent):void
            {
                trace("Update event called");
                log.text = "latitude = " + event.latitude +
                    "\nlongitude = " + event.longitude +
                    "\naltitude = " + event.altitude +
                    "\nverticalAccuracy = " + event.verticalAccuracy +
                    "\nhorizontalAccuracy = " + event.horizontalAccuracy +
                    "\nspeed = " + event.speed +
                    "\nheading = " + event.heading +
                    "\ntimestamp = " + event.timestamp;       
                // auto-scroll the text area to the latest text
                StyleableTextField(log.textDisplay).scrollV = StyleableTextField(log.textDisplay).scrollV+1;
            }
           
            protected function onRemove(event:ViewNavigatorEvent):void
            {
                g.removeEventListener(GeolocationEvent.UPDATE, onUpdate);               
            }
        ]]>
    </fx:Script>
    <s:states>
        <s:State name="normal"/>
        <s:State name="unsupported"/>
    </s:states>
   
    <s:layout>
        <s:VerticalLayout paddingTop="20" paddingBottom="20" paddingLeft="20" paddingRight="20" gap="40"/>
    </s:layout>
   
    <s:Label id="lblSupport" includeIn="unsupported" width="95%"/>
    <s:TextArea width="98%" enabled="false"
                text="The Geolocation sample displays updates to the current geographical location of the device in the form of latitudinal and longitudinal coordinates." includeIn="normal"/>
    <s:VGroup width="400" includeIn="normal">
        <s:Label text="Event Log:"/>
        <s:TextArea id="log" editable="false" height="400"/>
    </s:VGroup>
   
</s:View>

Vitor Yudi Hansen

Tela inteira Flex Mobile

<?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"
      viewActivate="view1_viewActivateHandler(event)"
        title="Full Screen">
    
    <fx:Script>
        <![CDATA[
            import spark.events.ViewNavigatorEvent;
            
            protected function view1_viewActivateHandler(event:ViewNavigatorEvent):void
            {
                if (stage.displayState == StageDisplayState.FULL_SCREEN_INTERACTIVE)
                    chk.selected = true;
            }
            
            protected function chk_changeHandler(event:Event):void
            {
                if (chk.selected)
                    stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
                else stage.displayState = StageDisplayState.NORMAL;
            }
        ]]>
    </fx:Script>
    <s:CheckBox id="chk" label="Full Screen" change="chk_changeHandler(event)" horizontalCenter="0" verticalCenter="0"/>
</s:View>

Vitor Yudi Hansen

Alert no Flex Mobile

Segue um exemplo do Tour de Flex,
de como coocar Alert no Flex mobile

<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx"
        xmlns:s="library://ns.adobe.com/flex/spark" title="SampleAlert" >
   
    <fx:Declarations>
        <fx:Component className="AlertMsg">
            <s:SkinnablePopUpContainer x="70" y="300">
                <s:TitleWindow title="My Message" close="close()">
                    <s:VGroup horizontalAlign="center" paddingTop="8" paddingBottom="8" paddingLeft="8" paddingRight="8" gap="5" width="100%">
                        <s:Label text="My alert message text here..."/>
                        <s:Button label="OK" click="close()"/>
                    </s:VGroup>
                </s:TitleWindow>
            </s:SkinnablePopUpContainer>
        </fx:Component>
    </fx:Declarations>
   
    <s:layout>
        <s:VerticalLayout paddingTop="5" paddingBottom="5" paddingLeft="5" paddingRight="5" gap="10"
                          horizontalAlign="center" verticalAlign="top"/>
    </s:layout>
   
    <s:TextArea text="This sample shows how you can display a simple alert message in a mobile application using the Spark SkinnablePopUpContainer. The mx.controls.Alert is not recommended for mobile."
                width="98%" editable="false"/>
    <s:Button label="Show Alert" click="(new AlertMsg()).open(this, false)"/>
</s:View>


É isso ai!

absssss

Vitor Yudi Hansen