clear DNS cache
for win
in command line:
ipconfig /flushdns
for mac
in terminal
dscacheutil -flushcache
as3 embed youtube player fullscreen problem
stage.addEventListener(FullScreenEvent.FULL_SCREEN, fullScreenHandler);
function fullScreenHandler(e:FullScreenEvent) {
if(!e.fullScreen){ //you just returned back to normal
topMC.addChild(player);
player.setSize(640, 360)
}else{ //you just entered full screen mode
xxx.addChild(player);
player.setSize(stage.stageWidth, stage.stageHeight)
}
};
mc change depth to top
this.setChildIndex(mc, this.numChildren-1)
as3 sound fade in fade out
// Initialize sound variables
var so:Sound = new Sound();
var sc:SoundChannel;
var fadeInIncr = 0.1;
var sAmbienceVol:SoundTransform = new SoundTransform(fadeInIncr, 0); // 1=vol, 0=pan
var soundFadeOutTimer:Timer = new Timer(100,10);
var soundFadeInTimer:Timer = new Timer(100,10);
soundFadeOutTimer.addEventListener("timer", soundFadeOut);
soundFadeInTimer.addEventListener("timer", soundFadeIn);
soundFadeOutTimer.addEventListener(TimerEvent.TIMER_COMPLETE, soundOutComplete);
soundFadeInTimer.addEventListener(TimerEvent.TIMER_COMPLETE, soundInComplete);
loadMusic()
var soundFadeInSwitch:Boolean =false;
var soundFadeOutSwitch:Boolean =true;
function loadMusic():void{
so = new Sound(new URLRequest("xxx.mp3"));
so.addEventListener(Event.COMPLETE, soundLoadComplete);
so.addEventListener(ProgressEvent.PROGRESS, soundprogressHandler);
}
function soundprogressHandler(event:ProgressEvent):void {
var loadTime:Number = event.bytesLoaded / event.bytesTotal;
var loadPercent:uint = Math.round(100 * loadTime);
sound_mc.loaded_txt.text =loadPercent + "%";
}
function soundLoadComplete(event:Event):void {
sound_mc.loaded_txt.text ="";
startMusic();
sc = so.play(0, 1, sAmbienceVol);
}
function stopMusic():void{
soundFadeOutSwitch=false;
soundFadeOutTimer.reset();
soundFadeOutTimer.start()
}
function startMusic():void{
soundFadeInSwitch=false;
soundFadeInTimer.reset();
soundFadeInTimer.start()
}
function soundFadeOut(e:TimerEvent){
trace(fadeInIncr);
if(fadeInIncr>0){
fadeInIncr -= 1/10;
}else{
fadeInIncr=0;
soundFadeOutTimer.stop();
}
sAmbienceVol = new SoundTransform(fadeInIncr, 0);
sc.soundTransform = sAmbienceVol;
}
function soundFadeIn(e:TimerEvent){
trace(fadeInIncr);
if(fadeInIncr<=1){
fadeInIncr += 1/10;
}else{
fadeInIncr=1;
soundFadeInTimer.stop();
}
sAmbienceVol = new SoundTransform(fadeInIncr, 0);
sc.soundTransform = sAmbienceVol;
}
function soundInComplete(e:TimerEvent):void {
sAmbienceVol = new SoundTransform(1, 0);
sc.soundTransform = sAmbienceVol;
soundFadeInSwitch=true;
}
function soundOutComplete(e:TimerEvent):void {
sAmbienceVol = new SoundTransform(0, 0);
sc.soundTransform = sAmbienceVol;
soundFadeOutSwitch=true;
}
Firefox/Chrome Flash TextField can't type chinese
html wmode -> Window ->done!
as3 sound length and position
var so:Sound = new Sound();
var sc:SoundChannel;
so = new Sound(new URLRequest("xxx.mp3"));
so.addEventListener(Event.COMPLETE, soundLoadComplete);
sc = so.play();
function soundLoadComplete(event:Event):void {
}
sc.position //song right now position
so.length //song total length
