publicdirectx functionn Main():void

还没有开通你的开心账户?使用其他账号登录:
在线直接打开本地MP3文件(播放二进制格式的MP3文件)
他的原理是:通过FlashPlayer10的API将文件以二进制形式载入,然后将此MP3文件转成一个swf文件,并根据MP3文件生成SoundClass类,然后播放此声音。  下面是我写的这个测试程序:package {
import flash.display.S
import flash.events.E
import flash.events.MouseE
import flash.media.SoundC
import flash.net.FileF
import flash.net.FileR
import org.audiofx.mp3.MP3FileReferenceL
import org.audiofx.mp3.MP3SoundE
* @author Jaja
public class Main extends Sprite
private var mp3Type:FileFilter = new FileFilter(&mp3文件(*.mp3)&, &*.mp3&);
private var fr:FileR
private var mp3Loader:MP3FileReferenceL
private var channel:SoundC
public function Main():void
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
private function init(e:Event = null):void
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
_btn.addEventListener(MouseEvent.CLICK, browse);
private function browse(event:MouseEvent):void {
fr = new FileR
fr.addEventListener(Event.Select, selectFile);
fr.browse([mp3Type]);
private function selectFile(event:Event):void {
fr.removeEventListener(Event.Select, selectFile);
_txt.text = fr.
mp3Loader = new MP3FileReferenceL
mp3Loader.PLETE, mp3Loaded);
mp3Loader.getSound(fr);
private function mp3Loaded(event:MP3SoundEvent):void {
mp3Loader.PLETE, mp3Loaded);
if (channel != null) {
channel.stop();
channel = event.sound.play();
&&上一帖:
下一帖:&&
(%)点击发表你的观点
07-29 12:0207-29 12:0207-29 12:0307-29 12:1207-29 12:2007-29 12:2607-29 12:2907-29 12:4907-29 12:4907-29 12:49
热门转帖:
最新专题:
&2015 开心网当前位置 &
flash与javascript相互通信(as3.0)
在html中嵌入swf有两种方式,一种是用Flash CS3直接发布,还有一种就是大家都熟悉的swfobject。这里我没什么挑剔的,能解决问题就行。 这个例子是flash调用js函数funcWaitingForFlash,执行funcWaitingForFlash函数时再回调flash的func,仅供参考。 flash as3:
& & import&flash.display.*;
& & import&flash.external.*;
& & public&class Main extends Sprite
& & & & public&function Main():void
& & & & & & // ...
& & & & & & ExternalInterface.addCallback('flashFunc', func);
& & & & & & ExternalInterface.call('funcWaitingForFlash');
& & & & private&function func(str:String):void
& & & & & & // ...
function callFlashFunc(str)
& & var&obj = thisMovie('flashas3js');
& & // thisMovie函数在发布时会自动生成
& & // 如果用swfobject则是
& & // var obj = swfobject.getObjectById(&flashas3js&);
& & if(obj){
& & & & obj.flashFunc(str);
function&funcWaitingForFlash()
& & callFlashFunc('试试看');
视频教程列表
文章教程搜索
输入您的搜索字词
提交搜索表单
Flash AS推荐教程
tel:<font color="#FF30058package{&&&&import&flash.display.B&&&&import&flash.display.BitmapD&&&&import&flash.display.L&&&&import&flash.display.S&&&&import&flash.events.E&&&&import&flash.events.MouseE&&&&import&flash.net.URLL&&&&import&flash.net.URLR&&&&&&&&public&class&Main&extends&Sprite&&&&{&&&&&&&&&&&&&&&&private&var&xiao_tu:B&&&&&&&&//原小图&&&&&&&&private&var&da_tu:B&&&&&&&&//大图&&&&&&&&private&var&loader:L&&&&&&&&//加载图像对象&&&&&&&&private&var&url:URLR&&&&&&&&//图像URL对象&&&&&&&&&&&&&&&&public&function&Main():void&&&&&&&&{&&&&&&&&&&&&init();&&&&&&&&}&&&&&&&&private&function&init():void&&&&&&&&{&&&&&&&&&&&&loader&=&new&Loader();&&&&&&&&&&&&&&&&&&&&&&&&url&=&new&URLRequest("a.jpg");&&&&&&&&&&&&loader.load(url);&&&&&&&&&&&&loader.contentLoaderInfo.PLETE,loadok);&&&&&&&&}&&&&&&&&&&&&&&&&private&function&loadok(evt:Event):void&&&&&&&&{&&&&&&&&&&&&xiao_tu&=&new&Bitmap(evt.target.content.bitmapData);&&//把载入的图片放到的原图对象里&&&&&&&&&&&&&&&&xiao_tu.width&=&400;&&&&&&&&&&&&xiao_tu.height&=&300;&&&&&&&&&&&&this.addChild(xiao_tu);&&&&&&&&&&&&&&&&&&&&&&&&//创建放大镜的镜片&&&&&&&&&&&&var&tu:Sprite&=&new&Sprite();&&&&&&&&&&&&tu.graphics.beginFill(0x000000);&&&&&&&&&&&&tu.graphics.drawCircle(0,0,50);&&&&&&&&&&&&tu.graphics.endFill();&&&&&&&&&&&&tu.startDrag(true);&&&&&&&&&&&&this.addChild(tu);&&&&&&&&&&&&&&&&&&&&&&&&//绘制大图片&&&&&&&&&&&&da_tu&=&new&Bitmap(evt.target.content.bitmapData);&&&&&&&&&&&&da_tu.mask&=&&&&&&&&&&&&&this.addChild(da_tu);&&&&&&&&&&&&&&&&&&&&&&&&stage.addEventListener(MouseEvent.MOUSE_MOVE,onmove);&&&&&&&&}&&&&&&&&&&&&&&&&private&function&onmove(evt:MouseEvent):void&&&&&&&&{&&&&&&&&&&&&da_tu.x&=&(da_tu.width&-&400)&*&(stage.mouseX&/&400)&*&-1;&&&&&&&&&&&&da_tu.y&=&(da_tu.height&-&300)&*&(stage.mouseY&/&300)&*&-1;&&&&&&&&}&&&&}}
阅读(...) 评论()自己写的一个类似MVC框架—视图与数据分离处理
自己写的一个类似MVC框架,为什么是类似呢?因为我对MVC不是很了解,对一个设计模式也不太了解,只是根据的想法写了一个处理视图与数据分离处理的方式。
帖一个主程序代码,详细的下载源码看吧!
package
{
& && &&&import flash.display.S
& && &&&import flash.events.E
& && &&&import flash.text.TextF
& && &&&mands.IV
& && &&&import roy.demo.*;
& && &&&
& && &&&public class Main extends Sprite
& && &&&{
& && && && && & private var view:IV
& && && && && & public function Main():void
& && && && && & {
& && && && && && && && &if (stage) init();
& && && && && && && && &else addEventListener(Event.ADDED_TO_STAGE, init);
& && && && && & }
& && && && && &
& && && && && & private function init(e:Event = null):void
& && && && && & {
& && && && && && && && &removeEventListener(Event.ADDED_TO_STAGE, init);
& && && && && && && && &// entry point
& && && && && && && && &
& && && && && && && && &//属性示例
& && && && && && && && &var tf:TextField = new TextField();
& && && && && && && && &var Attribute:* = tf.
& && && && && && && && &tf.text = &100&;
& && && && && && && && &this.addChild(tf);& && && && && && && && &
& && && && && && && && &view = new BaseView(HandlerType.TEST, null, tf, &text&);
& && && && && && && && &
& && && && && && && && &//方法示例
& && && && && && && && &var view0:IView = new BaseView(HandlerType.TEST, test);
& && && && && && && && &
& && && && && && && && &//属性与方法示例使用共同的Model
& && && && && && && && &new TestModel(HandlerType.TEST);
& && && && && && && && &
& && && && && && && && &//任意View对象触发更新数据
& && && && && && && && &view0.sendData('test.xml');
& && && && && && && && &//view.sendData('test.xml');
& && && && && && && && &
& && && && && & }
& && && && && & private function test(data:Object):void
& && && && && & {
& && && && && && && && &trace(data);
& && && && && && && && &//view.removeSelfForType(&test&);
& && && && && && && && &view.removeSelf(true);
& && && && && & }
& && &&&}
& && &&&
}复制代码
源码下载:
(17.83 KB, 下载次数: 3)
12:08 上传
点击文件名下载附件
该贴已经同步到
北京浩庭广告传媒有限责任公司薪金:12-25万职位:WEB前端
上海钱智金融信息服务有限公司薪金:21w-28w职位:UI经理
广州市久邦数码科技有限公司薪金:面议职位:UI设计师}

我要回帖

更多关于 directx function 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信