当前位置:七道奇文章资讯设计学堂Flash设计
日期:2009-04-03 23:58:00  来源:本站整理

<b>AS打造的复制粘贴等功效类</b>[Flash设计]

赞助商链接



  本文“<b>AS打造的复制粘贴等功效类</b>[Flash设计]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:

效果如图:

源码下载:flash_copy.rar

演示

主要代码:

//定义大众函数...
class ClipBoard extends Object {
static var contents:Object;
static var operation:String;
function ClipBoard() {
}
//定义当挑选剪切时的效果...
public static function cut(obj) {
obj._alpha = 50;
contents = obj;
operation = "cut";
}
//定义复制函数...
public static function copy(obj) {
contents = obj;
operation = "copy";
}
//定义删除函数...
public static function remove(obj) {
contents = obj;
operation = "remove";
contents.removeMovieClip();
}
//定义顺时针旋转...
public static function rotation(obj) {
contents = obj;
operation = "rotation";
contents._rotation += 45;
}
//定义逆时针旋转...
public static function rotation2(obj) {
contents = obj;
operation = "rotation2";
contents._rotation -= 45;
}
//定义移动...
private static var xm:Number;
private static var ym:Number;
public static function movethis(obj) {
contents = obj;
operation = "movethis";
_root.onMouseDown = function() {
xm = _xmouse;
ym = _ymouse;
movethisit();
};
function movethisit() {
_root.onEnterFrame = function() {
contents._x += (xm-contents._x)/5;
contents._y += (ym-contents._y)/5;
if (Math.abs(contents._x-xm)<0.5) {
_root.onEnterFrame = undefined;
}
};
}
}
//定义革新...
public static function refish() {
getURL("javascript:location.reload()");
}
//定义粘贴功效...
public static function paste() {
if (operation == "cut") {
contents._x = _root._xmouse;
contents._y = _root._ymouse;
contents._alpha = 100;
contents = undefined;
operation = "";
} else if (operation == "copy") {
var newdepth = contents._parent.getNextHighestDepth();
var newname = contents._name+newdepth;
contents.duplicateMovieClip(newname, newdepth);
contents._parent[newname]._x = _root._xmouse;
contents._parent[newname]._y = _root._ymouse;
contents._alpha = 100;
contents._parent[newname]._alpha = 100;
} else if (operation == "remove") {
var newdepth = contents._parent.getNextHighestDepth();
var newname = contents._name+newdepth;
contents.removeMovieClip("");
} else {
return;
}
}
public function isEmpty():Boolean {
if (contents != undefined) {
return false;
} else {
return true;
}
}
public function handleMenuCommand(obj, item):Void {
switch (item.caption) {
case "剪切__X" :
cut(obj);
break;
case "复制__C" :
copy(obj);
break;
case "粘贴__P" :
paste();
break;
case "删除__D" :
remove(obj);
break;
case "革新_F5" :
refish();
break;
case "往右旋转" :
rotation(obj);
break;
case "往左旋转" :
rotation2(obj);
break;
case "移动此球" :
movethis(obj);
break;
}
}
}

定义右键菜单:

_global.clipboard = new ClipBoard();
function menuCallback(obj, menuObj) {
var empty:Boolean = _global.clipboard.isEmpty();
menuObj.customItems = [];
// 假如对象为影片剪辑,而不是 _root
if ((obj instanceof MovieClip) && (obj != _level0)) {
menuObj.customItems.push(cutItem);
menuObj.customItems.push(copyItem);
menuObj.customItems.push(remove);
menuObj.customItems.push(refish);
menuObj.customItems.push(rotation);
menuObj.customItems.push(rotation2);
menuObj.customItems.push(movethis);
if (!empty) {
menuObj.customItems.push(pasteItem);
menuObj.customItems.push(refish);
}
} else if (obj == _level0 && !empty) {
menuObj.customItems.push(pasteItem);
menuObj.customItems.push(refish);
}
}
var myMenu = new ContextMenu(menuCallback);
myMenu.hideBuiltInItems();
var cutItem = new ContextMenuItem("剪切__X", _global.clipboard.handleMenuCommand);
var copyItem = new ContextMenuItem("复制__C", _global.clipboard.handleMenuCommand);
var pasteItem = new ContextMenuItem("粘贴__P", _global.clipboard.handleMenuCommand);
var remove = new ContextMenuItem("删除__D", _global.clipboard.handleMenuCommand);
var refish = new ContextMenuItem("革新_F5", _global.clipboard.handleMenuCommand);
var rotation = new ContextMenuItem("往右旋转", _global.clipboard.handleMenuCommand);
var rotation2 = new ContextMenuItem("往左旋转", _global.clipboard.handleMenuCommand);
var movethis = new ContextMenuItem("移动此球", _global.clipboard.handleMenuCommand);
MovieClip.prototype.menu = myMenu;
this.menu = myMenu;
stop();

利用办法很简单,直接将制作好的MC拖入场景,然后在MC中加入以下代码:

on (release) {
stopDrag();
//完毕行为
}
on (press) {
startDrag(this);
//完毕行为
mx.behaviors.DepthControl.bringToFront(this);
//完毕行为
}

注意下载的“ClipBoard.as”类文件,要放在SWF同级目录下...


  以上是“<b>AS打造的复制粘贴等功效类</b>[Flash设计]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
  • <b>hosts是什么 hosts文件在什么位置 若何改正hosts</b>
  • <b>在 Windows 8 中手动安装语言包</b>
  • <b>五个常见 PHP数据库问题</b>
  • Windows中Alt键的12个高效快速的利用本领介绍
  • <b>MySQL ORDER BY 的实现解析</b>
  • <b>详解MySQL存储历程参数有三种范例(in、out、inout)</b>
  • <b>Win8系统恢复出来经典的开始菜单的办法</b>
  • <b>Win8系统花屏怎么办 Win8系统花屏的办理办法</b>
  • <b>Windows 7系统下无线网卡安装</b>
  • <b>为什么 Linux不需求碎片整理</b>
  • <b>Windows 8中删除账户的几种办法(图)</b>
  • <b>教你如安在win7下配置路由器</b>
  • 本文地址: 与您的QQ/BBS好友分享!
    • 好的评价 如果您觉得此文章好,就请您
        0%(0)
    • 差的评价 如果您觉得此文章差,就请您
        0%(0)

    文章评论评论内容只代表网友观点,与本站立场无关!

       评论摘要(共 0 条,得分 0 分,平均 0 分) 查看完整评论
    Copyright © 2020-2022 www.xiamiku.com. All Rights Reserved .