月度归档:2011年01月

flex(air) image button

package buttons
{
    import mx.controls.Button;
    
    public class ImageButton extends Button
    {
        [Embed(source=”assets/image/delete-16.png”)]
        private var icon:Class;
        [Embed(source=”assets/image/deleteover.png”)]
        private var overIcon:Class;
        [Embed(source=”assets/image/deletedown.png”)]
        private var downIcon:Class;
        public function ImageButton()
        {
            super();
            this.label = “”;
            this.width = 16;
            this.height = 16;
            this.setStyle(“cornerRadius”,8);
            this.setStyle(“icon”,icon);
            this.setStyle(“downIcon”,downIcon);
            this.setStyle(“overIcon”,overIcon);
            this.setStyle(“upIcon”,icon);
        }
    }
}

应用程序启动前启动画面adobe flex air splash screen

这是一个应用程序启动前的窗口,可以用在多个方面,比如下载资源、检查更新、初始化控件等等

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Window xmlns:fx=”http://ns.adobe.com/mxml/2009″
          xmlns:s=”library://ns.adobe.com/flex/spark”
          xmlns:mx=”library://ns.adobe.com/flex/mx” width=”265″ height=”226″
          systemChrome=”none”
          type=”lightweight” showFlexChrome=”false” transparent=”true”
          verticalScrollPolicy=”off” horizontalScrollPolicy=”off” windowComplete=”init()”>
    <fx:Declarations>
        <!– Place non-visual elements (e.g., services, value objects) here –>
    </fx:Declarations>
    <fx:Script>
        <![CDATA[
            private function init():void
            {
                this.nativeWindow.x = Screen.mainScreen.visibleBounds.width/2 – this.width/2;
                this.nativeWindow.y = Screen.mainScreen.visibleBounds.height/2 – this.height/2;
                this.nativeWindow.visible = true;
              
                this.dispatchEvent(new Event(Event.COMPLETE));
                var timer:Timer = new Timer(500,10);
                timer.addEventListener(TimerEvent.TIMER,onTimer);
                timer.start();
            }
            
            private function onTimer(e:TimerEvent):void
            {
                if(lbl.text.length<15)
                    lbl.text += “.”;
                else
                    lbl.text = “download”;
            }
            
            public function showProgress(str:String,num:int):void
            {
                if(!pb.visible)
                    pb.visible = true;
                pb.label = str;
                pb.setProgress(num,100);
            }
        ]]>
    </fx:Script>
    <mx:Canvas width=”266″ height=”227″ borderStyle=”none”>
        <mx:Image source=”@Embed(‘splash-bg.jpg’)” >
            
        </mx:Image>
      
        <s:Label id=”lbl” y=”200″ fontSize=”14″ horizontalCenter=”0″ color=”0xdddddd” text=”download…”>
        </s:Label>
        <mx:ProgressBar id=”pb”  y=”230″ visible=”false” chromeColor=”white”
                        minimum=”0″ maximum=”100″
                        direction=”right” mode=”manual” width=”80%”
                         horizontalCenter=”0″>
            
        </mx:ProgressBar>
    </mx:Canvas>
</mx:Window>

 

 

主程序调用:

this.visible = false;//set app invisible.
splashScreen = new Splash_Window();
splashScreen.addEventListener(Event.COMPLETE,function():void
{
       //闪过之后的处理,splashScreen
});
splashScreen.open();//show splash screen.

 

Android创建sdcard详细图解

Android应用广泛,应用方式灵活,可以在模拟器中进行相应修改实现许多特定的功能需求。我们在这里就先来了解一下Android创建sdcard的具体方法,从中感受一下这一操作系统的相关特性。

Android创建sdcard步骤一、cmd进入tools目录输入mksdcard -l mycard 100M F:mysdcard.img

1. mycard命令可以使用三种尺寸:字节、K和M。如果只使用数字,表示字节。后面还可以跟K,如262144K,也表示256M。

2. mycard建立的虚拟文件最小为8M,也就是说,模拟器只支持大于8M的虚拟文件。

3. -l命令行参数表示虚拟磁盘的卷标,可以没有该参数。

4. 虚拟文件的扩展名可以是任意的,如mycard.abc。

5. mksdcard命令不会自动建立不存在的目录,因此,在执行上面命令之前,要先在当前目录中建立一个card目录。

6. mksdcard命令是按实际大小生成的sdcard虚拟文件。也就是说,生成256M的虚拟文件的尺寸就是256M,如果生成较大的虚拟文件,要看看自己的硬盘空间够不够哦!

Android创建sdcard步骤二、激活sdcard

1.命令行输入:emulator -avd my_android1.5 -sdcard F:mysdcard.img

我在命令行输入激活不了,不知为什么!待解决!

emulator: ERROR: the user data image is used by another emulator. aborting

2.如果在开发环境(Eclipse)中,可以在Run Configuration对话框中设置启动参数

或者在Preferences–>Android–>Launch加入

Android创建sdcard步骤三、sdcard中加入内容

F:android-sdk-windows-1.5_r3tools>adb push E:Xunleigive.mp3 /sdcard/give.mp3

mp3 frame header


AAAAAAAA AAABBCCD EEEEFFGH IIJJKLMM

Sign Length
(bits)
Position
(bits)
Description
A 11 (31-21) Frame sync (all bits must be set)
B 2 (20,19) MPEG Audio version ID
00 – MPEG Version 2.5 (later extension of MPEG 2)
01 – reserved
10 – MPEG Version 2 (ISO/IEC 13818-3)
11 – MPEG Version 1 (ISO/IEC 11172-3)

Note: MPEG Version 2.5 was added lately to the MPEG 2 standard.
It is an extension used for very low bitrate files, allowing
the use of lower sampling frequencies. If your decoder does
not support this extension, it is recommended for you to use
12 bits for synchronization instead of 11 bits.

C 2 (18,17) Layer description
00 – reserved
01 – Layer III
10 – Layer II
11 – Layer I
D 1 (16) Protection bit
0 – Protected by CRC (16bit CRC follows header)
1 – Not protected
E 4 (15,12) Bitrate index

bits V1,L1 V1,L2 V1,L3 V2,L1 V2, L2 & L3
0000 free free free free free
0001 32 32 32 32 8
0010 64 48 40 48 16
0011 96 56 48 56 24
0100 128 64 56 64 32
0101 160 80 64 80 40
0110 192 96 80 96 48
0111 224 112 96 112 56
1000 256 128 112 128 64
1001 288 160 128 144 80
1010 320 192 160 160 96
1011 352 224 192 176 112
1100 384 256 224 192 128
1101 416 320 256 224 144
1110 448 384 320 256 160
1111 bad bad bad bad bad

NOTES: All values are in kbps
V1 – MPEG Version 1
V2 – MPEG Version 2 and Version 2.5
L1 – Layer I
L2 – Layer II
L3 – Layer III

“free” means free format. The free bitrate must
remain constant, an must be lower than the maximum allowed
bitrate. Decoders are not required to support decoding of
free bitrate streams.
“bad” means that the value is unallowed.

MPEG files may feature variable bitrate (VBR). Each frame
may then be created with a different bitrate. It may be used
in all layers. Layer III decoders must support this method.
Layer I & II decoders may support it.

For Layer II there are some combinations of bitrate and mode
which are not allowed. Here is a list of allowed combinations.

bitrate
single channel
stereo
intensity stereo
dual channel
free
yes
yes
yes
yes
32
yes
no
no
no
48
yes
no
no
no
56
yes
no
no
no
64
yes
yes
yes
yes
80
yes
no
no
no
96
yes
yes
yes
yes
112
yes
yes
yes
yes
128
yes
yes
yes
yes
160
yes
yes
yes
yes
192
yes
yes
yes
yes
224
no
yes
yes
yes
256
no
yes
yes
yes
320
no
yes
yes
yes
384
no
yes
yes
yes
F 2 (11,10) Sampling rate frequency index

bits MPEG1 MPEG2 MPEG2.5
00 44100 Hz 22050 Hz 11025 Hz
01 48000 Hz 24000 Hz 12000 Hz
10 32000 Hz 16000 Hz 8000 Hz
11 reserv. reserv. reserv.
G 1 (9) Padding bit
0 – frame is not padded
1 – frame is padded with one extra slot

Padding is used to exactly fit the bitrate.As an example: 128kbps
44.1kHz layer II uses a lot of 418 bytes and some of 417 bytes
long frames to get the exact 128k bitrate. For Layer I slot
is 32 bits long, for Layer II and Layer III slot is 8 bits long.

H 1 (8) Private bit. This one is only informative.
I 2 (7,6) Channel Mode
00 – Stereo
01 – Joint stereo (Stereo)
10 – Dual channel (2 mono channels)
11 – Single channel (Mono)

Note: Dual channel files are made of two independant mono channel.
Each one uses exactly half the bitrate of the file. Most decoders
output them as stereo, but it might not always be the case.
    One example of use would be some speech
in two different languages carried in the same bitstream, and
then an appropriate decoder would decode only the choosen language.

J 2 (5,4) Mode extension (Only used in Joint stereo)

Mode extension is used to join informations that are of no
use for stereo effect, thus reducing needed bits. These bits
are dynamically determined by an encoder in Joint stereo mode,
and Joint Stereo can be changed from one frame to another,
or even switched on or off.

Complete frequency range of MPEG file is divided in subbands
There are 32 subbands. For Layer I & II these two bits determine
frequency range (bands) where intensity stereo is applied.
For Layer III these two bits determine which type of joint
stereo is used (intensity stereo or m/s stereo). Frequency
range is determined within decompression algorithm.

Layer I and II Layer III
value Layer I & II
00 bands 4 to 31
01 bands 8 to 31
10 bands 12 to 31
11 bands 16 to 31
Intensity stereo MS stereo
off off
on off
off on
on on
K 1 (3) Copyright
0 – Audio is not copyrighted
1 – Audio is copyrighted

The copyright has the same meaning as the copyright bit on CDs
and DAT tapes, i.e. telling that it is illegal to copy the contents
if the bit is set.

L 1 (2) Original
0 – Copy of original media
1 – Original media

The original bit indicates, if it is set, that the frame is
located on its original media.

M 2 (1,0) Emphasis
00 – none
01 – 50/15 ms
10 – reserved
11 – CCIT J.17

The emphasis indication is here to tell the decoder that the
file must be de-emphasized, ie the decoder must ‘re-equalize’
the sound after a Dolby-like noise supression. It is rarely
used.