Translate

2011/11/01

Flex 4 – FlexGlobals.topLevelApplication

在Flex 3读取HTML页面的flashvars的变量需要使用Application.application,在Flex 4 SDK里使用FlexGlobals.topLevelApplication代替了Application.application。 

Flex 4已经使用swfobject了: 


<script type="text/javascript"> 
    var swfVersionStr = "10.0.0"; 
    var xiSwfUrlStr = "playerProductInstall.swf"; 
    var flashvars = {}; 
    flashvars.firstname = "Nick"; 
    flashvars.lastname = "Danger"; 
    var params = {}; 
    params.quality = "high"; 
    params.bgcolor = "#ffffff"; 
    params.allowscriptaccess = "sameDomain"; 
    var attributes = {}; 
    attributes.id = "TestProject"; 
    attributes.name = "TestProject"; 
    attributes.align = "middle"; 
    swfobject.embedSWF( 
        "FlashVarTest.swf", "flashContent", "100%", "100%", swfVersionStr, 
        xiSwfUrlStr, flashvars, params, attributes); 
    swfobject.createCSS("#flashContent", "display:block;text-align:left;"); 
script>

读取flashvars中firstname和lastname变量的写法: 

var first_name : String = FlexGlobals.topLevelApplication.parameters.firstname;
var last_name : String = FlexGlobals.topLevelApplication.parameters.lastname;

在Flash Builder 4里用Flex 4 SDK开发时,如果还使用了Application.application,则会有提示这是Flex 3 SDK的写法。


文章來源:Flex 4 – FlexGlobals.topLevelApplication

沒有留言:

張貼留言

一山不容二虎之 EDBClient - Key violation 記事

關聯式資料庫裡有個很基本的特性:PRIMARY KEY 條件約束。 一個資料表只能有一個 PRIMARY KEY 條件約束,並且任何加入 PRIMARY KEY 條件約束的資料行都不可接受 Null 值。因為 PRIMARY KEY 條件約束保證唯一的資料,它們通常...