home *** CD-ROM | disk | FTP | other *** search
- package com.generationk.zinc
- {
- import controller.VersionController;
- import flash.display.Loader;
- import flash.display.Sprite;
- import flash.display.StageAlign;
- import flash.display.StageScaleMode;
- import flash.events.Event;
- import flash.events.MouseEvent;
- import flash.events.NetStatusEvent;
- import flash.events.TimerEvent;
- import flash.media.SoundTransform;
- import flash.media.Video;
- import flash.net.NetConnection;
- import flash.net.NetStream;
- import flash.net.URLLoader;
- import flash.net.URLRequest;
- import flash.text.AntiAliasType;
- import flash.text.TextField;
- import flash.text.TextFieldAutoSize;
- import flash.text.TextFieldType;
- import flash.text.TextFormat;
- import flash.utils.Timer;
- import mdm.*;
-
- public class ChromeLINUX extends Sprite
- {
- private static var MINI:String = "mini";
-
- private static var STANDARD:String = "standard";
-
- private static var FULLSCREEN:String = "fullscreen";
-
- private var videobg:BackGroundAsset;
-
- private var closeWindow:Window;
-
- private var xmlLoader:URLLoader;
-
- private var closewindowlabel:String;
-
- private var iscontent:Boolean = false;
-
- private var vwidth:Number;
-
- private var oldX:Number;
-
- private var oldY:Number;
-
- private var closewindowtext:String;
-
- private var videosp:Sprite;
-
- private var volume:Number;
-
- private var vheight:Number;
-
- private var maximized:Boolean = false;
-
- private var isoutro:Boolean = false;
-
- private var buttomBar:Sprite;
-
- private var border:Sprite;
-
- private var oldHeight:Number;
-
- private var Application:InternalApplication;
-
- private var bg:BackGroundAsset;
-
- private var loadingscreenversion:String;
-
- private var System:InternalSystem;
-
- private var loadingscreenlabel:String;
-
- private var sp:Sprite;
-
- private var xmlData:XML;
-
- private var miniHeight:Number;
-
- private var introOver:Boolean = false;
-
- private var content:Sprite;
-
- private var video:Video;
-
- private var topBar:Sprite;
-
- private var completeTimer:Timer;
-
- private var duration:Number;
-
- private var progresser:Sprite;
-
- public var lin:Boolean = true;
-
- private var mode:String = "standard";
-
- private var progressBar:Sprite;
-
- private var logo:LogoAsset;
-
- private var holder:Sprite;
-
- private var _metaData:Object;
-
- private var miniWidth:Number;
-
- private var nc:NetConnection;
-
- private var ns:NetStream;
-
- private var closewindowcancellabel:String;
-
- private var progressInit:Boolean = false;
-
- private var oldWidth:Number;
-
- private var miniX:Number;
-
- private var closewindowcloselabel:String;
-
- private var miniY:Number;
-
- private var isMoveTimer:Boolean;
-
- private var Froms:InternalForms;
-
- private var resizeTimer:Timer;
-
- private var moveTimer:Timer;
-
- private var label:TextField;
-
- private var versionLabel:TextField;
-
- private var resizeLayer:Sprite;
-
- public function ChromeLINUX()
- {
- super();
- Application = new InternalApplication();
- System = new InternalSystem();
- Forms = InternalForms.getInstance(stage);
- Application.init(this,initZinc);
- addEventListener(Event.ADDED_TO_STAGE,init1);
- VersionController.getInstance("linux");
- }
-
- private function initApp() : void
- {
- completeTimer = new Timer(10);
- completeTimer.addEventListener(TimerEvent.TIMER,onCompleteCheck);
- stage.align = StageAlign.TOP_LEFT;
- stage.scaleMode = StageScaleMode.NO_SCALE;
- checkMaxScreen();
- holder = new Sprite();
- addChild(holder);
- sp = new Sprite();
- sp.y = 20;
- bg = new BackGroundAsset();
- sp.addChild(bg);
- videosp = new Sprite();
- holder.addChild(sp);
- holder.addChild(videosp);
- videobg = new BackGroundAsset();
- videobg.x = 0;
- videobg.y = 20;
- videobg.height = stage.stageHeight - 30;
- videobg.width = stage.stageWidth;
- addChild(videobg);
- video = new Video();
- video.smoothing = true;
- video.y = 20;
- addChild(video);
- createProgressBar();
- createProgressBarLabels();
- Application.addEventListener(Event.RESIZE,resize);
- loadContent();
- }
-
- private function createProgressBar() : void
- {
- logo = new LogoAsset();
- logo.width = stage.stageWidth - 300;
- logo.scaleY = logo.scaleX;
- logo.x = Math.round((stage.stageWidth - logo.width) / 2 + 60);
- logo.y = Math.round((stage.stageHeight - logo.height) / 2 + 20);
- addChild(logo);
- progressBar = new Sprite();
- border = new Sprite();
- border.graphics.beginFill(16777215,0);
- border.graphics.lineStyle(1,15329769,1,true);
- border.graphics.drawRoundRect(0,0,330,14,10,10);
- border.graphics.endFill();
- progresser = new Sprite();
- progresser.graphics.beginFill(3516897,1);
- progresser.graphics.drawRoundRect(0,0,1,14,10,10);
- progresser.graphics.endFill();
- progresser.y = 0;
- progresser.x = 0;
- progressBar.addChild(progresser);
- progressBar.addChild(border);
- addChild(progressBar);
- progressBar.x = Math.round((stage.stageWidth - progressBar.width) / 2);
- progressBar.y = Math.round((stage.stageHeight - progressBar.height) / 2);
- }
-
- private function onMetaDataHandler(param1:Object) : void
- {
- duration = param1.duration;
- vwidth = param1.width;
- vheight = param1.height;
- }
-
- private function loadIntro() : void
- {
- nc = new NetConnection();
- nc.connect(null);
- nc.addEventListener(NetStatusEvent.NET_STATUS,netStatusHandler);
- _metaData = new Object();
- _metaData.onMetaData = onMetaDataHandler;
- ns = new NetStream(nc);
- ns.client = _metaData;
- ns.addEventListener(NetStatusEvent.NET_STATUS,netStatusHandler);
- video.attachNetStream(ns);
- ns.play(Application.path + "media/intro.mp4");
- var _loc1_:SoundTransform = new SoundTransform(volume);
- ns.soundTransform = _loc1_;
- video.width = Forms.getFormByName("MainForm").width;
- video.height = Forms.getFormByName("MainForm").width / 1280 * 720;
- video.y = (Forms.getFormByName("MainForm").height - video.height) / 2;
- video.x = 0;
- videobg.addEventListener(MouseEvent.MOUSE_DOWN,skipIntro);
- videobg.buttonMode = true;
- }
-
- private function onHideIntro(param1:Event) : void
- {
- trace("CHROME HIDE INTRO");
- content.removeEventListener("loading",onLoading);
- removeChild(progressBar);
- removeChild(label);
- removeChild(versionLabel);
- removeChild(logo);
- loadIntro();
- iscontent = true;
- }
-
- private function skipIntro(param1:MouseEvent) : void
- {
- trace("skipIntro");
- completeTimer.stop();
- ns.pause();
- nc.close();
- introOver = true;
- videobg.removeEventListener(MouseEvent.MOUSE_DOWN,skipIntro);
- removeChild(videobg);
- removeChild(video);
- content["onCompleteIntro"]();
- }
-
- private function activateFullScreen(param1:Event) : void
- {
- Forms.getFormByName("MainForm").showFullScreen(true);
- }
-
- private function LoadXML(param1:Event) : void
- {
- xmlData = new XML(param1.target.data);
- closewindowlabel = xmlData.projectordata.closewindow.label;
- closewindowtext = xmlData.projectordata.closewindow.text;
- closewindowcancellabel = xmlData.projectordata.closewindow.cancelbuttonlabel;
- closewindowcloselabel = xmlData.projectordata.closewindow.closebuttonlabel;
- loadingscreenlabel = xmlData.projectordata.loadingscreen.label;
- loadingscreenversion = xmlData.projectordata.loadingscreen.version;
- initApp();
- }
-
- private function init1(param1:Event) : void
- {
- parseXML();
- }
-
- private function onCancel(param1:Event) : void
- {
- if(iscontent && introOver)
- {
- content["onPlay"]();
- }
- }
-
- private function onCloseApp(param1:Event) : void
- {
- if(iscontent)
- {
- videobg.visible = false;
- video.visible = false;
- ns.pause();
- content["onoutro"]();
- }
- else
- {
- Application.exit();
- }
- }
-
- private function onOut(param1:MouseEvent) : void
- {
- param1.target.gotoAndStop(1);
- }
-
- private function onProgress(param1:Number, param2:Number) : void
- {
- var _loc3_:Number = 0;
- if(progressInit)
- {
- _loc3_ = 330 / param1 * param2 + 5;
- if(_loc3_ > 330)
- {
- _loc3_ = 330;
- }
- }
- if(param1 == param2 * 2 && !progressInit)
- {
- progressInit = true;
- }
- progresser.graphics.clear();
- progresser.graphics.beginFill(2992866,1);
- progresser.graphics.drawRoundRect(0,0,_loc3_,14,10,10);
- progresser.graphics.endFill();
- }
-
- private function initZinc() : void
- {
- Application.enableExitHandler();
- Application.onAppExit = this.onExit;
- }
-
- private function onOver(param1:MouseEvent) : void
- {
- param1.target.gotoAndStop(2);
- }
-
- private function netStatusHandler(param1:NetStatusEvent) : void
- {
- switch(param1.info.code)
- {
- case "NetStream.Play.Start":
- trace("start");
- completeTimer.start();
- break;
- case "NetStream.Buffer.Flush":
- }
- }
-
- private function parseXML() : void
- {
- xmlLoader = new URLLoader();
- xmlData = new XML();
- xmlLoader.addEventListener(Event.COMPLETE,LoadXML);
- xmlLoader.load(new URLRequest(Application.path + "system/data/projector.xml"));
- }
-
- private function onLoading(param1:Event) : void
- {
- onProgress(param1.target.total,param1.target.loaded);
- }
-
- private function toogleSize(param1:MouseEvent = null) : void
- {
- trace("toogleSize");
- isMoveTimer = false;
- if(maximized)
- {
- hideFullScreen();
- if(mode == STANDARD && !maximized)
- {
- Forms.getFormByName("MainForm").x = oldX;
- Forms.getFormByName("MainForm").y = oldY;
- }
- else if(mode == MINI && !maximized)
- {
- Forms.getFormByName("MainForm").x = miniX;
- Forms.getFormByName("MainForm").y = miniY;
- }
- }
- else
- {
- Application.bringToFront(true);
- Application.bringToFront(false);
- Application.sendToBack();
- showFullScreen();
- }
- }
-
- private function onChange(param1:Event) : void
- {
- if(param1.target.modi == 0 && mode != FULLSCREEN)
- {
- stopBringToFront();
- mode = FULLSCREEN;
- toogleSize();
- }
- else if(param1.target.modi == 1 && mode != STANDARD)
- {
- stopBringToFront();
- mode = STANDARD;
- Forms.getFormByName("MainForm").showFullScreen(false);
- Forms.getFormByName("MainForm").x = oldX;
- Forms.getFormByName("MainForm").y = oldY;
- Forms.getFormByName("MainForm").setModiSize(oldWidth,oldHeight);
- }
- else if(param1.target.modi == 2 && mode != MINI)
- {
- mode = MINI;
- Forms.getFormByName("MainForm").showFullScreen(false);
- startBringToFront();
- Forms.getFormByName("MainForm").setModiSize(miniWidth,miniHeight);
- Forms.getFormByName("MainForm").x = miniX;
- Forms.getFormByName("MainForm").y = miniY;
- }
- }
-
- private function setButtonPosition(param1:String) : void
- {
- }
-
- private function deactivateFullScreen(param1:Event) : void
- {
- Forms.getFormByName("MainForm").showFullScreen(false);
- }
-
- private function onFinalExit(param1:MouseEvent) : void
- {
- Application.exit();
- }
-
- private function onExit() : void
- {
- closeWindow.show();
- if(iscontent)
- {
- content["onPause"]();
- content["onexit"]();
- }
- }
-
- private function stopBringToFront() : void
- {
- Application.bringToFront(false);
- Application.sendToBack();
- }
-
- private function createProgressBarLabels() : void
- {
- var _loc1_:TextFormat = new TextFormat();
- _loc1_.color = 16777215;
- _loc1_.font = new REGULAR().fontName;
- _loc1_.size = 18;
- var _loc2_:TextFormat = new TextFormat();
- _loc2_.color = 16777215;
- _loc2_.font = new REGULAR().fontName;
- _loc2_.size = 14;
- label = new TextField();
- label.antiAliasType = AntiAliasType.ADVANCED;
- label.embedFonts = true;
- label.type = TextFieldType.DYNAMIC;
- label.selectable = false;
- label.multiline = true;
- label.wordWrap = true;
- label.autoSize = TextFieldAutoSize.LEFT;
- label.width = 330;
- label.defaultTextFormat = _loc1_;
- label.setTextFormat(_loc1_);
- label.htmlText = loadingscreenlabel;
- addChild(label);
- versionLabel = new TextField();
- versionLabel.antiAliasType = AntiAliasType.ADVANCED;
- versionLabel.embedFonts = true;
- versionLabel.type = TextFieldType.DYNAMIC;
- versionLabel.selectable = false;
- versionLabel.multiline = true;
- versionLabel.wordWrap = true;
- versionLabel.autoSize = TextFieldAutoSize.LEFT;
- versionLabel.defaultTextFormat = _loc2_;
- versionLabel.setTextFormat(_loc2_);
- versionLabel.htmlText = loadingscreenversion;
- addChild(versionLabel);
- label.x = Math.round(progressBar.x);
- label.y = Math.round(progressBar.y - label.height - 8);
- versionLabel.x = Math.round(progressBar.x + progressBar.width - versionLabel.width + 14);
- versionLabel.y = Math.round(progressBar.y + progressBar.height + 8);
- }
-
- private function onCompleteCheck(param1:TimerEvent) : void
- {
- if(Math.round(duration) == Math.round(ns.time) && Math.round(duration) > 0)
- {
- introOver = true;
- completeTimer.stop();
- removeChild(videobg);
- removeChild(video);
- content["onCompleteIntro"]();
- }
- }
-
- private function loadContent() : void
- {
- var _loc1_:Loader = new Loader();
- var _loc2_:URLRequest = new URLRequest(Application.path + "system/player.swf");
- _loc1_.contentLoaderInfo.addEventListener(Event.COMPLETE,loadedContent);
- _loc1_.load(_loc2_);
- }
-
- private function loadedContent(param1:Event) : void
- {
- content = param1.target.content as Sprite;
- content.addEventListener("modichange",onChange);
- content.addEventListener("hideintro",onHideIntro);
- content.addEventListener("loading",onLoading);
- content.addEventListener("openfullscreen",activateFullScreen);
- content.addEventListener("closefullscreen",deactivateFullScreen);
- content.addEventListener("onvolume",onVolume);
- content.addEventListener("packshotcomplete",onPackshotComplete);
- content.addEventListener("hidepackshot",onPackshotComplete);
- content.y = -20;
- sp.addChild(content);
- }
-
- private function showFullScreen(param1:Event = null) : void
- {
- if(mode == FULLSCREEN)
- {
- trace("Fullscreen");
- Forms.getFormByName("MainForm").showFullScreen(true);
- }
- else
- {
- Forms.getFormByName("MainForm").showFullScreen(false);
- }
- }
-
- private function resize(param1:Event = null) : void
- {
- trace("resize ");
- if(!maximized)
- {
- trace("!isMaximized " + mode + " > " + stage.stageWidth + " x " + stage.stageHeight);
- if(mode == STANDARD)
- {
- if(stage.stageWidth < 1024 || stage.stageHeight < 685)
- {
- Forms.getFormByName("MainForm").setSize(1024,685);
- }
- else if(stage.stageWidth > 1024 || stage.stageHeight > 685)
- {
- if(stage.stageWidth / 1024 < stage.stageHeight / 685)
- {
- Forms.getFormByName("MainForm").setSize((stage.stageHeight - 109) * (1024 / 576),stage.stageHeight - 109);
- }
- else
- {
- Forms.getFormByName("MainForm").setSize(stage.stageWidth,stage.stageWidth * (576 / 1024) + 109);
- }
- }
- }
- if(mode == MINI)
- {
- if(stage.stageWidth < 575 && stage.stageHeight < 387)
- {
- Forms.getFormByName("MainForm").setSize(575,323 + 64);
- }
- else if(stage.stageWidth < 1280)
- {
- if(stage.stageWidth / 575 < stage.stageHeight / 387)
- {
- Forms.getFormByName("MainForm").setSize(stage.stageWidth,stage.stageWidth * (323 / 575) + 64);
- }
- else
- {
- Forms.getFormByName("MainForm").setSize((stage.stageHeight - 64) * (575 / 323),stage.stageHeight);
- }
- }
- else
- {
- Forms.getFormByName("MainForm").setSize(1280,1280 * (323 / 575) + 64);
- }
- }
- }
- if(mode == STANDARD && !maximized)
- {
- oldX = Forms.getFormByName("MainForm").x;
- oldY = Forms.getFormByName("MainForm").y;
- oldWidth = Forms.getFormByName("MainForm").width;
- oldHeight = Forms.getFormByName("MainForm").height;
- }
- else if(mode == MINI && !maximized)
- {
- miniX = Forms.getFormByName("MainForm").x;
- miniY = Forms.getFormByName("MainForm").y;
- miniWidth = Forms.getFormByName("MainForm").width;
- miniHeight = Forms.getFormByName("MainForm").height;
- }
- }
-
- private function hideFullScreen(param1:Event = null) : void
- {
- if(maximized)
- {
- maximized = false;
- Forms.getFormByName("MainForm").showFullScreen(false);
- if(mode == STANDARD && !maximized)
- {
- Forms.getFormByName("MainForm").x = oldX;
- Forms.getFormByName("MainForm").y = oldY;
- Forms.getFormByName("MainForm").width = oldWidth;
- Forms.getFormByName("MainForm").height = oldHeight;
- }
- else if(mode == MINI && !maximized)
- {
- Forms.getFormByName("MainForm").x = miniX;
- Forms.getFormByName("MainForm").y = miniY;
- Forms.getFormByName("MainForm").width = miniWidth;
- Forms.getFormByName("MainForm").height = miniHeight;
- }
- }
- }
-
- private function checkMaxScreen() : void
- {
- if(System.screenWidth >= 1280 && System.screenHeight >= 839)
- {
- Forms.getFormByName("MainForm").width = 1280;
- Forms.getFormByName("MainForm").height = 720 + 109;
- }
- else
- {
- Forms.getFormByName("MainForm").width = 1024;
- Forms.getFormByName("MainForm").height = 576 + 109;
- }
- miniHeight = 387;
- miniWidth = 575;
- miniX = (System.screenWidth - 575) / 2;
- miniY = (System.screenHeight - 387) / 2;
- Forms.getFormByName("MainForm").x = (System.screenWidth - Forms.getFormByName("MainForm").width) / 2;
- Forms.getFormByName("MainForm").y = (System.screenHeight - Forms.getFormByName("MainForm").height) / 2;
- oldX = Forms.getFormByName("MainForm").x;
- oldY = Forms.getFormByName("MainForm").y;
- oldWidth = Forms.getFormByName("MainForm").width;
- oldHeight = Forms.getFormByName("MainForm").height;
- }
-
- private function onVolume(param1:Event) : void
- {
- volume = param1.target.volume;
- }
-
- private function onPackshotComplete(param1:Event) : void
- {
- trace("PACKSHOTCOMPLETE");
- }
-
- private function startBringToFront() : void
- {
- Application.bringToFront(true);
- }
- }
- }
-
-