MovieClip içindeki tüm nesnelere erişmek
Pazartesi, 28 Haziran 2010mc adlı movieclip olsun. mc içindekileri silmek istiyorsunuz:
var i:uint = mc.numChildren;
while(i- -)
{
mc.removeChild(mc.getChildAt(i));
}
mc adlı movieclip olsun. mc içindekileri silmek istiyorsunuz:
var i:uint = mc.numChildren;
while(i- -)
{
mc.removeChild(mc.getChildAt(i));
}
import flash.net.NetConnection;
import flash.events.NetStatusEvent;
import flash.media.Microphone;
import flash.net.NetStream;
var nc:NetConnection=new NetConnection();
var mic:Microphone=Microphone.getMicrophone();
nc.addEventListener(NetStatusEvent.NET_STATUS,fStatus);
function fStatus(evt:NetStatusEvent)
{
if(evt.info.code==”NetConnection.Connect.Success”)
{
var ns:NetStream=new NetStream(nc);
ns.attachAudio(mic);
ns.publish(”FlashDersi”,”record”);
}
}
nc.connect(”rtmp://fms_hosting.com/applicationName”);
alttaki kodlar ile kullanıcının bilgisayarına dosya kayıt yaptırabiliyoruz.
Özellikle String, ByteArray veya XML tarzı objelerde işe yarıyor.
var file:FileReference = new FileReference();
stage.addEventListener(MouseEvent.CLICK, fKaydet, false, 0, true);
function fKaydet(evt:MouseEvent):void {
file.save(”FlashDersi.com.\nAS3 örnekleri”, “FD_com.txt”);
}
sahnenizde mc1 adlı Movieclip olsun:
addEventListener(Event.ENTER_FRAME, f1);
mc1.z=10;
function f1(e:Event):void {
mc1.transform.matrix3D.prependRotation(2, Vector3D.Y_AXIS);
}
this[”tw”+Math.random()]=new Tween(sahnedekiMC,”scaleX”,Strong.easeOut,0,1,3,true);
Önceden tanımlamaya gerek duymuyor. Bu tek satır ile TWEEN çalışıyor ve aynı anda birçok TWEEN in kullanılmasında donma sorunu oluşmuyor.
Sahnenizde 6 tane button olsun. Sahne adları sırayla : btn1_btn ,btn2_btn , btn3_btn vs… olsun.
Frame’e şu kodları ekleyelim:
for(var no:uint=1;no<4;no++)
{
dispecle(this[”btn”+no+”_btn”],MouseEvent.CLICK,f1);
}
for(var no2:uint=4;no2<7;no2++)
{
dispecle(this[”btn”+no2+”_btn”],MouseEvent.ROLL_OVER,f2);
}
function dispecle(pecleyen:IEventDispatcher,olay:String,fonksiyon:Function)
{
pecleyen.addEventListener(olay,fonksiyon);
}
function f1(evt:MouseEvent)
{
trace(evt.currentTarget.name);
}
function f2(evt:MouseEvent)
{
trace(evt.currentTarget.name);
}