分类目录归档:Flex

编译源代码修改jwplayer Build jwplayer source code

首先checkout jwplayer的源代码
地址:http://developer.longtailvideo.com/svn/trunk/fl5
编译jwplayer需要以下程序
* Flex SDK 4.1: http://sourceforge.net/adobe/flexsdk/wiki/Downloads/
* Ant 1.7.0: http://ant.apache.org/bindownload.cgi
* FlexUnit 4: http://opensource.adobe.com/wiki/display/flexunit/FlexUnit (for testing the player)
环境配置好之后需要修改配置文件
flexsdk = C:/Program Files/Adobe/Adobe Flash Builder 4.5/sdks/4.5.1
windows环境下需要更改execextension
execextension = .exe
根据flash player版本更改flexsdk.target
C:Program FilesAdobeAdobe Flash Builder 4.5sdks4.5.1frameworkslibsplayer10.2
这个是本机的player版本,所以
flexsdk.target = 10.2.0
配置文件修改完成之后就可以用ant来build了
控制台切换到build文件夹运行:ant -buildfile buildbuild.xml
输出:
Buildfile: E:Developmentjwplayersourcebuildbuild.xml
check-properties:
clean-release:
build-release-player:
release-swf:
build-swf:
[exec] ????????????????C:Program FilesAdobeAdobe Flash Builder 4.5sdks4.5.1frameworksflex-config.xml??
[exec] E:Developmentjwplayersourceplayer.swf??112357 ????
BUILD SUCCESSFUL
Total time: 4 seconds
如果你的电脑上装的是64位的java sdk的话,可能会报错
现在开始修改源代码
1、去掉左下角的jwplayer水印
找到com.longtailvideo.jwplayer.view里的View.as
找到protected function setupComponents()里的setupComponent(_logo, n++);注释掉即可
2、修改右键about的菜单项
找到com.longtailvideo.jwplayer.view里的RightclickMenu.as
修改function setAboutText()函数
about = new ContextMenuItem(‘About Sheng00 …’);
修改function aboutHandler(evt:ContextMenuEvent)函数
navigateToURL(new URLRequest(‘http://www.sheng00.com’), ‘_blank’);
 
然后ant -buildfile buildbuild.xml
生成的就是修改过的player了
以下是效果:
 

JW Player goes here




 

flex中设置背景色或背景图片Fill background image or color in Group using Rect

<?xml version="1.0" encoding="utf-8"?>
<s:Application 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="400" height="300">
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:HGroup width="100%" height="100%">
        <s:Group width="50%" height="100%">
            <s:Rect width="100%" height="100%"
                    horizontalCenter="0"
                    verticalCenter="0"
                    topLeftRadiusX="5"
                    topLeftRadiusY="5"
                    topRightRadiusX="5"
                    topRightRadiusY="5">
                <s:fill>
                    <s:BitmapFill fillMode="repeat" source="@Embed(source='flag.png')"/>
                </s:fill>
            </s:Rect>
        </s:Group>
        <s:Group width="50%" height="100%">
            <s:Rect width="100%" height="100%"
                    horizontalCenter="0"
                    verticalCenter="0"
                    topLeftRadiusX="5"
                    topLeftRadiusY="5"
                    topRightRadiusX="5"
                    topRightRadiusY="5">
                <s:fill>
                    <s:SolidColor alpha="0.5" color="#8811dd"/>
                </s:fill>
            </s:Rect>
        </s:Group>
    </s:HGroup>
</s:Application>

效果如下:
[swfobj src=”http://www.sheng00.com/wp-content/uploads/2011/12/BackgroundFill.swf”]

Flex/Air Reading application settings

Reading the application descriptor file

You can read the application descriptor file of the currently running application, as an XML object, by getting the applicationDescriptor property of the NativeApplication object, as in the following:

var appXml:XML = NativeApplication.nativeApplication.applicationDescriptor;

You can then access the application descriptor data as an XML (E4X) object, as in the following:

var appXml:XML = NativeApplication.nativeApplication.applicationDescriptor;
var ns:Namespace = appXml.namespace();
var appId = appXml.ns::id[0];
var appVersion = appXml.ns::version[0];
var appName = appXml.ns::filename[0];
air.trace("appId:", appId);
air.trace("version:", appVersion);
air.trace("filename:", appName);

For more information, see The application descriptor file structure.

 

var fileTypes:XML = appXml.ns::fileTypes[0];

                    for each ( var fileType:XML in fileTypes.ns::fileType ) {

                        trace(fileType.ns::name);

                    }

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.

 

更改flash builder 语言

安装目录里有个FlashBuilder.ini
打开

-clean
-nl
en_US
-startup
plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.0.200.v20090519
-vmargs
-Xms256m
-Xmx512m
-XX:MaxPermSize=256m
-XX:PermSize=64m
-Djava.net.preferIPv4Stack=true
-Dorg.eclipse.equinox.p2.resolve

第三行是语言
可用的有:

de_DE
fr_FR
ja_JP
ru_RU
zh_CN
en_US

ActionScript访问WCF的svc WebService读取二进制数据

先写个wcf的svc服务
有个方法叫TestImage,返回一个图片的二进制数据
写好服务能用之后开始ActionScript的实现

先在build path里加入fiber.swc
我的fiber.swc路径是C:Program FilesAdobeAdobe Flash Builder 4pluginscom.adobe.flexbuilder.dcrad_4.0.0.272416dcradSwcs4.0libsfiber.swc

然后是代码


package WebService
{ import com.adobe.fiber.core.model_internal; import com.adobe.fiber.services.wrapper.WebServiceWrapper; import flash.events.Event; import flash.events.IOErrorEvent; import flash.filesystem.File; import flash.filesystem.FileMode; import flash.filesystem.FileStream; import flash.net.URLLoader; import flash.net.URLRequest; import flash.net.URLRequestMethod; import flash.net.URLVariables; import flash.utils.ByteArray; import mx.rpc.AbstractOperation; import mx.rpc.AsyncToken; import mx.rpc.events.ResultEvent; import mx.rpc.soap.mxml.WebService; public class ImageTest extends WebServiceWrapper { public function ImageTest() { _serviceControl = new WebService(); //load wsdl _serviceControl.loadWSDL("http://192.168.0.2:8080/EpubService/Service1.svc?wsdl"); model_internal::initialize(); getImage(); } public function getImage():void { var operation:AbstractOperation = _serviceControl.getOperation("TestImage"); operation.addEventListener(ResultEvent.RESULT,onresult); operation.send(); } private function onresult(e:ResultEvent):void { var imgByte:ByteArray = e.result as ByteArray; var f:File = File.documentsDirectory.resolvePath("test.jpg"); var fs:FileStream = new FileStream(); try { //open file in write mode fs.open(f,FileMode.WRITE); //write bytes from the byte array fs.writeBytes(imgByte); trace("create file: "+f.nativePath); } catch(e:Error) { trace(e.message); } finally { //close the file fs.close(); } } } }

输出:

create file: C:UsersQingDocumentstest.jpg