flex gifloader
最近项目需要运用到FLEX,但GOOGLE一下发现可用的资料实在太少了。
找了好久发现google code上在这个还不错,还有很多东西可以好好研究研究
http://code.google.com/p/as3gif/
下面的例子是将动态GIF绑定到SPRITE上
package com.render
{
import flash.display.Sprite;
import flash.events.IOErrorEvent;
import flash.net.URLRequest;
import mx.core.Application;
import org.bytearray.gif.player.GIFPlayer;
public class SpriteWithBitmap extends Sprite
{
//Pass the source path or url here.
private static const defaultUrl:String = "/consoleweb/console/images/treewait.gif";
public function SpriteWithBitmap(url:String = defaultUrl)
{
loadImg(url);
}
private function loadImg(url:String):void
{
var gifPlayer:GIFPlayer = new GIFPlayer();
var request:URLRequest = new URLRequest(url);
gifPlayer.load(request);
gifPlayer.addEventListener(IOErrorEvent.IO_ERROR,loadFailure);
this.addChild(gifPlayer);
//设置图片居中显示
gifPlayer.x = Application.application.checkTree.width * 0.5 - 32;
gifPlayer.y = Application.application.checkTree.height * 0.5 -32;
}
private function loadFailure(event:IOErrorEvent):void
{
}
}
}
但要动态取到GIF的宽度还是没有头绪,在网上看到过这个
Hi, Thibault Imbert. The width/height property return 0, event after COMPLETE event dispatch. The GIFPlayerEvent has the ‘rect’, but it’s useless.
I’ve edited your GIFPlayer class (you should have done that).
All u needed 2 do is just to create a public var
public var rect:Rectangle;
And after in the readStream method to do so:
rect = aFrames[0].bitma
相关文档:
http://www.adobe.com/cn/devnet/flex/articles/best_practices_pt2_07.html
Flex 最佳做法 - 第 2 部分: 开发做法
Flex 开发最佳做法回顾
这些做法可以应用到所有 Flex 应用程序。请查看这些做法:
创建和使用 assets 目录
使用 assets 目录中的子目录
使用 SWF 目录
使用 images 目录
&n ......
effects\Blinds.as
JScript code
package effects
{
import effects.effectClasses.BlindsInstance;
import mx.controls.scrollClasses.ScrollBarDirection;
import mx.effects.IEffectInstance;
  ......
下载地址一:
http://download.macromedia.com/pub/flex/flex_builder/FB3_win.exe
大小: 424 MB ;未进行压缩的 Flex Builder 3 安装文件
不用注册登录,可以直接下载。
下载地址二:
http://trials.adobe.com/Applications/.../FB3_WWEJ.exe
大小: 385.84 MB ; 已经压缩的 Flex Builder 3 安装文件
需要注册 ......
flex中使用socket与其他语言(如Java)socket交互的例子。
自从Adobe Flash Player升级到9.0.124后,由于安全策略的修改,原来的socket连接方式将不能被使用,而必须采用新的安全策略方式来验证,具体的过程如下:
1.首先检测服务端的843端口是否提供安全策略文件;
&n ......
flex和C++服务器通信。因为安全沙漏问题,当swf位于A服务器,C++服务器程序位于B服务器时。
这时swf和B服务器建立Socket建立连接会产生跨域问题。
解决方法如下
swf建立socket时会先发起一个请求跨域文件的请求:"<policy-file-request/>"
服务器接收到后发送字符串
<?xml version="1.0"?>
<cross-doma ......