Showing posts with label Flex. Show all posts
Showing posts with label Flex. Show all posts

Monday, June 29, 2009

Using Global Variable in Flex

 

1. Declare the global variable in the main .mxml file.

 

In the main .mxml file :

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="TryAS()">
    <mx:Script>
        <![CDATA[
            public var bookSize:Rectangle = new Rectangle(0,0,800,600);

            public function TryAS():void{
                trace("Hello World");
            }
       ]]>
    </mx:Script>
</mx:WindowedApplication>

2.Use Application.application.yourGlobalVariableName to access the variable.

 

In the .as class you write :

import mx.core.Application;

// Application.application.yourGlobalVariableName

Application.application.bookSize.width

Thursday, June 25, 2009

Writing Action Script in Flex

Writing Action Script in Flex

Example of a .mxml file :

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="TryAS()">
    <mx:Script>
        <![CDATA[
            import Puzzles.*;
            public function TryAS():void{
                trace("InitPuzzles");
            }
       ]]>
    </mx:Script>

</mx:Application>

Monday, December 3, 2007

Note : Adobe Flex 2 (Training from the Source)


Lesson 24 Using Shared Objects
Shared Objects 可以由複雜的資料結構組成(話是這樣說沒錯,但是目前的經驗是,也只有簡單的資料型別可以,BitmapData 等大型的東西就要轉成Byte 寫進去,再自己 parse出來了)。學到的重點是使用前最好 instantiate 給它 ex. example.data.accounts = new Array();。另外就是,如果存的東西比較複雜 ex. boolean + array => example.data.accounts = {hasWork:Boolean, buyBooks:Array}。