存档

文章标签 ‘ActionScript’

在URLRequest中构造HTTP协议发送数据

2010年8月31日 f-angel 没有评论
来源博客:Tencent ISD Flash Team

有一点经验的AS开发者都知道,要发送数据用URLRequest,要POST数据用URLVarialbes。一切都非常好,直到碰到了发送图片+数据的时候···

因为图片BitmapData一般都Encode成了ByteArray,以流的形式传至后台,而变量是以值对的形式POST过去,这就造成了后台无法区分二进制和值对。

以前的做法是先把图片单独发过去,然后等服务器返回URL,再将URL与其他数据以值对的形式发送至后台。(比较Stupid,但是Work!!)

其实抓包分析之后,发现Flash其实也是以标准的HTTP协议发送数据的,我们完全可以构造URLRequest的内容来构造一个标准的HTTP协议。

首先分析一个简单的HTTP协议例子(截取自FileReference的例子):

POST /handler.cfm HTTP/1.1
Accept: text/*
Content-Type: multipart/form-data;
boundary=———-Ij5ae0ae0KM7GI3KM7
User-Agent: Shockwave Flash
Host: www.example.com
Content-Length: 421
Connection: Keep-Alive
Cache-Control: no-cache

————Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7
Content-Disposition: form-data; name=”Filename”

MyFile.jpg
————Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7
Content-Disposition: form-data; name=”Filedata”; filename=”MyFile.jpg”
Content-Type: application/octet-stream

FileDataHere
————Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7
Content-Disposition: form-data; name=”Upload”

Submit Query
————Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7–

其中:

POST /handler.cfm HTTP/1.1
Accept: text/*
Content-Type: multipart/form-data;
boundary=———-Ij5ae0ae0KM7GI3KM7
User-Agent: Shockwave Flash
Host: www.example.com
Content-Length: 421
Connection: Keep-Alive
Cache-Control: no-cache

这一串是HTTP头,一般我们不用管太多,URLRequest会自动构造,但是有几个参数要留意一下:

Content-Type: multipart/form-data;

boundary=———-Ij5ae0ae0KM7GI3KM7

第一个是类似页面表单的数据类型。而boundary则定义了分界符的字符(这个可以自己定义)。

所以我们在AS3代码中应该写如下语句:

this.request.contentType = “multipart/form-data; boundary=—————————Ij5ae0ae0KM7GI3KM7” ;

就是要构造在HTTP协议中添加了这两段内容。

接下来是内容部分:

————Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7
Content-Disposition: form-data; name=”Filename”

MyFile.jpg
————Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7

上下两段是分割符(细心的同学可能已经发现其实就是我们刚刚定义的boundary的值)。一般都是这样括住我们需要的数据(结尾除外)

Content-Disposition: form-data;

说明的是数据的类型,这个可以上网去查看,一般比较常用的有例如image/jpeg,image/x-png,当然还有非常多的其他值。

name=”Filename”

这个就是POST的变量的变量名。

MyFile.jpg

这个就是变量的值。

所以上面的全句的意思可以理解为Filename = MyFile.jpg;

在AS3里我们可以这样写:

_byteArray.writeUTFBytes(“\r\n—————————–” + separator + “\r\n”);

_byteArray.writeUTFBytes(“Content-Disposition: form-data; name=\”” + $name +”\”\r\n\r\n” + $value);

_byteArray.writeUTFBytes(“\r\n—————————–” + separator + “\r\n”);

(这里为了方便看写了三句,其实可以一句写完)

同理,对于图片数据,HTTP协议有一些不同:

————Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7
Content-Disposition: form-data; name=”Filedata”; filename=”MyFile.jpg”
Content-Type: application/octet-stream

FileDataHere
————Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7

(实践证明其实不用这么写,只要按我下面的写法就OK了,但还是把比较标准的格式给大家看看)

_byteArray.writeUTFBytes(“\r\n—————————–” + separator + “\r\n”);

_byteArray.writeUTFBytes(“Content-Disposition: form-data; name=\”” + $name + “\”; filename=\”” + $filename + “\”\r\nContent-Type: ” + $type + “\r\n\r\n”);

_byteArray.writeBytes($content);

_byteArray.writeUTFBytes(“\r\n—————————–” + separator + “\r\n”);

最后一个变量的结尾记得换成结尾的分割符(跟我们一直写的分割符有那么一点点不同)

————Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7–

即:

_byteArray.writeUTFBytes(“\r\n—————————–” + separator + “–”);

然后把我们一直在编辑的赋值给URLRequest,即:

_request.data = _byteArray;

我们就大功告成了,同时后台同学也可以很轻松的按标准的格式去获取我们发送过来的数据。

下面附上我自己对应整合的一个小类,没测试过,只是做个范例吧 :)

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

package com.dannycheung
{
import flash.net.URLRequest;
import flash.net.URLRequestMethod;
import flash.net.URLVariables;
import flash.utils.ByteArray;

/**
* @author DannyCheung
*/
public class HttpRequestBuilder
{
//构造的URLRequest
private var _request:URLRequest;
//构造的二进制ByteArray
private var _byteArray:ByteArray;
//Http协议分割符
private var _separator:String;
//标志位
private var PROTOCAL_END_SET:Boolean = false; //是否填写HTTP文件尾

public function HttpRequestBuilder ($url:String, $separator:String = “7d86d710144a”) {
//初始化
this.separator = $separator;

this.request = new URLRequest($url);
this.request.method = URLRequestMethod.POST;
this.request.contentType = “multipart/form-data; boundary=—————————” + separator;

this._byteArray = new ByteArray();
}

/*
* 写入变量
* @param $name 写入的变量名
* @param $value 写入的变量值
*/
public function writeVariable($name:String, $value:String):void {
writeSeparator();
_byteArray.writeUTFBytes(“Content-Disposition: form-data; name=\”” + $name +”\”\r\n\r\n” + $value);
}

/*
* 写入图片
* @param $name 变量名
* @param $filename 图片文件名
* @param $type 图片类型,在HttpRequestBuilderConsts下定义
* @param $content 图片二进制数据
*/
public function writeImage($name:String, $filename:String, $type:String, $content:ByteArray):void {
writeSeparator();
_byteArray.writeUTFBytes(“Content-Disposition: form-data; name=\”” + $name + “\”; filename=\”” + $filename + “\”\r\nContent-Type: ” + $type + “\r\n\r\n”);
_byteArray.writeBytes($content);
}

/*
* 构造HTTP分割线
*/
public function writeSeparator():void {
_byteArray.writeUTFBytes(“\r\n—————————–” + separator + “\r\n”);
}

/*
* 构造HTTP结尾,只能调用一次,二次调用会抛出错误
*/
public function writeHttpEnd():void {
if (!PROTOCAL_END_SET) {
_byteArray.writeUTFBytes(“\r\n—————————–” + separator + “–”);
} else {
throw(new Error(“Write the Http End More Than Once”));
}
}

/*
* 获取构造好的URLRequest
*/
public function getURLrequest():URLRequest {
return this.request;
}

//get set
public function get separator():String { return _separator; }
/*public function set separator(value:String):void
{
//TODO 替换之前写入的内容
_separator = value;
}*/

/*
* 获取前会检查是否写入HTTP结尾,未调用的话会报错
*/
public function get request():URLRequest {
if (!PROTOCAL_END_SET) throw(new Error(“Havn’t Write the Http End Yet”)); //??还是应该自动构造
_request.data = _byteArray;
return _request;
}
}

}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

package com.dannycheung
{

/**
* …
* @author DannyCheung
*/
public class HttpRequestBuilderConsts
{
public static const JPG:String = “image/jpeg”;
public static const PNG:String = “image/x-png”;

public function HttpRequestBuilderConsts() {

}
}

}

分类: ActionScript 标签:

js控制flash之参数

2010年7月2日 f-angel 没有评论

CODE:

Play() —————————————- 播放动画
StopPlay()————————————停止动画
IsPlaying()———————————– 动画是否正在播放
GotoFrame(frame_number)—————- 跳转到某帧
TotalFrames()——————————- 获取动画总帧数
CurrentFrame()——————————回传当前动画所在帧数-1
Rewind()————————————-使动画返回第一帧
SetZoomRect(left,top,right,buttom)——-放大指定区域
Zoom(percent)——————————改变动画大小
Pan(x_position,y_position,unit)————使动画在x,y方向 上平移
PercentLoaded()—————————-返回动画被载入的百分比
LoadMovie(level_number,path)———– 加载动画
TGotoFrame(movie_clip,frame_number)- movie_clip跳转到指定帧数
TGotoLabel(movie_clip,label_name)—— movie_clip跳转到指定标签
TCurrentFrame(movie_clip)————— 回传movie_clip当 前帧-1
TCurrentLabel(movie_clip)—————–回传movie_clip当 前标签
TPlay(movie_clip)—————————播放movie_clip
TStopPlay(movie_clip)———————-停止movie_clip的 播放
GetVariable(variable_name)—————–获取变量
SetVariable(variable_name,value)———–变量赋值
TCallFrame(movie_clip,frame_number)—call指定帧上的action
TCallLabel(movie_clip,label)—————-call指定标签上的action
TGetProperty(movie_clip,property)——–获取movie_clip的 指定属性
TSetProperty(movie_clip,property,number)-设置movie_clip的 指定属性
其中TGetProperty 和 TSetProperty 的属性是使用数字0-18来 获取的,下面是各数字代表的属性:
属性 作用 数字 使用方式

X Position X坐标 0 Get,Set
Y Position Y坐标 1 Get,Set
X Scale X方向缩放比率 2 Get,Set
Y Scale Y方向缩放比率 3 Get,Set
CurrentFrame movie_clip当前所在帧数 4 Get
TotalFrames movie_clip总帧数 5 Get
Alpha movie_clip的透明度 6 Get,Set
Visibility movie_clip是否可见 7 Get,Set
Width movie_clip的宽度 8 Get
Height movie_clip的高度 9 Get
Rotation movie_clip的旋转度 10 Get,Set
Target movie_clip的路径 11 Get
Framesloaded movie_clip已载入的帧数 12 Get
Name movie_clip的实体名字 13 Get,Set
DropTarget movie_clip的拖拽 14 Get
Url 包含movie_clip的动画的url 15 Get
HighQuality 设置画面质量为高质量 16 Get,Set
FocusRect 显示按钮边框 17 Get,Set
SoundBufTime 预设声音缓冲时间 18 Get,Set
flash调用js:
可以使用fscommand来调用js,但使用getUrl方 面更为的方便,比如:getURL(”BLOCKED SCRIPTalert(’”+ message+ “‘)”);就可 以使用js的alert的方法作为调试使用.

引用

Play() 使已停止 了的FLASH动画在停止处开始播放
格式:YourMovieName.Play()
StopPlay() 停止正在播放的FLASH文件?
格式:YourMovieName.StopPlay()
IsPlay() 如果FLASH文件正在播放中,此函数值为true?
例如:if (YourMovieName.IsPlaying)
alert(”Playing”)
如当动画正在播放,就会弹出一个警告条。
GotoFrame(int frameNum) 控制FLASH跳到指定的frame
格式:YourMovieName.GotoFrame(10)
TotalFrames() 传回FLASH动画的总帧数???
格式:YourMovieName.TotalFrames()
CurrentFrame() 传回FLASH动画目前所在的帧数减一
FS Command控制的帧都是由0开始的
格式:YourMovieName.CurrentFrame()+1
Rewind() 控制FLASH动画条会第一帧并停止?
格式:YourMovieName.Rewind()
SetZoomRect(int left,
int top,int right,int bottom) 放大指定的坐标区域(int left=左坐标 的整数;int right为右坐标的整数;int top和int bottom分 别表示上坐标和下坐标的整数)

Zoom(int percent) 改变FLASH动画的大小。这函数只允许你将放大后的 图片缩小到原图片的大小
YourMovieName.Zoom(50)放大一倍
YourMovieName.Zoom(200)缩小一倍
YourMovieName.Zoom(0)恢复原始尺寸
Pan(int x,int y,int mode) 平移放大后的FLASH动画。x,y表 示移动目的地的x轴和y轴的坐标;int mode表示表示坐标的单 位,但其值为”0″时,以象数为单位,为”1″时,以百分比为单 位。??

PercentLoaded() 回传0~100的值,此值为浏览器载入FLASH的 百分比程度。可用此功能制作loading画面
如:if (YourMovieName.PercentLoaded()$#@60;100)
YourMovieName.GotoFrame(YourMovieName.PercentLoaded())
LoadMovie(int layer,
String url) 载入其他的FLASH动画,”int layer”为level的 值,数值越大,动画就放得越上;”string url”为要栽入的动画的路径和名称??
如:LoadMovie(1, “yourmovie.swf”)?表示把yourmovie.swf的 动画加载到原来的动画上,level为1
LoadMovie(”", “yourmovie.swf”)表示卸载yourmovie.swf动画?
TGotoFrame(String target,
int frameNum) 控制动画跳到指定的movie clip的第几帧
TGotoFrame(”_flash0/mm”,10)表示跳到instance name为mm的movie clip的第十帧
TGotoLabel(String target,
String label) 控制动画跳到指定的movie clip的指定的label?
TGotoFrame(”_flash0/mm”,”ten”)
TCurrentFrame(String target) 传回指定的movie clip的当前所在帧减 一?
fras=YourMovieName.TCurrentFrame(”_flash0/mm”)+1
TCurrentLabel(String target) 传回指定的movie clip当前所在的label?
label=play_movie.TCurrentLabel(”_flash0/mm”)
TPlay(String target) 控制指定的movie clip从停止出开始播放
YourMovieName.Play(”_flash0/mm”)
TStopPlay(String target) 控制指定的movie clip停止播放??
YourMovieName.Play(”_flash0/mm”)

转一些as类库

2010年5月22日 f-angel 没有评论

1、 as3ebaylib http://code.google.com/p/as3ebaylib/

2、 as3youtubelib http://code.google.com/p/as3youtubelib/

3、 as3flickrlib http://code.google.com/p/as3flickrlib/

4、Yahoo ASTRA Flash Components http://developer.yahoo.com/flash/astra-flash/

5、 facebook-as3 http://code.google.com/p/facebook-as3/

6、 as3awss3lib http://code.google.com/p/as3awss3lib/

7、Adobe ActionScript 3:resources:apis:libraries (官方,包括corelib、FlexUnit、Flickr、Mappr、RSS and Atom libraries、Odeo、YouTube) http://labs.adobe.com/wiki/index.php/ActionScript_3:resources:apis:libraries

8、 Tweener 用于过渡与切换的一组动画库 http://code.google.com/p/tweener/

9、 uicomponents-as3 一组轻量级的AS3 UI组件库 http://code.google.com/p/uicomponents-as3/

10、 as3ds AS3的数据结构实现 http://code.google.com/p/as3ds/

11、mecheye-as3- libraries 一组主要用于Flash 游戏开发的AS3库 http://code.google.com/p/mecheye-as3-libraries/

12、 XIFF 一套XMPP协议的AS3实现 http://svn.igniterealtime.org/svn/repos/xiff/branches/xiff_as3_flexlib_beta1/

13、 FZip 一套AS3库,可用作对ZIP压缩文件的载入、修改与创建 http://codeazur.com.br/lab/fzip/

14、 FlexLib 一套开源的Flex界面组件库 http://code.google.com/p/flexlib/

15、 AnimatedGIfLoader Flex Component 可载入GIF的Flex组件 http://dougmccune.com/blog/animatedgifloader-flex-component/

16、 goplayground 一套轻量级的,可用创建属于你自己的AS3 动画工具的库 http://code.google.com/p/goplayground/

17、 AlivePDF 开源的用于PDF创建的AS3库 http://www.alivepdf.org/

18、jwopitz-lib 一组开源的Flex用户界面组件 http://code.google.com/p/jwopitz-lib/

19、 as3crypto AS3实现的一套加密库,包括多种加密算法 http://code.google.com/p/as3crypto/

20、 flare 一套强大的可视化交互的AS3类库 http://flare.prefuse.org/

21、SWFAddress 一小而强大的库,可以为Flash和Ajax提供深链接的功能 http://www.asual.com/swfaddress/

22、SWFObject 用于嵌入Flash,Adobe官方也认可了 http://code.google.com/p/swfobject/

23、ulse Particle System 一套开源的强大的AS3动态粒子系统 http://code.google.com/p/pulse-particle/ http://www.rogue-development.com/pulseParticles.html

24、 SpringGraph Flex Component http://mark-shepherd.com/blog/springgraph-flex-component/

25、 GoASAP AS3动画库 http://code.google.com/p/goasap/ http://www.goasap.org/index.html

26、 asaplibrary 一套开源的Flash Actionscript3.0 RIA库 http://code.google.com/p/asaplibrary/ http://asaplibrary.org/ http://asapframework.org

27、 as3mathlib 开源Flex/Actionscript数学库 http://code.google.com/p/as3mathlib/

28、 as3corelib 包含一些基础功能AS3库 http://code.google.com/p/as3corelib/

29、 minimalcomps 一组AS3 UI组件 http://www.bit-101.com/minimalcomps/

30、as3gif http://code.google.com/p/as3gif/

31、 queueloader-as3 一组AS3库,用来进行资源序列载入及监测 http://code.google.com/p/queueloader-as3/

32、 TweenMax (AS3) http://blog.greensock.com/tweenmaxas3/

33、 Atellis Reflection Component 一款Flex反射效果组件 http://labs.atellis.com/2007/07/11/atellis-reflection-component/

34、 AS3Eval 简单来说,就是用AS3实现的AS3编译器 http://eval.hurlant.com/

35、 ByteArray的组件、库合集,包括liquid components、mousegesture、ASZip、GIF Player、GIF Animation Encoder、AlivePDF、Live JPEG Encoder、ScaleBitmap等 http://www.bytearray.org/?page_id=82

36、 AS3C 针对AVM2虚拟机,用C#写的字节码编译器 http://code.google.com/p/as3c/

37、 as3httpclientlib as3实现的http客户端 http://code.google.com/p/as3httpclientlib/

38、 as3ui 一组常规的as3 ui界面库 http://code.google.com/p/as3ui/

39、as3xls 让你在 flex中可以读写Excel文件 http://code.google.com/p/as3xls/

40、as3flexdb 让你的flex程序可以连接到MySQL服务器,主要是使用AMFPHP来访问PHP服务器 http://code.google.com/p/as3flexdb/ 这一是一篇详细使用介绍的教程 http://itutorials.ro/viewtopic.php?f=9&t=7

41、 vivisectingmedia-as3  一组AS3/Flex实用库,是作者在实践中总结出来的 http://code.google.com/p/vivisectingmedia-as3/

Actionscript 3.0 Class

1、fZip 此类可允许你载入标准的zip文件并提取里面包含的文件 http://wahlers.com.br/claus/blog/zip-it-up/

2、 AS3: Layout class for Flash CS3 一组用作布局的类 http://www.senocular.com/?id=2.8

3、 CSSLoader 该类允许Flex应用程序在运行时载入CSS http://www.rubenswieringa.com/blog/cssloader

4、 AS3: QueryString 一个单例类,用来获取URL地址后所带参数值对 http://evolve.reintroducing.com/2008/07/03/as3/as3-querystring/#more-141

5、 ActionScript 3 Contextual Menu Manager Class AS3关联菜单管理类 http://www.blog.noponies.com/archives/103

2D & 3D Engine

1、 APE (Actionscript Physics Engine) 物理引擎 APE 前身是as2版本的Flade,呼声很高,优点就是清晰简单,一共没有几个类:),目前版本alpha 0.45 ,有API文档和示例,教程有一篇quick start ,在Google Group上有一个论坛可以讨论。svn上一直在更新目前svn上的版本为0.5a

http://www.cove.org/ape/

2、 Away3D http://code.google.com/p/away3d/

3、 Papervision3D http://code.google.com/p/papervision3d/

4、Sandy 开源3D库 http://www.flashsandy.org/versions/3.0

5、 FORM 一套AS3完成的用于2D刚性物体的物理引擎 http://code.google.com/p/foam-as3/

6、Five3D 基于矢量的Flash 3D 交互动画创建 http://five3d.mathieu-badimon.com/

7、Flade (Flash Dynamics Engine) 一套开源的2D物理引擎,AS2实现 http://www.cove.org/flade/

8、 Box2DFlashAS3 2D物理引擎,AS3实现,基于强大的Box2D C++物理库 http://box2dflash.sourceforge.net/

9、 Paradox 基于Flash的第一称3D引擎 http://animasinteractive.com/propaganda/

10、 ND3D AS3 3D Engine  一款简单的AS3开源3D引擎,编译后的引擎大小仅约10K http://code.google.com/p/nd3d/ http://www.nulldesign.de/nd3d-as3-3d-engine/

11、 motor2 基于Box2d的AS3刚体引擎,也是2D的. 作者就是 AS3数据结构的作者,2007年最后一天发布 作者主页:http://lab.polygonal.de/motor_physics/ 代码:http://code.google.com/p/motor2/

12、 WOW-Engine 法国人写的,基于Sandy library的算法 3D物理引擎 http://seraf.mediabox.fr/wow-engine/as3-3d-physics-engine-wow-engine/

FrameWorks

1、 Cairngorm Adobe官方出的Flex框架 http://labs.adobe.com/wiki/index.php/Cairngorm

2、 PureMVC 纯AS3框架,也有其它语言的实现 http://www.puremvc.org/

3、ASWing AS3 一套开源的AS3 GUI框架 http://www.aswing.org/

4、 EasyMVC 由事件驱动的MVC框架 http://projects.simb.net/easyMVC/

5、Mate 基于Tag及事件驱动的Flex框架 http://mate.asfusion.com/

6、 ARP 基于模式(Pattern)的RIA框架,Flash平台,支持AS2和AS3 http://osflash.org/projects/arp

7、 Gaia 开源的Flash前端框架,支持AS2和AS3,用于快速开发 http://www.gaiaflashframework.com/

8、 flest Actionscript3.0/Flex应用程序框架,用来开发企业级的RIA http://code.google.com/p/flest/

9、 Gugga Flash Framework 更新至AS3 http://www.gugga.com/flashblog/

10、Prana 另一个提供了IOC反转控制的框架,类似著名的Spring框架 http://www.pranaframework.org/

11、OpenFlux 开源的Flex组件框架,让开发Flex组件更加快速容易 http://code.google.com/p/openflux/

12、Degrafa 声明式的Flex图形框架,允许以MXML标签的方式绘制图形、创建皮肤,还包括对CSS的支持 http://code.google.com/p/degrafa/

13、 FlexMVCs 针对AS3和Flex的应用程序框架,基于PureMVC,作了些修正和精简 http://code.google.com/p/flexmvcs/

Flash & Flex Tools、Servers

1、FlexUnit Flex/Actionscript3.0单元测试框架 http://code.google.com/p/as3flexunitlib/

2、 Visual FlexUnit 增强的FlexUnit,支持“可视化断言” http://code.google.com/p/visualflexunit/

3、 RED bug debug调试控制器,让Flash、Flex、AIR应用程序更加容易 http://www.realeyesmedia.com/redbug/

4、 reflexutil 可在运行时对Flex组件进行调试 http://code.google.com/p/reflexutil/

5、 FxSpy 当Flex应用程序运行时可以检测和动态的改变可视化组件属性值 http://code.google.com/p/fxspy/

6、 ThunderBolt 基于Firefox的Firebug插件的日志扩展,支持AS2及AS3 http://code.google.com/p/flash-thunderbolt/

7、 FlashTracer Firefox扩展,可以以侧栏的方式将Flash中trace()的结果显示

8、RIALogger 另一款 Flex/AIR的Debug工具 http://renaun.com/blog/flex-components/rialogger/

9、 Alcon 一款轻量级的AS2及AS3的Debug工具,AIR方式将Debug信息展示出来 http://blog.hexagonstar.com/alcon/

10、 GDS (Granite Data Services) 开源,提供了Adobe LiveCycle Data Services类似功能的服务器 http://www.graniteds.org/

Flex Explorers (大部分为Flex2版本,但同样适用于Flex3)

1、Flex3 Component Explorer Flex各类组件示例 http://examples.adobe.com/flex3/componentexplorer/explorer.html

2、 Resize ManagerFX Explorer (此为商业作品,要收费的) http://www.teotigraphix.com/explorers/ResizeManagerFX/ResizeManagerFXExplorer.html

3、 Flex3 Style Explorer http://examples.adobe.com/flex3/consulting/styleexplorer/Flex3StyleExplorer.html

4、 Flex2 Style Explorer(添加了Kuler功能)Flex UI组件风格定制并可输出为CSS http://www.maclema.com/content/sek/

5、 Flex2 Style Explorer(Adobe 原始的版本) http://examples.adobe.com/flex2/consulting/styleexplorer/Flex2StyleExplorer.html

6、 Flex2 Filter Explorer 查看各类滤镜效果并可进行设置 http://merhl.com/flex2_samples/filterExplorer/ http://merhl.com/?p=40 (AIR版本)

7、Flex2 Primitive Explorer 在Flex中创建各种简单形状

http://www.flexibleexperiments.com/Flex/PrimitiveExplorer/Flex2PrimitiveExplorer.html

分类: Flash 标签: ,

Flash as2,as3 加载MP3(load music)

2010年4月1日 f-angel 没有评论

flash 背景音乐可以用外部加载方式(用数据流就行了,直接在外面load)

as2.0 code:

//用数据流,外部加载.
//写在帧上:
//确定要缓冲多少秒声音流。默认值为 5 秒
_soundbuftime(5);
// 新建一个声音对象
var music:Sound = new Sound();
//声音对象加载外部mp3文件
music.loadSound(”123.mp3″, true);

as3.0 code:

package {
import flash.display.Sprite;
import flash.events.*;
import flash.media.Sound;
import flash.net.URLRequest;
import flash.system.System;
public class SWFmySound extends Sprite {
private var url:String = “123.mp3″;
private var mySound:Sound = new Sound();
public function SWFmySound() {
//是否使用 系统默认编码
//System.useCodePage=true;
//以后在AS3 中加载一个指定路径的文件,路径必须先由String字符串转成URLRequest
var request:URLRequest = new URLRequest(url);
//添加ID3事件侦听器
mySound.addEventListener(Event.ID3, Id3Handler);
mySound.load(request);
mySound.play();
}
//ID3 事件触发时执行的方法
private function Id3Handler(event:Event):void {
// 在输出面板输出消息
trace(String(”歌曲ID3信息:”+mySound.id3.artist));
}
}
}

检测出当前Flash所在的浏览器类型

2009年8月14日 f-angel 没有评论

flash.system.Capabilities.playerType == “ActiveX”

ActiveX 代表IE浏览器

PlugIn 代表Firefox浏览器

External 代表在浏览器外部