Skip to content

Instantly share code, notes, and snippets.

@miminashi
Forked from anonymous/gist:720736
Created November 29, 2010 22:26
Show Gist options
  • Save miminashi/720761 to your computer and use it in GitHub Desktop.
Save miminashi/720761 to your computer and use it in GitHub Desktop.
package
{
import flash.display.MovieClip;
import flash.events.Event;
import flash.utils.*;
import flash.events.*;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.net.navigateToURL;
import flash.net.URLRequest;
import tv.ustream.viewer.logic.Logic;
import tv.ustream.viewer.logic.media.Channel;
import tv.ustream.viewer.logic.media.Media;
import flash.external.ExternalInterface;
public class Main extends MovieClip
{
private var viewer:Logic = new Logic();
private var viewer2:Logic = new Logic();
private var viewer3:Logic = new Logic();
public var checker1:Channel = new Channel('6014465',true);
private var displayNum:int;
private var flg1:int = 0;
public var cm1:MovieClip = new mov_cm1();
private var timer1:Timer = new Timer(2000,1);
// public var live1:MovieClip = new mc_live1();
// public var live2:MovieClip = new mc_live2();
// public var live3:MovieClip = new mc_live3();
public function Main():void{
if (stage) onAddedToStage();
else addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
displayNum = 5;
viewer.display.width = 400;
viewer.display.height = 300;
viewer.muted = true;
cm1.width = 400;
cm1.height = 300;
timer1.addEventListener(TimerEvent.TIMER, Checker1);
timer1.start();
bt_display.addEventListener( MouseEvent.CLICK , onClick );
}
public function onClick ( event:MouseEvent ) {
// URLRequestを設定
// var url:URLRequest = new URLRequest( "display1.html" );
// 実際にページに飛ぶ
// navigateToURL(url,'_self');
ExternalInterface.call("function(){ javascript:changeDisplay(" + displayNum.toString() + "); }");
}
private function onAddedToStage(...e):void
{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
//
// display2: 3127344
// display3: 3041721
// live1.x = live2.x = live3.x = 10;
// live1.y = live2.y = live3.y = 10;
// this.display1.addChild(live1);
// this.display2.addChild(live2);
// this.display3.addChild(live3);
}
public function Checker1(e:TimerEvent){
if(checker1.online == true && flg1 == 0){
if(viewer){viewer.destroy();}
viewer.createChannel('6014465',true); // Display1:2953923
display1.addChild(viewer.display);
flg1 = 1;
}else if(checker1.online == true && flg1 == -1){
display1.removeChild(cm1);
if(viewer){viewer.destroy();}
viewer.createChannel('6014465',true); // Display1:2953923
display1.addChild(viewer.display);
flg1 = 1;
}else if(checker1.online == false && flg1 == 0){
display1.addChild(cm1);
flg1 = -1;
}else if(checker1.online == false && flg1 == 1){
if(viewer){viewer.destroy();}
display1.removeChild(viewer.display);
display1.addChild(cm1);
flg1 = -1;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment