AS2和AS3的一个主要一个区别是可以写公用的类来调用,减轻代码量,同时规范了语法,不允许在影片剪辑中去写代码,只能允许在时间帧中写代码,同时发现如果用到gotoAndStop(场景,帧数),
1.这个方法后是在一个影片剪辑中时间帧去写这个代码跳到另外一个场景中是无法掉用的。
2.同事发现时用下面的duplicateDisplayObject,将影片剪辑转换成构造器,去复制一个影片剪辑中的影片剪辑是无法复制的,我想原因应该在与,这个是有父子关系的,不能只要子不要父。
3.关于反射的一个问题,反射是使用getDefinitionByName(name:String)来获得class
但是去不能动态去活动方法名,去调用方法。
1.常用在页面中弹出对话框
import flash.external.ExternalInterface;
ExternalInterface.call("alert","对话框内容");
2.常用动画
import caurina.transitions.Tweener;
Tweener.addTween(info, {x:10,alpha:1, time:1, transition:"easeOutQuart"});
Tweener.addTween(PicMc, {alpha:0, time:1, transition:"easeInQuart",onComplete:function(){}});
查看下面文档
http://hosted.zeh.com.br/tweener/docs/en-us/
关于该动画使用的详细情况。
3.更改影片剪辑颜色
public var transOver:
ColorTransform=
new ColorTransform;
transOver.
color=0xffffff;
mc.
transform.colorTransform=
transOver;
5.调用outbook
import flash.external.ExternalInterface;
mc.buttonMode=true;
mc.addEventListener(MouseEvent.CLICK,function(e:MouseEvent)
{ExternalInterface.call("window.location.href","mailto:
[email protected]"); });
6.声音使用
function playSound(st:String)
{
var s:Sound = new Sound();
s.addEventListener(Event.COMPLETE, function(e:Event)
{s.play();});
var req:URLRequest = new URLRequest(st);
s.load(req);
}
7.旋转影片剪辑
function transFormMC(obj:MovieClip)
{
var matrix:Matrix =new Matrix();
matrix.a=-1;
matrix.tx=obj.width;
matrix.concat(obj.transform.matrix);
obj.transform.matrix=matrix;
}
8.加载XML
import mycommon.*;
var loadXML:LoadXML;
function initLoadXML()
{
loadXML=new LoadXML("data.xml");
loadXML.addEventListener(CommonEvent.LOAD_XML_COMPLETE,loadXMLComplete);
}
function loadXMLComplete(e:Event)
{
for each(var xml:XML in loadXML.myXML.product)
{
trace(xml.@name);
}
}
9.获取全局变量
var mc:MovieClip=e.currentTarget as MovieClip;
var point:Point=new Point(mc.x,mc.y)
var mcX:Number=mc.localToGlobal(point).x;
10.常用方法
MovieClip(root).main
11.常用影片剪辑
for(var i:Number=0;i<6;i++)
{
var mc:MovieClip=this.getChildByName("btn"+i) as MovieClip;
mc.buttonMode=true;
mc.addEventListener(MouseEvent.CLICK,function(e:MouseEvent)
{
})
}
SoundMixer.stopAll();
11.在AS3中使用定时器,用Timer对象,方法如下:
import flash.utils.Timer;
import flash.events.TimerEvent;
var mytimer:Timer = new Timer(1000);
mytimer.addEventListener(TimerEvent.TIMER, run);
mytimer.start();
function run(event:TimerEvent):void {
}
加载SWF文件
var mainSWF:MovieClip=new MovieClip();
var mLoaderMain:Loader;
function loadSWF(url:String)
{
mLoaderMain= new Loader();
var mRequest:URLRequest = new URLRequest(url);
mLoaderMain.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteMainHandler);
mLoaderMain.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
mLoaderMain.load(mRequest);
}
function loadProgress(event:ProgressEvent):void
{
var percentLoaded:Number = event.bytesLoaded/event.bytesTotal;
percentLoaded = Math.round(percentLoaded * 100);
myload.loadTxt.text=percentLoaded;
}
function onCompleteMainHandler(loadEvent:Event)
{
myload.visible=false;
mainSWF.addChild(mLoaderMain.content);
mLoaderMain1.contentLoaderInfo.removeEventListener(Event.COMPLETE, onCompleteMain1Handler);
}
我的网站设计 web design home page
http://www.webdesign-cn.com
http://www.webdesign-china.cn