topical media & game development
student-ar-demo.ax
student-ar-demo.ax
[swf]
flex
package {
import student_ar_PaperBase;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.lights.PointLight3D;
import org.papervision3d.core.proto.DisplayObjectContainer3D;
import org.papervision3d.events.InteractiveScene3DEvent;
//import org.papervision3d.objects.parsers.Collada;
import org.papervision3d.render.QuadrantRenderEngine;
import org.papervision3d.objects.parsers.DAE;
import org.papervision3d.events.FileLoadEvent;
//import org.papervision3d.events.*;
import org.papervision3d.materials.BitmapFileMaterial;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.display.Shape;
import flash.display.Loader;
import flash.display.MovieClip;
import flash.ui.Keyboard;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.ProgressEvent;
import flash.events.KeyboardEvent;
import flash.media.Camera;
import flash.media.Video;
import flash.utils.ByteArray;
import flash.display.Sprite;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFieldAutoSize;
import flash.filters.GlowFilter;
import org.libspark.flartoolkit.core.FLARCode;
import org.libspark.flartoolkit.core.param.FLARParam;
import org.libspark.flartoolkit.core.raster.rgb.FLARRgbRaster_BitmapData;
import org.libspark.flartoolkit.core.transmat.FLARTransMatResult;
import org.libspark.flartoolkit.detector.FLARSingleMarkerDetector;
import org.libspark.flartoolkit.pv3d.FLARBaseNode;
import org.libspark.flartoolkit.pv3d.FLARCamera3D;
import org.papervision3d.lights.PointLight3D;
import org.papervision3d.materials.ColorMaterial;
import org.papervision3d.materials.WireframeMaterial;
import org.papervision3d.materials.shadematerials.GouraudMaterial;
import org.papervision3d.materials.special.CompositeMaterial;
import org.papervision3d.materials.shadematerials.FlatShadeMaterial;
import org.papervision3d.materials.MovieMaterial;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.objects.primitives.Plane;
import org.papervision3d.objects.primitives.Cube;
import org.papervision3d.render.BasicRenderEngine;
import org.papervision3d.scenes.Scene3D;
import org.papervision3d.view.Viewport3D;
import org.papervision3d.view.BasicView;
import org.papervision3d.view.layer.ViewportLayer;
[SWF(width="640", height="480", frameRate="30", backgroundColor="#FFFFFF")]
public class @ax-student-ar-demo extends Sprite
{
[Embed(source="student-ar-Data-flarlogo.pat", mimeType="application/octet-stream")]
private var pattern:Class;
[Embed(source="student-ar-Data-camera-para.dat", mimeType="application/octet-stream")]
private var params:Class;
private var fparams:FLARParam;
private var mpattern:FLARCode;
private var vid:Video;
private var cam:Camera;
private var bmd:BitmapData;
private var raster:FLARRgbRaster_BitmapData;
private var detector:FLARSingleMarkerDetector;
private var scene:Scene3D;
private var camera:FLARCamera3D;
private var container:FLARBaseNode;
private var vp:Viewport3D;
private var bre:BasicRenderEngine;
private var trans:FLARTransMatResult;
private var matList:MaterialsList;
private var _loader:URLLoader;
private var myDate:Date;
private var strCurDate:String = "";
private var dayText;
private var dateText;
private var monthText;
private var boolTrack:Boolean = true;
private var _linksList:XML;
private var overijssel:DAE;
private var zeeland:DAE;
private var noordbrabant:DAE;
private var limburg:DAE;
private var zuidholland:DAE;
private var gelderland:DAE;
private var utrecht:DAE;
private var noordholland:DAE;
private var flevoland:DAE;
private var friesland:DAE;
private var groningen:DAE;
private var drenthe:DAE;
private var color1:ColorMaterial = new ColorMaterial(0x8D073A,1,true);
private var color2:ColorMaterial = new ColorMaterial(0xE4B899,1,true);
private var color3:ColorMaterial = new ColorMaterial(0xE39999,1,true);
private var color4:ColorMaterial = new ColorMaterial(0xE1578F,1,true);
private var color5:ColorMaterial = new ColorMaterial(0x99E4D6,1,true);
private var color6:ColorMaterial = new ColorMaterial(0x000000,1,true);
private var color7:ColorMaterial = new ColorMaterial(0x1C1CB1,1,true);
private var color8:ColorMaterial = new ColorMaterial(0xFFFFFF,1,true);
private var color9:ColorMaterial = new ColorMaterial(0x551CB1,1,true);
private var color10:ColorMaterial = new ColorMaterial(0x99E499,1,true);
private var color11:ColorMaterial = new ColorMaterial(0x876E08,1,true);
private var color12:ColorMaterial = new ColorMaterial(0x1BB11B,1,true);
private var swfLoader:Loader;
private var rssOverijssel:String = "http://rss.accuweather.com/rss/liveweather_rss.asp?metric=1&locCode=EUR|NL|NL009|ZWOLLE";
private var rssZeeland:String = "http://rss.accuweather.com/rss/liveweather_rss.asp?metric=1&locCode=EUR|NL|NL012|MIDDELBURG";
private var rssNoordBrabant:String = "http://rss.accuweather.com/rss/liveweather_rss.asp?metric=1&locCode=EUR|NL|NL007|DEN BOSCH";
private var rssLimburg:String = "http://rss.accuweather.com/rss/liveweather_rss.asp?metric=1&locCode=EUR|NL|NL006|MAASTRICHT";
private var rssZuidHolland:String = "http://rss.accuweather.com/rss/liveweather_rss.asp?metric=1&locCode=EUR|NL|NL012|DEN HAAG";
private var rssGelderland:String = "http://rss.accuweather.com/rss/liveweather_rss.asp?metric=1&locCode=EUR|NL|NL004|ARNHEM";
private var rssUtrecht:String = "http://rss.accuweather.com/rss/liveweather_rss.asp?metric=1&locCode=EUR|NL|NL010|UTRECHT";
private var rssNoordHolland:String = "http://rss.accuweather.com/rss/liveweather_rss.asp?metric=1&locCode=EUR|NL|NL008|HAARLEM";
private var rssFlevoland:String = "http://rss.accuweather.com/rss/liveweather_rss.asp?metric=1&locCode=EUR|NL|NL002|LELYSTAD";
private var rssFriesland:String = "http://rss.accuweather.com/rss/liveweather_rss.asp?metric=1&locCode=EUR|NL|NL003|LEEUWARDEN";
private var rssGroningen:String = "http://rss.accuweather.com/rss/liveweather_rss.asp?metric=1&locCode=EUR|NL|NL005|GRONINGEN";
private var rssDrenthe:String = "http://rss.accuweather.com/rss/liveweather_rss.asp?metric=1&locCode=EUR|NL|NL001|ASSEN";
private var i:Number = -1;
private var rssArray:Array = new Array();
private var imageArray:Array = new Array();
private var infoArray:Array = new Array();
private var showInfo:student_ar_WeatherInfo = new student_ar_WeatherInfo();
private var loading:student_ar_LoadScreen = new student_ar_LoadScreen();
private var btn_trackON:TrackingOn = new TrackingOn();
private var btn_trackOFF:TrackingOff = new TrackingOff();
//1 Overijssel
//2 Zeeland
//3 Noord Brabant
//4 Limburg
//5 Zuid Holland
//6 Gelderland
//7 Utrecht
//8 Noord Holland
//9 Flevoland
//10 Friesland
//11 Groningen
//12 Drenthe
public function @ax-student-ar-demo()
{
rssArray.push(rssOverijssel, rssZeeland, rssNoordBrabant, rssLimburg, rssZuidHolland, rssGelderland, rssUtrecht, rssNoordHolland, rssFlevoland, rssFriesland, rssGroningen, rssDrenthe);
btn_trackON.addEventListener(MouseEvent.CLICK,mouseClick);
btn_trackOFF.addEventListener(MouseEvent.CLICK,mouseClick);
setCurrentDate();
loadAllRSS();
setupFLAR();
setupCamera();
setupBitmap();
setupPV3D();
addProvinces();
btn_trackON.x = 18;
btn_trackON.y = 342;
btn_trackOFF.x = 18;
btn_trackOFF.y = 342;
setupButtons();
addChild(showInfo);
swfLoader = new Loader();
swfLoader.y = 120;
addChild(swfLoader);
//swfLoader.load(new URLRequest("animations/icon_1.swf"));
addChild(loading);
addEventListener(Event.ENTER_FRAME, loop);
}
public function mouseClick(event:MouseEvent):void{
if(boolTrack==true) {
boolTrack=false;
} else {
boolTrack=true;
}
setupButtons();
}
private function setCurrentDate():void {
myDate = new Date();
/*
var sec:Number = myDate.getSeconds();
var min:Number = myDate.getMinutes();
var hour:Number = myDate.getHours();
*/
var day:Number = myDate.getDay();
var date:Number = myDate.getDate();
var month:Number = myDate.getMonth();
var year:Number = myDate.getFullYear();
switch(day){
case 0:
dayText = "Sunday";
break;
case 1:
dayText = "Monday";
break;
case 2:
dayText = "Tuesday";
break;
case 3:
dayText = "Wednesday";
break;
case 4:
dayText = "Thursday";
break;
case 5:
dayText = "Friday";
break;
case 6:
dayText = "Saturday";
break;
default:
}
if(date == 1 || date == 21 || date == 31) {
dateText = date+"st";
} else if(date == 2 || date == 22) {
dateText = date+"nd";
} else if(date == 3 || date == 23) {
dateText = date+"rd";
} else {
dateText = date+"th";
}
switch(month){
case 0:
monthText = "January";
break;
case 1:
monthText = "February";
break;
case 2:
monthText = "March";
break;
case 3:
monthText = "April";
break;
case 4:
monthText = "May";
break;
case 5:
monthText = "June";
break;
case 6:
monthText = "July";
break;
case 7:
monthText = "August";
break;
case 8:
monthText = "September";
break;
case 9:
monthText = "October";
break;
case 10:
monthText = "November";
break;
case 11:
monthText = "December";
break;
default:
}
strCurDate = dayText+", the "+dateText+" of "+monthText;
}
private function loadAllRSS():void {
i++
_loader = new URLLoader;
_loader.addEventListener(ProgressEvent.PROGRESS, LoadProgress);
_loader.addEventListener(Event.COMPLETE, HandleComplete);
if(i < rssArray.length){
_loader.load(new URLRequest(rssArray[i]));
//trace(rssArray[i]);
}else{
removeChild(loading);
}
}
private function LoadProgress(event:ProgressEvent):void{
loading.LoadingRSS(event.bytesLoaded, event.bytesTotal);
}
private function HandleComplete(event:Event):void{
_linksList = new XML(event.target.data);
var city:String = GetCity(_linksList.channel.title);
var highTemp:String = GetHighTemp(_linksList.channel.item[1].description);
var lowTemp:String = GetLowTemp(_linksList.channel.item[1].description);
var forecastSentence:String = GetForecast(_linksList.channel.item[1].description);
infoArray.push([city, highTemp, lowTemp, forecastSentence]);
imageArray.push(GetImage(_linksList.channel.item[1].description));
//trace(GetImage(_linksList.channel.item[1].description));
//trace(event.target);
loading.UpdateRSS(i+1, rssArray.length);
loading._rssPercentage.text = "100%";
loading._rssPercentage.setTextFormat(loading._loadingTextFormat);
loadAllRSS();
}
private function setupFLAR():void
{
fparams = new FLARParam();
fparams.loadARParam(new params() as ByteArray);
mpattern = new FLARCode(16, 16);
mpattern.loadARPatt(new pattern());
}
private function setupCamera():void
{
vid = new Video(640, 480);
cam = Camera.getCamera();
cam.setMode(640, 480, 30);
vid.attachCamera(cam);
addChild(vid);
}
private function setupBitmap():void
{
bmd = new BitmapData(640, 480);
bmd.draw(vid);
raster = new FLARRgbRaster_BitmapData(bmd);
detector = new FLARSingleMarkerDetector(fparams, mpattern, 80);
}
private function setupButtons():void
{
addChild(btn_trackOFF);
if(boolTrack==true) {
removeChild(btn_trackOFF);
addChild(btn_trackON);
} else {
removeChild(btn_trackON);
addChild(btn_trackOFF);
}
}
//add provinces to the container
private function addProvinces():void
{
//add collada models to container
container.addChild(overijssel);
trace("MODEL 1 LOADED");
//add collada models to container
container.addChild(zeeland);
trace("MODEL 2 LOADED");
//add collada models to container
container.addChild(noordbrabant);
trace("MODEL 3 LOADED");
//add collada models to container
container.addChild(limburg);
trace("MODEL 4 LOADED");
//add collada models to container
container.addChild(zuidholland);
trace("MODEL 5 LOADED");
//add collada models to container
container.addChild(gelderland);
trace("MODEL 6 LOADED");
//add collada models to container
container.addChild(utrecht);
trace("MODEL 7 LOADED");
//add collada models to container
container.addChild(noordholland);
trace("MODEL 8 LOADED");
//add collada models to container
container.addChild(flevoland);
trace("MODEL 9 LOADED");
//add collada models to container
container.addChild(friesland);
trace("MODEL 10 LOADED");
//add collada models to container
container.addChild(groningen);
trace("MODEL 11 LOADED");
//add collada models to container
container.addChild(drenthe);
trace("MODEL 12 LOADED");
}
//set imported collada object size and rotation values
private function setupModelProperties():void
{
overijssel.scale = 0.3;
overijssel.rotationX-=90;
overijssel.rotationY+=180;
zeeland.scale = 0.3;
zeeland.rotationX-=90;
zeeland.rotationY+=180;
noordbrabant.scale = 0.3;
noordbrabant.rotationX-=90;
noordbrabant.rotationY+=180;
limburg.scale = 0.3;
limburg.rotationX-=90;
limburg.rotationY+=180;
zuidholland.scale = 0.3;
zuidholland.rotationX-=90;
zuidholland.rotationY+=180;
gelderland.scale = 0.3;
gelderland.rotationX-=90;
gelderland.rotationY+=180;
utrecht.scale = 0.3;
utrecht.rotationX-=90;
utrecht.rotationY+=180;
noordholland.scale = 0.3;
noordholland.rotationX-=90;
noordholland.rotationY+=180;
flevoland.scale = 0.3;
flevoland.rotationX-=90;
flevoland.rotationY+=180;
friesland.scale = 0.3;
friesland.rotationX-=90;
friesland.rotationY+=180;
groningen.scale = 0.3;
groningen.rotationX-=90;
groningen.rotationY+=180;
drenthe.scale = 0.3;
drenthe.rotationX-=90;
drenthe.rotationY+=180;
//Positioning
overijssel.z += 50;
overijssel.y = 2;
zeeland.z += 50;
zeeland.y = 2;
noordbrabant.z += 50;
noordbrabant.y = 2;
limburg.z += 50;
limburg.y = 2;
zuidholland.z += 50;
zuidholland.y = 2;
gelderland.z += 50;
gelderland.y = 2;
utrecht.z += 50;
utrecht.y = 2;
noordholland.z += 50;
noordholland.y = 2;
flevoland.z += 50;
flevoland.y = 2;
friesland.z += 50;
friesland.y = 2;
groningen.z += 50;
groningen.y = 2;
drenthe.z += 50;
drenthe.y = 2;
}
private function setupPV3D():void
{
scene = new Scene3D();
camera = new FLARCamera3D(fparams);
container = new FLARBaseNode();
scene.addChild(container);
var pl:PointLight3D = new PointLight3D();
pl.x = 1000;
pl.y = 1000;
pl.z = -1000;
overijssel = new DAE();
zeeland = new DAE();
noordbrabant = new DAE();
limburg = new DAE();
zuidholland = new DAE();
gelderland = new DAE();
utrecht = new DAE();
noordholland = new DAE();
flevoland = new DAE();
friesland = new DAE();
groningen = new DAE();
drenthe = new DAE();
//set imported collada object size and rotation values
setupModelProperties();
overijssel.load("student-ar-Data-overijssel.DAE");
overijssel.useMaterialTargetName = true;
zeeland.load("student-ar-Data-zeeland.DAE");
zeeland.useMaterialTargetName = true;
noordbrabant.load("student-ar-Data-noordbrabant.DAE");
noordbrabant.useMaterialTargetName = true;
limburg.load("student-ar-Data-limburg.DAE");
limburg.useMaterialTargetName = true;
zuidholland.load("student-ar-Data-zuidholland.DAE");
zuidholland.useMaterialTargetName = true;
gelderland.load("student-ar-Data-gelderland.DAE");
gelderland.useMaterialTargetName = true;
utrecht.load("student-ar-Data-utrecht.DAE");
utrecht.useMaterialTargetName = true;
noordholland.load("student-ar-Data-noordholland.DAE");
noordholland.useMaterialTargetName = true;
flevoland.load("student-ar-Data-flevoland.DAE");
flevoland.useMaterialTargetName = true;
friesland.load("student-ar-Data-friesland.DAE");
friesland.useMaterialTargetName = true;
groningen.load("student-ar-Data-groningen.DAE");
groningen.useMaterialTargetName = true;
drenthe.load("student-ar-Data-drenthe.DAE");
drenthe.useMaterialTargetName = true;
//add event listeners to collada objects
overijssel.addEventListener(FileLoadEvent.LOAD_COMPLETE, collada1Loaded);
overijssel.addEventListener(FileLoadEvent.COLLADA_MATERIALS_DONE, matsLoaded);
zeeland.addEventListener(FileLoadEvent.LOAD_COMPLETE, collada2Loaded);
zeeland.addEventListener(FileLoadEvent.COLLADA_MATERIALS_DONE, matsLoaded);
noordbrabant.addEventListener(FileLoadEvent.LOAD_COMPLETE, collada3Loaded);
noordbrabant.addEventListener(FileLoadEvent.COLLADA_MATERIALS_DONE, matsLoaded);
limburg.addEventListener(FileLoadEvent.LOAD_COMPLETE, collada4Loaded);
limburg.addEventListener(FileLoadEvent.COLLADA_MATERIALS_DONE, matsLoaded);
zuidholland.addEventListener(FileLoadEvent.LOAD_COMPLETE, collada5Loaded);
zuidholland.addEventListener(FileLoadEvent.COLLADA_MATERIALS_DONE, matsLoaded);
gelderland.addEventListener(FileLoadEvent.LOAD_COMPLETE, collada6Loaded);
gelderland.addEventListener(FileLoadEvent.COLLADA_MATERIALS_DONE, matsLoaded);
utrecht.addEventListener(FileLoadEvent.LOAD_COMPLETE, collada7Loaded);
utrecht.addEventListener(FileLoadEvent.COLLADA_MATERIALS_DONE, matsLoaded);
noordholland.addEventListener(FileLoadEvent.LOAD_COMPLETE, collada8Loaded);
noordholland.addEventListener(FileLoadEvent.COLLADA_MATERIALS_DONE, matsLoaded);
flevoland.addEventListener(FileLoadEvent.LOAD_COMPLETE, collada9Loaded);
flevoland.addEventListener(FileLoadEvent.COLLADA_MATERIALS_DONE, matsLoaded);
friesland.addEventListener(FileLoadEvent.LOAD_COMPLETE, collada10Loaded);
friesland.addEventListener(FileLoadEvent.COLLADA_MATERIALS_DONE, matsLoaded);
groningen.addEventListener(FileLoadEvent.LOAD_COMPLETE, collada11Loaded);
groningen.addEventListener(FileLoadEvent.COLLADA_MATERIALS_DONE, matsLoaded);
drenthe.addEventListener(FileLoadEvent.LOAD_COMPLETE, collada12Loaded);
drenthe.addEventListener(FileLoadEvent.COLLADA_MATERIALS_DONE, matsLoaded);
//add 3D objects to container
bre = new BasicRenderEngine();
trans = new FLARTransMatResult();
vp = new Viewport3D();
vp.interactive = true;
addChild(vp);
}
public function collada1Loaded(ev:FileLoadEvent):void
{
//1 Overijssel
//2 Zeeland
//3 Noord Brabant
//4 Limburg
//5 Zuid Holland
//6 Gelderland
//7 Utrecht
//8 Noord Holland
//9 Flevoland
//10 Friesland
//11 Groningen
//12 Drenthe
overijssel.replaceMaterialByName(color1, 'ColorMaterial_1BB11B00');
var overijsselDO3D:DisplayObject3D = overijssel.getChildByName("Overijsel", true);
var overijsselLayer:ViewportLayer = vp.containerSprite.getChildLayer(overijsselDO3D, true, true);
overijsselLayer.name = "Overijssel";
overijsselLayer.addEventListener(MouseEvent.MOUSE_OVER, MouseOverHandler);
overijsselLayer.addEventListener(MouseEvent.MOUSE_OUT, MouseOutHandler);
}
public function collada2Loaded(ev:FileLoadEvent):void
{
//2 Zeeland
zeeland.replaceMaterialByName(color2, 'ColorMaterial_876E0800');
var zeelandDO3D:DisplayObject3D = zeeland.getChildByName("Zeeland", true);
var zeelandLayer:ViewportLayer = vp.containerSprite.getChildLayer(zeelandDO3D, true, true);
zeelandLayer.name = "Zeeland";
zeelandLayer.addEventListener(MouseEvent.MOUSE_OVER, MouseOverHandler);
zeelandLayer.addEventListener(MouseEvent.MOUSE_OUT, MouseOutHandler);
}
public function collada3Loaded(ev:FileLoadEvent):void
{
//3 Noord Brabant
noordbrabant.replaceMaterialByName(color3, 'ColorMaterial_99E49900');
var noordbrabantDO3D:DisplayObject3D = noordbrabant.getChildByName("NoordBrabant", true);
var noordbrabantLayer:ViewportLayer = vp.containerSprite.getChildLayer(noordbrabantDO3D, true, true);
noordbrabantLayer.name = "NoordBrabant";
noordbrabantLayer.addEventListener(MouseEvent.MOUSE_OVER, MouseOverHandler);
noordbrabantLayer.addEventListener(MouseEvent.MOUSE_OUT, MouseOutHandler);
}
public function collada4Loaded(ev:FileLoadEvent):void
{
//4 Limburg
limburg.replaceMaterialByName(color4, 'ColorMaterial_551CB100');
var limburgDO3D:DisplayObject3D = limburg.getChildByName("Limburg", true);
var limburgLayer:ViewportLayer = vp.containerSprite.getChildLayer(limburgDO3D, true, true);
limburgLayer.name = "Limburg";
limburgLayer.addEventListener(MouseEvent.MOUSE_OVER, MouseOverHandler);
limburgLayer.addEventListener(MouseEvent.MOUSE_OUT, MouseOutHandler);
}
public function collada5Loaded(ev:FileLoadEvent):void
{
//5 Zuid Holland
zuidholland.replaceMaterialByName(color5, 'ColorMaterial_FFFFFF00');
var zuidhollandDO3D:DisplayObject3D = zuidholland.getChildByName("ZuidHolland", true);
var zuidhollandLayer:ViewportLayer = vp.containerSprite.getChildLayer(zuidhollandDO3D, true, true);
zuidhollandLayer.name = "ZuidHolland";
zuidhollandLayer.addEventListener(MouseEvent.MOUSE_OVER, MouseOverHandler);
zuidhollandLayer.addEventListener(MouseEvent.MOUSE_OUT, MouseOutHandler);
}
public function collada6Loaded(ev:FileLoadEvent):void
{
//6 Gelderland
gelderland.replaceMaterialByName(color6, 'ColorMaterial_1C1CB100');
var gelderlandDO3D:DisplayObject3D = gelderland.getChildByName("Gelderland", true);
var gelderlandLayer:ViewportLayer = vp.containerSprite.getChildLayer(gelderlandDO3D, true, true);
gelderlandLayer.name = "Gelderland";
gelderlandLayer.addEventListener(MouseEvent.MOUSE_OVER, MouseOverHandler);
gelderlandLayer.addEventListener(MouseEvent.MOUSE_OUT, MouseOutHandler);
}
public function collada7Loaded(ev:FileLoadEvent):void
{
//7 Utrecht
utrecht.replaceMaterialByName(color7, 'ColorMaterial_00000000');
var utrechtDO3D:DisplayObject3D = utrecht.getChildByName("Utrecht", true);
var utrechtLayer:ViewportLayer = vp.containerSprite.getChildLayer(utrechtDO3D, true, true);
utrechtLayer.name = "Utrecht";
utrechtLayer.addEventListener(MouseEvent.MOUSE_OVER, MouseOverHandler);
utrechtLayer.addEventListener(MouseEvent.MOUSE_OUT, MouseOutHandler);
}
public function collada8Loaded(ev:FileLoadEvent):void
{
//8 Noord Holland
noordholland.replaceMaterialByName(color8, 'ColorMaterial_99E4D600');
var noordhollandDO3D:DisplayObject3D = noordholland.getChildByName("NoordHolland", true);
var noordhollandLayer:ViewportLayer = vp.containerSprite.getChildLayer(noordhollandDO3D, true, true);
noordhollandLayer.name = "NoordHolland";
noordhollandLayer.addEventListener(MouseEvent.MOUSE_OVER, MouseOverHandler);
noordhollandLayer.addEventListener(MouseEvent.MOUSE_OUT, MouseOutHandler);
}
public function collada9Loaded(ev:FileLoadEvent):void
{
//9 Flevoland
flevoland.replaceMaterialByName(color9, 'ColorMaterial_E1578F00');
var flevolandDO3D:DisplayObject3D = flevoland.getChildByName("Flevoland", true);
var flevolandLayer:ViewportLayer = vp.containerSprite.getChildLayer(flevolandDO3D, true, true);
flevolandLayer.name = "Flevoland";
flevolandLayer.addEventListener(MouseEvent.MOUSE_OVER, MouseOverHandler);
flevolandLayer.addEventListener(MouseEvent.MOUSE_OUT, MouseOutHandler);
}
public function collada10Loaded(ev:FileLoadEvent):void
{
//10 Friesland
friesland.replaceMaterialByName(color10, 'ColorMaterial_E3999900');
var frieslandDO3D:DisplayObject3D = friesland.getChildByName("Friesland", true);
var frieslandLayer:ViewportLayer = vp.containerSprite.getChildLayer(frieslandDO3D, true, true);
frieslandLayer.name = "Friesland";
frieslandLayer.addEventListener(MouseEvent.MOUSE_OVER, MouseOverHandler);
frieslandLayer.addEventListener(MouseEvent.MOUSE_OUT, MouseOutHandler);
}
public function collada11Loaded(ev:FileLoadEvent):void
{
//11 Groningen
groningen.replaceMaterialByName(color11, 'ColorMaterial_E4B89900');
var groningenDO3D:DisplayObject3D = groningen.getChildByName("Groningen", true);
var groningenLayer:ViewportLayer = vp.containerSprite.getChildLayer(groningenDO3D, true, true);
groningenLayer.name = "Groningen";
groningenLayer.addEventListener(MouseEvent.MOUSE_OVER, MouseOverHandler);
groningenLayer.addEventListener(MouseEvent.MOUSE_OUT, MouseOutHandler);
}
public function collada12Loaded(ev:FileLoadEvent):void
{
//12 Drenthe
drenthe.replaceMaterialByName(color12, 'ColorMaterial_8D073A00');
var drentheDO3D:DisplayObject3D = drenthe.getChildByName("Drenthe", true);
var drentheLayer:ViewportLayer = vp.containerSprite.getChildLayer(drentheDO3D, true, true);
drentheLayer.name = "Drenthe";
drentheLayer.addEventListener(MouseEvent.MOUSE_OVER, MouseOverHandler);
drentheLayer.addEventListener(MouseEvent.MOUSE_OUT, MouseOutHandler);
//trace(drentheDO3D);
}
protected function MouseOverHandler(event:MouseEvent):void
{
//1 Overijssel
//2 Zeeland
//3 Noord Brabant
//4 Limburg
//5 Zuid Holland
//6 Gelderland
//7 Utrecht
//8 Noord Holland
//9 Flevoland
//10 Friesland
//11 Groningen
//12 Drenthe
event.currentTarget.filters = [new GlowFilter(0x009900, 1, 6, 6, 2, 5)];
switch(event.currentTarget.name){
case "Overijssel":
WeatherAnimation(imageArray[0]);
showInfo.ChangeInfo(infoArray[0][0], infoArray[0][1], infoArray[0][2], infoArray[0][3]);
break;
case "Zeeland":
WeatherAnimation(imageArray[1]);
showInfo.ChangeInfo(infoArray[1][0], infoArray[1][1], infoArray[1][2], infoArray[1][3]);
break;
case "NoordBrabant":
WeatherAnimation(imageArray[2]);
showInfo.ChangeInfo(infoArray[2][0], infoArray[2][1], infoArray[2][2], infoArray[2][3]);
break;
case "Limburg":
WeatherAnimation(imageArray[3]);
showInfo.ChangeInfo(infoArray[3][0], infoArray[3][1], infoArray[3][2], infoArray[3][3]);
break;
case "ZuidHolland":
WeatherAnimation(imageArray[4]);
showInfo.ChangeInfo(infoArray[4][0], infoArray[4][1], infoArray[4][2], infoArray[4][3]);
break;
case "Gelderland":
WeatherAnimation(imageArray[5]);
showInfo.ChangeInfo(infoArray[5][0], infoArray[5][1], infoArray[5][2], infoArray[5][3]);
break;
case "Utrecht":
WeatherAnimation(imageArray[6]);
showInfo.ChangeInfo(infoArray[6][0], infoArray[6][1], infoArray[6][2], infoArray[6][3]);
break;
case "NoordHolland":
//setInfoText(item8Str);
WeatherAnimation(imageArray[7]);
showInfo.ChangeInfo(infoArray[7][0], infoArray[7][1], infoArray[7][2], infoArray[7][3]);
break;
case "Flevoland":
WeatherAnimation(imageArray[8]);
showInfo.ChangeInfo(infoArray[8][0], infoArray[8][1], infoArray[8][2], infoArray[8][3]);
break;
case "Friesland":
WeatherAnimation(imageArray[9]);
showInfo.ChangeInfo(infoArray[9][0], infoArray[9][1], infoArray[9][2], infoArray[9][3]);
break;
case "Groningen":
WeatherAnimation(imageArray[10]);
showInfo.ChangeInfo(infoArray[10][0], infoArray[10][1], infoArray[10][2], infoArray[10][3]);
break;
case "Drenthe":
WeatherAnimation(imageArray[11]);
showInfo.ChangeInfo(infoArray[11][0], infoArray[11][1], infoArray[11][2], infoArray[11][3]);
break;
default:
}
//trace(event.currentTarget.name);
}
protected function MouseOutHandler(event:MouseEvent):void
{
event.currentTarget.filters = [];
swfLoader.unload();
showInfo.ChangeInfo("-", "-", "-", "-");
}
public function matsLoaded(ev:FileLoadEvent):void
{
trace("MATS LOADED");
}
private function loop(e:Event):void
{
bmd.draw(vid);
try
{
if(detector.detectMarkerLite(raster, 80) && detector.getConfidence() > 0.5 && boolTrack)
{
detector.getTransformMatrix(trans);
container.setTransformMatrix(trans);
bre.renderScene(scene, camera, vp);
}
}
catch(e:Error){}
}
private function WeatherAnimation(image:String)
{
switch(image){
case "01":
swfLoader.load(new URLRequest("animations/icon_1.swf"));
break;
case "02":
swfLoader.load(new URLRequest("animations/icon_2.swf"));
break;
case "03":
case "04":
swfLoader.load(new URLRequest("animations/icon_3.swf"));
break;
case "06":
swfLoader.load(new URLRequest("animations/icon_4.swf"));
break;
case "05":
case "11":
swfLoader.load(new URLRequest("animations/icon_6.swf"));
break;
case "07":
swfLoader.load(new URLRequest("animations/icon_7.swf"));
break;
case "08":
swfLoader.load(new URLRequest("animations/icon_11.swf"));
break;
case "12":
swfLoader.load(new URLRequest("animations/icon_12.swf"));
break;
case "13":
swfLoader.load(new URLRequest("animations/icon_13.swf"));
break;
case "14":
swfLoader.load(new URLRequest("animations/icon_14.swf"));
break;
case "15":
swfLoader.load(new URLRequest("animations/icon_15.swf"));
break;
case "16":
case "17":
swfLoader.load(new URLRequest("animations/icon_16.swf"));
break;
case "18":
swfLoader.load(new URLRequest("animations/icon_18.swf"));
break;
case "19":
swfLoader.load(new URLRequest("animations/icon_20.swf"));
break;
case "20":
case "21":
case "23":
swfLoader.load(new URLRequest("animations/icon_21.swf"));
break;
case "22":
swfLoader.load(new URLRequest("animations/icon_22.swf"));
break;
case "25":
swfLoader.load(new URLRequest("animations/icon_23.swf"));
break;
case "29":
swfLoader.load(new URLRequest("animations/icon_25.swf"));
break;
case "24":
swfLoader.load(new URLRequest("animations/icon_26.swf"));
break;
case "25":
case "26":
swfLoader.load(new URLRequest("animations/icon_29.swf"));
break;
case "30":
swfLoader.load(new URLRequest("animations/icon_30.swf"));
break;
case "31":
swfLoader.load(new URLRequest("animations/icon_31.swf"));
break;
case "32":
swfLoader.load(new URLRequest("animations/icon_32.swf"));
break;
case "33":
swfLoader.load(new URLRequest("animations/icon_33.swf"));
break;
case "34":
case "37":
swfLoader.load(new URLRequest("animations/icon_34.swf"));
break;
case "35":
case "36":
case "38":
swfLoader.load(new URLRequest("animations/icon_35.swf"));
break;
case "39":
case "40":
swfLoader.load(new URLRequest("animations/icon_39.swf"));
break;
case "41":
case "42":
swfLoader.load(new URLRequest("animations/icon_42.swf"));
break;
case "43":
case "44":
swfLoader.load(new URLRequest("animations/icon_43.swf"));
break;
default:
swfLoader.load(new URLRequest("animations/icon_0.swf"));
}
}
private function GetCity(temp:String):String
{
var indexCityEnd:int = temp.lastIndexOf(",");
var cityLowerCase:String = temp.substring(1, indexCityEnd).toLowerCase();
//trace("This is the city: " + temp.substring(0, 1) + cityLowerCase);
return temp.substring(0, 1) + cityLowerCase;
}
private function GetHighTemp(temp:String):String
{
var lastIndex:int = temp.length;
var spaceArray:Array = new Array();//This array will contain the index of every whitespace in the string
while((lastIndex = temp.lastIndexOf(" ", lastIndex - 1)) != -1){
spaceArray.push(lastIndex);
//trace("tracing C: " + lastIndex);
}
//trace("This is the sentence of the highest value: " + temp.substring(indexHigh, cArray[cArray.length-1]+1));
return temp.substring(spaceArray[spaceArray.length-1], spaceArray[spaceArray.length-2]);
}
private function GetLowTemp(temp:String):String
{
var lastIndex:int = temp.length;
var spaceArray:Array = new Array();//This array will contain the index of every whitespace in the string
while((lastIndex = temp.lastIndexOf(" ", lastIndex - 1)) != -1){
spaceArray.push(lastIndex);
//trace("tracing C: " + lastIndex);
}
//trace("This is the sentence of the highest value: " + temp.substring(indexHigh, cArray[cArray.length-1]+1));
return temp.substring(spaceArray[spaceArray.length-4], spaceArray[spaceArray.length-5]);
}
private function GetForecast(temp:String):String
{
var indexImage:int = temp.lastIndexOf("<");
var lastIndex:int = temp.length;
var cArray:Array = new Array();//This array will contain the index of every capital C in the string
while((lastIndex = temp.lastIndexOf("C", lastIndex - 1)) != -1){
cArray.push(lastIndex);
//trace("tracing C: " + lastIndex);
}
//trace("This is the sentence of the highest value: " + temp.substring(indexHigh, cArray[cArray.length-1]+1));
return temp.substring(cArray[cArray.length-2]+1, indexImage);
}
private function GetImage(temp:String):String
{
var beginURL:int = temp.lastIndexOf("<") + 1;
var endURL:int = temp.lastIndexOf(">");
var urlString:String = temp.substring(beginURL, endURL);
return urlString.substring(68, 70);
}
}
}
(C) Æliens
27/08/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.