Archive Page 2

09
fev
12

Variáveis globais Flex

Variáveis Globais no Flex.

Olá.

Neste post vou mostrar como fazer com que uma (ou várias) variável seja utilizada e compartilhe o mesmo valor em toda a aplicação.

Para isto basta criar uma classe, com o método getInstance() e chamar esta classe em qualquer lugar do sistema através do getInstance(), e pronto você terá a mesma variável com o mesmo valor.

Classe de exemplo:

VariaveisGlobais.as

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

package com.blogspot.desenvolvendoemflex.utils {

 import mx.collections.ArrayCollection;

     

    [Bindable]

    public class VariaveisGlobais {

        private static var instance:VariaveisGlobais;

         

        public var variavel:ArrayCollection;

   

        public static function getInstance():VariaveisGlobais {

            if (instance==null) {

                instance = new VariaveisGlobais();

            }

            return instance;

        }

    }

}

 

 

09
fev
12

Diminuir cachem em aplicações Flex 3

CACHE

O que geralmente faço, é no arquivo AC_OETags.js trocar a função:

view plainHYPERLINK “http://www.guj.com.br/posts/list/142902.java” \l “”copy to clipboardHYPERLINK “http://www.guj.com.br/posts/list/142902.java” \l “”printHYPERLINK “http://www.guj.com.br/posts/list/142902.java” \l “”?

function AC_FL_RunContent(){

var ret =

AC_GetArgs

( arguments, “.swf”, “movie”, “clsid:d27cdb6e-ae6d-11cf-96b8-444553540000”

, “application/x-shockwave-flash”

);

AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);

}

function AC_FL_RunContent(){ var ret = AC_GetArgs ( arguments, “.swf”, “movie”, “clsid:d27cdb6e-ae6d-11cf-96b8-444553540000” , “application/x-shockwave-flash” ); AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs); }

por:

view plainHYPERLINK “http://www.guj.com.br/posts/list/142902.java” \l “”copy to clipboardHYPERLINK “http://www.guj.com.br/posts/list/142902.java” \l “”printHYPERLINK “http://www.guj.com.br/posts/list/142902.java” \l “”?

function AC_FL_RunContent(){

var ret =

AC_GetArgs

( arguments, “.swf?avoidCache=” + new Date(), “movie”, “clsid:d27cdb6e-ae6d-11cf-96b8-444553540000”

, “application/x-shockwave-flash”

);

AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);

}

function AC_FL_RunContent(){ var ret = AC_GetArgs ( arguments, “.swf?avoidCache=” + new Date(), “movie”, “clsid:d27cdb6e-ae6d-11cf-96b8-444553540000” , “application/x-shockwave-flash” ); AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs); }

09
fev
12

Registro na Apple Store

 

http://devgirl.org/2011/06/20/flexair-for-ios-development-process-explained/

09
fev
12

Teclado numérico Flex 4.6

Teclado

xtInput autoCapitalize=”sentence” width=”150″/>

<s:TextInput autoCorrect=”true” width=”150″/>

 

 

<s:TextInput softKeyboardType="contact" autoCorrect="true" autoCapitalize="word" returnKeyLabel="search" width="150"/>

<s:TextInput returnKeyLabel=”go” width=”150″/>

<s:TextInput returnKeyLabel=”search” width=”150″/>

 

<s:VGroup verticalAlign=”middle”>

<s:Label text=”Soft Keyboard=Number”/>

<s:TextInput softKeyboardType=”number” width=”180″/>

</s:VGroup>

09
fev
12

Tipos de teclado Flex 4.6

Teclado

xtInput autoCapitalize=”sentence” width=”150″/>

<s:TextInput autoCorrect=”true” width=”150″/>

 

 

<s:TextInput softKeyboardType="contact" autoCorrect="true" autoCapitalize="word" returnKeyLabel="search" width="150"/>

<s:TextInput returnKeyLabel=”go” width=”150″/>

<s:TextInput returnKeyLabel=”search” width=”150″/>

 

<s:VGroup verticalAlign=”middle”>

<s:Label text=”Soft Keyboard=Number”/>

<s:TextInput softKeyboardType=”number” width=”180″/>

</s:VGroup>

09
fev
12

Conexão com SQLite

import flash.data.SQLConnection;
import flash.data.SQLStatement;
import flash.data.SQLResult;
import flash.data.SQLMode;
import flash.events.SQLErrorEvent;
import flash.events.SQLEvent;
import flash.filesystem.File;

private var conn:SQLConnection;
private var createStmt:SQLStatement;
private var insertStmt:SQLStatement;
private var insertStmt2:SQLStatement;
private var selectStmt:SQLStatement;

protected function init(event:FlexEvent):void
{
var dbFile:File = File.applicationStorageDirectory.resolvePath(“ttt.db”);

conn = new SQLConnection();
conn.openAsync(dbFile);
conn.addEventListener(SQLEvent.OPEN, openSuccess);
conn.addEventListener(SQLErrorEvent.ERROR, openFailure);
}

protected function openSuccess(event:SQLEvent):void
{
conn.removeEventListener(SQLEvent.OPEN, openSuccess);
conn.removeEventListener(SQLErrorEvent.ERROR, openFailure);

trace (“openSuccess”);

selectStmt = new SQLStatement();
selectStmt.sqlConnection = conn;

var sql:String = “SELECT * FROM nnn WHERE id = 2”;
selectStmt.text = sql;

selectStmt.addEventListener(SQLEvent.RESULT, selectResult);
selectStmt.addEventListener(SQLErrorEvent.ERROR, selectError);

selectStmt.execute();
}

protected function openFailure(event:SQLErrorEvent):void
{
conn.removeEventListener(SQLEvent.OPEN, openSuccess);
conn.removeEventListener(SQLErrorEvent.ERROR, openFailure);

trace (“openFailure”);
}

protected function selectResult(event:SQLEvent):void
{
selectStmt.removeEventListener(SQLEvent.RESULT, selectResult);
selectStmt.removeEventListener(SQLErrorEvent.ERROR, selectError);
trace (“selectResult”);
var result:SQLResult = selectStmt.getResult();
}

protected function selectError(event:SQLErrorEvent):void
{
selectStmt.removeEventListener(SQLEvent.RESULT, selectResult);
selectStmt.removeEventListener(SQLErrorEvent.ERROR, selectError);
trace (“selectError ” + event.error);
}

 

09
fev
12

Criar menu Flex 4.6

<?xml version=”1.0″ encoding=”utf-8″?>

<s:View xmlns:fx=”http://ns.adobe.com/mxml/2009&#8243;

xmlns:s=”library://ns.adobe.com/flex/spark” title=”HomeView”>

<fx:Script>

<![CDATA[

private function itemClickInfo(event:MouseEvent):void {

switch (event.currentTarget.label) {

case “Add” :

myTA.text = “Add selected”;

break;

case “Cancel” :

myTA.text = “Cancel selected”;

break;

case “Delete” :

myTA.text = “Delete selected”;

break;

case “Edit” :

myTA.text = “Edit selected”;

break;

case “Search” :

myTA.text = “Search selected”;

break;

default :

myTA.text = “Error”;

}

}

]]>

</fx:Script>

<fx:Declarations>

<!– Place non-visual elements (e.g., services, value objects) here –>

</fx:Declarations>

<s:viewMenuItems>

<s:ViewMenuItem label=”Add” click=”itemClickInfo(event);”/>

<s:ViewMenuItem label=”Cancel” click=”itemClickInfo(event);”/>

<s:ViewMenuItem label=”Delete” click=”itemClickInfo(event);”/>

<s:ViewMenuItem label=”Edit” click=”itemClickInfo(event);”/>

<s:ViewMenuItem label=”Search” click=”itemClickInfo(event);”/>

</s:viewMenuItems>

<s:Button x=”16″ y=”48″ label=”Abrir menu”  click=”mx.core.FlexGlobals.topLevelApplication.viewMenuOpen=true;”/>

<s:Button x=”142″ y=”48″ label=”Fechar Menu” click=”mx.core.FlexGlobals.topLevelApplication.viewMenuOpen=false;”/>

<s:TextArea id=”myTA” x=”26″ y=”126″/>

 

</s:View>