关于unity3d播放flash动画,使用插件uniswf
2014-05-21 13:22
357 查看
主要就是代码了。
1.using UnityEngine;
using System.Collections;
using pumpkin.swf;
using System.Collections.Generic;
using pumpkin.events;
using pumpkin.display;
public class MovieClipX : MovieClip
{
public delegate void FrameCallback();
public Dictionary<int, FrameCallback> FrameEvents = null;
public MovieClipX(SwfURI uri) : base(uri)
{
}
public MovieClipX(string linkage)
: base(linkage)
{
}
public bool addFrameScript(string label, FrameCallback onFrameCallback)
{
if (string.IsNullOrEmpty(label))
return false;
int index = this.getFrameLabel(label);
// Debug.Log("index " + getCurrentFrame());
if (index <= 0)
return false;
if (FrameEvents == null)
{
FrameEvents = new Dictionary<int, FrameCallback>();
}
if (!FrameEvents.ContainsKey(index))
{
FrameEvents.Add(index, onFrameCallback);
}
else
{
FrameEvents.Remove(index);
if (onFrameCallback != null)
{
FrameEvents.Add(index, onFrameCallback);
}
}
return true;
}
public bool addFrameScript(int frame, FrameCallback onFrameCallback)
{
if (FrameEvents == null)
{
FrameEvents = new Dictionary<int, FrameCallback>();
}
if (!FrameEvents.ContainsKey(frame))
{
FrameEvents.Add(frame, onFrameCallback);
}
else
{
FrameEvents.Remove(frame);
if (onFrameCallback != null)
{
FrameEvents.Add(frame, onFrameCallback);
}
}
return true;
}
public bool setEndScript(FrameCallback onFrameCallback)
{
int index = this.getTotalFrames();
if (index <= 0)
return false;
return addFrameScript(index, onFrameCallback);
}
public override void updateFrame(CEvent e)
{
if (FrameEvents != null)
{
int index = this.getCurrentFrame();
if (FrameEvents.ContainsKey(index))
{
FrameCallback b = FrameEvents[index];
if (b != null)
{
b();
}
}
}
base.updateFrame(e);
}
}
2.using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using pumpkin.display;
using pumpkin.text;
using pumpkin.events;
using pumpkin.logging;
using pumpkin.tweener;
public class FlashUI : MovieClipOverlayCameraBehaviour {
public GameObject back;
protected MovieClipX movie = null;
public delegate void OnStop();
void Start () {
stage.stageWidth = (float)Screen.width/1136f;
stage.stageHeight = (float)Screen.height/640f;
}
public void OnPlayToEnd(string path,Vector2 pos,OnStop stop = null)
{
MovieClipX overlay = new MovieClipX(path);
stage.addChild(overlay);
//位置
overlay.x = pos.x*stage.stageWidth;
overlay.y = pos.y*stage.stageHeight;
overlay.scaleX = stage.stageWidth;
overlay.scaleY = stage.stageHeight;
overlay.addFrameScript("end",delegate(){
stage.removeChild(overlay);
if(stop != null)stop();
});
overlay.gotoAndPlay(0);
}
public void OnPlayToFrame(string path,Vector2 pos,int endFrame,OnStop stop = null)
{
MovieClipX overlay = new MovieClipX(path);
stage.addChild(overlay);
//位置
overlay.x = pos.x*stage.stageWidth;
overlay.y = pos.y*stage.stageHeight;
overlay.scaleX = stage.stageWidth;
overlay.scaleY = stage.stageHeight;
overlay.addFrameScript(endFrame,delegate(){
stage.removeChild(overlay);
if(stop != null)stop();
});
overlay.gotoAndPlay(0);
}
public MovieClipX OnPlayNoEnd(string path,Vector2 pos)
{
MovieClipX overlay = new MovieClipX(path);
stage.addChild(overlay);
//位置
overlay.x = pos.x*stage.stageWidth;
overlay.y = pos.y*stage.stageHeight;
overlay.scaleX = stage.stageWidth;
overlay.scaleY = stage.stageHeight;
overlay.gotoAndPlay(0);
return overlay;
}
public void ClearFlash()
{
stage.clearChild();
}
}
1.using UnityEngine;
using System.Collections;
using pumpkin.swf;
using System.Collections.Generic;
using pumpkin.events;
using pumpkin.display;
public class MovieClipX : MovieClip
{
public delegate void FrameCallback();
public Dictionary<int, FrameCallback> FrameEvents = null;
public MovieClipX(SwfURI uri) : base(uri)
{
}
public MovieClipX(string linkage)
: base(linkage)
{
}
public bool addFrameScript(string label, FrameCallback onFrameCallback)
{
if (string.IsNullOrEmpty(label))
return false;
int index = this.getFrameLabel(label);
// Debug.Log("index " + getCurrentFrame());
if (index <= 0)
return false;
if (FrameEvents == null)
{
FrameEvents = new Dictionary<int, FrameCallback>();
}
if (!FrameEvents.ContainsKey(index))
{
FrameEvents.Add(index, onFrameCallback);
}
else
{
FrameEvents.Remove(index);
if (onFrameCallback != null)
{
FrameEvents.Add(index, onFrameCallback);
}
}
return true;
}
public bool addFrameScript(int frame, FrameCallback onFrameCallback)
{
if (FrameEvents == null)
{
FrameEvents = new Dictionary<int, FrameCallback>();
}
if (!FrameEvents.ContainsKey(frame))
{
FrameEvents.Add(frame, onFrameCallback);
}
else
{
FrameEvents.Remove(frame);
if (onFrameCallback != null)
{
FrameEvents.Add(frame, onFrameCallback);
}
}
return true;
}
public bool setEndScript(FrameCallback onFrameCallback)
{
int index = this.getTotalFrames();
if (index <= 0)
return false;
return addFrameScript(index, onFrameCallback);
}
public override void updateFrame(CEvent e)
{
if (FrameEvents != null)
{
int index = this.getCurrentFrame();
if (FrameEvents.ContainsKey(index))
{
FrameCallback b = FrameEvents[index];
if (b != null)
{
b();
}
}
}
base.updateFrame(e);
}
}
2.using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using pumpkin.display;
using pumpkin.text;
using pumpkin.events;
using pumpkin.logging;
using pumpkin.tweener;
public class FlashUI : MovieClipOverlayCameraBehaviour {
public GameObject back;
protected MovieClipX movie = null;
public delegate void OnStop();
void Start () {
stage.stageWidth = (float)Screen.width/1136f;
stage.stageHeight = (float)Screen.height/640f;
}
public void OnPlayToEnd(string path,Vector2 pos,OnStop stop = null)
{
MovieClipX overlay = new MovieClipX(path);
stage.addChild(overlay);
//位置
overlay.x = pos.x*stage.stageWidth;
overlay.y = pos.y*stage.stageHeight;
overlay.scaleX = stage.stageWidth;
overlay.scaleY = stage.stageHeight;
overlay.addFrameScript("end",delegate(){
stage.removeChild(overlay);
if(stop != null)stop();
});
overlay.gotoAndPlay(0);
}
public void OnPlayToFrame(string path,Vector2 pos,int endFrame,OnStop stop = null)
{
MovieClipX overlay = new MovieClipX(path);
stage.addChild(overlay);
//位置
overlay.x = pos.x*stage.stageWidth;
overlay.y = pos.y*stage.stageHeight;
overlay.scaleX = stage.stageWidth;
overlay.scaleY = stage.stageHeight;
overlay.addFrameScript(endFrame,delegate(){
stage.removeChild(overlay);
if(stop != null)stop();
});
overlay.gotoAndPlay(0);
}
public MovieClipX OnPlayNoEnd(string path,Vector2 pos)
{
MovieClipX overlay = new MovieClipX(path);
stage.addChild(overlay);
//位置
overlay.x = pos.x*stage.stageWidth;
overlay.y = pos.y*stage.stageHeight;
overlay.scaleX = stage.stageWidth;
overlay.scaleY = stage.stageHeight;
overlay.gotoAndPlay(0);
return overlay;
}
public void ClearFlash()
{
stage.clearChild();
}
}
相关文章推荐
- 关于unity3d播放flash动画,使用插件uniswf
- Unity3D学习(9)之动画效果与itween插件使用
- urho3d关于urho3d-blender插件,导出动画中帧标记的使用
- 组态王中播放FLASH动画控件的使用
- 关于最新版Chrome浏览器使用swfobject.swf, uploadify等无法正常播放Flash的问题
- 【Unity3D自学记录】关于Animation(动画)倒着播放方法
- unity3d的playmaker插件使用教程,三、对象出入触发,声音播放
- 可进可退,jQuery图片、视频、flash播放插件prettyPhoto使用记录
- unity3d的playmaker插件使用教程,三、对象出入触发,声音播放
- Unity3d的2D骨骼动画插件Puppet2D的使用2
- Unity3d:使用uWebKit插件嵌入网页,网页中的flv视频无法播放
- 关于使用flash上传插件uploadify出现的问题
- 服务器关于flash导入视频不能播放的解决方法!
- 使用Flash循环播放图片的Demo
- 在Flex项目中使用Flash媒体组件播放视频
- 用PowerBuilder实现Flash动画播放
- 使用FLEX和Actionscript开发FLASH 游戏-位图动画
- VC中借助内嵌资源实现Flash动画播放
- 使用PHP快速生成Flash 动画