home *** CD-ROM | disk | FTP | other *** search
- class DigiCam extends MovieClip
- {
- var current_photo_num;
- var save;
- var save_photo;
- var env;
- var current_photo;
- var touch_side;
- var screen;
- var photo;
- var replacement;
- var onEnterFrame;
- function DigiCam()
- {
- super();
- AsBroadcaster.initialize(this);
- this.current_photo_num = 0;
- this.save = new Object();
- this.save.photos = [];
- var _loc3_ = 0;
- while(_loc3_ < 9)
- {
- this.save.photos[_loc3_] = {};
- this.save.photos[_loc3_].object_id = undefined;
- this.save.photos[_loc3_].image = new flash.display.BitmapData(225,140,false,0);
- _loc3_ = _loc3_ + 1;
- }
- this.save_photo = {};
- this.save_photo.image = new flash.display.BitmapData(225,140,false,0);
- }
- function setEnvironment(p_env)
- {
- this.env = p_env;
- }
- function loadSave()
- {
- var _loc3_ = SharedObject.getLocal("BRCCSaveData");
- this.save.photos = [];
- var _loc2_ = 0;
- while(_loc2_ < 9)
- {
- this.save.photos[_loc2_] = {};
- this.save.photos[_loc2_].object_id = _loc3_.data.photos[_loc2_].object_id;
- this.save.photos[_loc2_].image = this.saveToImage(_loc3_.data.photos[_loc2_].image);
- _loc2_ = _loc2_ + 1;
- }
- }
- function writeSave()
- {
- var _loc3_ = SharedObject.getLocal("BRCCSaveData");
- _loc3_.data.photos = [];
- var _loc2_ = 0;
- while(_loc2_ < 9)
- {
- _loc3_.data.photos[_loc2_] = {};
- _loc3_.data.photos[_loc2_].object_id = this.save.photos[_loc2_].object_id;
- _loc3_.data.photos[_loc2_].image = this.imageToSave(this.save.photos[_loc2_].image);
- _loc2_ = _loc2_ + 1;
- }
- _loc3_.flush();
- }
- function imageToSave(p_image)
- {
- var _loc4_ = [];
- var _loc2_ = 0;
- while(_loc2_ < p_image.height)
- {
- _loc4_[_loc2_] = [];
- var _loc1_ = 0;
- while(_loc1_ < p_image.width)
- {
- _loc4_[_loc2_][_loc1_] = p_image.getPixel(_loc1_,_loc2_);
- _loc1_ = _loc1_ + 1;
- }
- _loc2_ = _loc2_ + 1;
- }
- return _loc4_;
- }
- function saveToImage(p_save)
- {
- var _loc5_ = p_save.length;
- var _loc3_ = new flash.display.BitmapData(225,_loc5_,false,0);
- var _loc2_ = 0;
- while(_loc2_ < _loc3_.height)
- {
- var _loc1_ = 0;
- while(_loc1_ < _loc3_.width)
- {
- _loc3_.setPixel(_loc1_,_loc2_,p_save[_loc2_][_loc1_]);
- _loc1_ = _loc1_ + 1;
- }
- _loc2_ = _loc2_ + 1;
- }
- return _loc3_.clone();
- }
- function takePicture()
- {
- _root.blue._visible = false;
- _root.hud._visible = false;
- this._visible = false;
- this.current_photo = new Photo();
- this.current_photo_num = null;
- _root.blue._visible = true;
- _root.hud._visible = true;
- this._visible = true;
- }
- function cameraPopup()
- {
- _root.hud.setText("");
- this._parent.digi_cam.broadcastMessage("popup",null);
- this.env.stopToPhoto();
- this._x = 30;
- this._y = 5;
- this._alpha = 0;
- this.touch_side._alpha = 0;
- this.setFadeIn();
- }
- function cameraPopdown()
- {
- this._parent.digi_cam.broadcastMessage("popdown",null);
- if(!this.env.inside)
- {
- this.env.stopPhotoing();
- }
- this._alpha = 100;
- this.setFadeOut();
- }
- function viewCurrentPhoto()
- {
- this.emptyScreen();
- this.screen.createEmptyMovieClip("holder_clip",1);
- this.screen.holder_clip.attachBitmap(this.current_photo.image,1);
- }
- function viewAllPhotos()
- {
- this.emptyScreen();
- var _loc4_ = 0;
- while(_loc4_ < 3)
- {
- var _loc3_ = 0;
- while(_loc3_ < 3)
- {
- var _loc2_ = 3 * _loc4_ + _loc3_;
- this.screen.createEmptyMovieClip("holder_clip" + _loc2_,_loc2_ + 1);
- this.screen["holder_clip" + _loc2_]._x = 80 * _loc3_;
- this.screen["holder_clip" + _loc2_]._y = 50 * _loc4_;
- this.screen["holder_clip" + _loc2_]._xscale = this.screen["holder_clip" + _loc2_]._yscale = 28;
- this.screen["holder_clip" + _loc2_].photo = _loc2_;
- this.screen["holder_clip" + _loc2_].attachBitmap(this.save.photos[_loc2_].image,_loc2_ + 1);
- _loc3_ = _loc3_ + 1;
- }
- _loc4_ = _loc4_ + 1;
- }
- }
- function emptyScreen()
- {
- for(var _loc2_ in this.screen)
- {
- this.screen[_loc2_].removeMovieClip();
- }
- }
- function setForSelection()
- {
- var s = this.save.photos;
- for(var _loc2_ in this.screen)
- {
- if(s[this.screen[_loc2_].photo].object_id != undefined)
- {
- this.screen[_loc2_].onRelease = function()
- {
- this._parent._parent.current_photo_num = this.photo;
- this._parent._parent.current_photo = s[this.photo];
- this._parent._parent.setTouchFadeIn(6);
- this._parent._parent.viewCurrentPhoto();
- };
- }
- }
- }
- function setForReplacement()
- {
- var s = this.save.photos;
- for(var _loc2_ in this.screen)
- {
- if(s[this.screen[_loc2_].photo].object_id != undefined)
- {
- this.screen[_loc2_].onRelease = function()
- {
- this._parent._parent.replacement = this._parent._parent.current_photo;
- this._parent._parent.current_photo_num = this.photo;
- this._parent._parent.current_photo = s[this.photo];
- this._parent._parent.setTouchFadeIn(4);
- this._parent._parent.viewCurrentPhoto();
- };
- }
- }
- }
- function replacePhoto()
- {
- this.save.photos[this.current_photo_num] = this.replacement;
- this.cameraPopdown();
- }
- function deletePhoto()
- {
- var _loc2_ = this.current_photo_num;
- while(_loc2_ < 8)
- {
- this.save.photos[_loc2_] = this.save.photos[_loc2_ + 1];
- _loc2_ = _loc2_ + 1;
- }
- this.save.photos[8] = {object_id:undefined,image:new flash.display.BitmapData(225,140,false,0)};
- this.viewSavedPhotos();
- }
- function takeNewPhoto()
- {
- this.emptyScreen();
- this.takePicture();
- this.viewCurrentPhoto();
- this.setTouchFadeIn(1);
- }
- function viewSavedPhotos()
- {
- this.emptyScreen();
- this.viewAllPhotos();
- this.setTouchFadeIn(5);
- this.setForSelection();
- }
- function saveCurrentPhoto()
- {
- var i = 0;
- while(i < 9)
- {
- if(this.save.photos[i].object_id == undefined)
- {
- this.touch_side.gotoAndStop(2);
- this.onEnterFrame = function()
- {
- this.save.photos[i] = this.current_photo;
- this.cameraPopdown();
- };
- return undefined;
- }
- i++;
- }
- this.viewSavedPhotos();
- this.setForReplacement();
- this.setTouchFadeIn(3);
- }
- function setTouchFadeIn(p_frame)
- {
- this.touch_side.gotoAndStop(p_frame);
- this.touch_side._alpha = 0;
- this.touch_side.onEnterFrame = function()
- {
- if(this._parent._alpha > 99)
- {
- this._alpha += 30;
- if(this._alpha > 99)
- {
- this.onEnterFrame = function()
- {
- };
- }
- }
- };
- }
- function setFadeIn()
- {
- this.onEnterFrame = function()
- {
- this._alpha += 30;
- if(this._alpha > 99)
- {
- this.onEnterFrame = function()
- {
- };
- }
- };
- }
- function setFadeOut()
- {
- this.onEnterFrame = function()
- {
- this._alpha -= 30;
- if(this._alpha < 0)
- {
- this._x = 60;
- this._y = 500;
- this.onEnterFrame = function()
- {
- };
- }
- };
- }
- }
-