I am making a website using this AS to create a full browser slideshow:
/******************************************************************************
CROSS FADING AS3 FULL BROWSER SLIDESHOW DOCUMENT CLASS
*******************************************************************************
Document class with demonstration use of some of the methods in the slideshow
class.
*******************************************************************************/
package {
import flash.display.MovieClip;
import flash.events.*;
import flash.text.*;
import noponies.display.FullBrowserXShow;
import noponies.utils.LoadXmlToArray;
import noponies.utils.FullScreenMenu;
import noponies.utils.StageManager;
public class FullBrowserSlideDemo extends MovieClip {
private var newBgSlideShow:FullBrowserXShow;
private var stageTest:StageManager;
private var myloadXml:LoadXmlToArray;
//constructor
public function FullBrowserSlideDemo() {
//load in xml via call to external xml parsing class
//it returns us a nice array of images to pass to the slide class*/
myloadXml = new LoadXmlToArray("images.xml");
myloadXml.addEventListener("xmlParsed", initSlides);
//associate the Stagemanager class with our button
stageTest = new StageManager(next_btn, 0, 100, -20, 100, true);
addChild(stageTest);
//add the fullscreen context menu
var fullScreenMenu:FullScreenMenu = new FullScreenMenu(this);
}
//call back function from XML loading class
//here we instantiate the full browser class and pass it our array of images
private function initSlides(evt:Event):void {
//instantiate the slideshow
newBgSlideShow = new FullBrowserXShow(myloadXml.imagesArray);
addChildAt(newBgSlideShow,0);
//configure listeners
newBgSlideShow.addEventListener(FullBrowserXShow.SLIDE_CHANGE, handleSlideChange);
newBgSlideShow.addEventListener(FullBrowserXShow.BG_LOADING, handleProgEvent);
newBgSlideShow.addEventListener(FullBrowserXShow.BG_LOADED, handleLoadedEvent);
newBgSlideShow.addEventListener(FullBrowserXShow.BG_LOAD_STARTED, handleLoadStartEvent);
next_btn.addEventListener(MouseEvent.CLICK, nextImage);
//disable the next button until we actually have content
next_btn.mouseChildren = false;
next_btn.buttonMode = false;
}
//demo manual next image function
//Here we change button text and change the buttons visual state to reflect its status
//The next image function will not work while an image is loading and fading in
private function nextImage(event:MouseEvent):void {
this.next_btn.btn_txt.text = "LOADING";
this.next_btn.alpha = .5;
this.next_btn.mouseEnabled = false;
next_btn.buttonMode = false;
newBgSlideShow.loadSlide()
//example below of calling a setter method in the slideshow
//newBgSlideShow.imageDisplayTime=10
//newBgSlideShow.pauseSlides()
//newBgSlideShow.restartSlides()
//newBgSlideShow.unloadAll()
}
//listener for load started event
private function handleLoadStartEvent(event:Event):void {
this.next_btn.btn_txt.text = "LOADING";
this.next_btn.alpha = .5;
this.next_btn.mouseEnabled = false;
next_btn.buttonMode = false;
}
//listener for status event dispatched from slideshow
private function handleSlideChange(event:Event):void {
status_txt.text = "You are currently viewing slide "+newBgSlideShow.currentSlide+ " of "+newBgSlideShow.slidesTotal+" slides";
}
//listener for loaded event dispatched from sideshow
private function handleLoadedEvent(event:Event):void {
this.next_btn.alpha = 1;
this.next_btn.btn_txt.text = "NEXT SLIDE";
this.next_btn.mouseEnabled = true;
next_btn.buttonMode = true
}
//listener handler for progress events. This handler accesses the classes getter methods to obtain references to the bytes loaded and bytesTotal value for each object.
//The goal here is for the class to have no external dependencies for display, rather it should simply provide information or dispatch information when requested and not
//care about what gets done with that information
private function handleProgEvent(event:Event):void {
loaded_txt.text = newBgSlideShow.bytesLoaded / 1000 + "KB loaded out of " + newBgSlideShow.bytesTotal / 1000 + "KB "+ "or "+uint(100 * newBgSlideShow.bytesLoaded / newBgSlideShow.bytesTotal)+"%";
}
}
}
now I have made got a gallery to work using a similar effect to that of light box. the gallery is in a seperate .SWF to the main website and it loaded in. My problem is I don’t know how to make the gallery god full screen once loaded into the website. at the moment it just loades to the size of the origional gallery.swf dimensions.
here is the gallery script:
gallery.swf AS:
stage.scaleMode = StageScaleMode.NO_SCALE;
btn1.imgAddr = 'island_in_the_sky2.jpg';
btn1.imgLabel = 'a funk alisious design';
btn1.buttonMode = true;
btn1.addEventListener(MouseEvent.CLICK,activateASbox);
btn2.imgAddr = 'islandstyle.jpg';
btn2.imgLabel = 'a nice island pic of mine';
btn2.buttonMode = true;
btn2.addEventListener(MouseEvent.CLICK,activateASbox);
btn3.imgAddr = 'peanut.jpg';
btn3.imgLabel = 'peanut man illustration';
btn3.buttonMode = true;
btn3.addEventListener(MouseEvent.CLICK,activateASbox);
btn4.imgAddr = 'water.jpg';
btn4.imgLabel = 'water or some stuff';
btn4.buttonMode = true;
btn4.addEventListener(MouseEvent.CLICK,activateASbox);
function activateASbox(e:MouseEvent):void {
var btn:MovieClip = e.target as MovieClip;
var asb:ASbox = new ASbox(btn,600,500);
}
the ASbox.as file.
/*
*************************************
* File: ASbox.as
* Version: 1.0
* Author: Marcello Surdi
* Web: http://www.marcellosurdi.name
* E-mail: info@marcellosurdi.name
* Created: 14/04/2008
* Last update: 14/04/2008
* License: http://creativecommons.org/licenses/by-sa/3.0/
*************************************
*/
package {
import fl.transitions.easing.None;
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import flash.display.Graphics;
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.display.Stage;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
public class ASbox {
private var imgAddr:String;
private var imgLabel:String;
private var oldSwfW:uint;
private var oldSwfH:uint;
private var swf:Stage;
private var bg:Sprite = new Sprite();
private var pr:Preloader = new Preloader();
private var cn:Sprite = new Sprite();
private var ld:Loader = new Loader();
public function ASbox(btn:MovieClip,oldSwfW:uint,oldSwfH:uint):void {
imgAddr = btn.imgAddr;
imgLabel = btn.imgLabel;
this.oldSwfW = oldSwfW;
this.oldSwfH = oldSwfH;
swf = btn.stage;
swf.addEventListener(Event.RESIZE,resizeBg);
bg.x = (oldSwfW - swf.stageWidth) / 2;
bg.y = (oldSwfH - swf.stageHeight) / 2;
bg.graphics.beginFill(0x000000,.85);
bg.graphics.drawRect(0,0,swf.stageWidth,swf.stageHeight);
bg.graphics.endFill();
swf.addChild(bg);
loadImage();
}
private function resizeBg(e:Event):void {
bg.x = (oldSwfW - swf.stageWidth) / 2;
bg.y = (oldSwfH - swf.stageHeight) / 2;
bg.width = swf.stageWidth;
bg.height = swf.stageHeight;
}
private function loadImage():void {
var addr:URLRequest = new URLRequest(imgAddr);
var infoloader:LoaderInfo = ld.contentLoaderInfo;
infoloader.addEventListener(IOErrorEvent.IO_ERROR,ioErrorHandler);
infoloader.addEventListener(Event.OPEN,openHandler);
infoloader.addEventListener(Event.COMPLETE,completeHandler);
ld.load(addr);
}
private function ioErrorHandler(e:IOErrorEvent):void {
swf.removeChild(bg);
trace(e.text);
}
private function openHandler(e:Event):void {
pr.x = (oldSwfW - pr.width) / 2;
pr.y = (oldSwfH - pr.height) / 2;
swf.addChild(pr);
}
private function completeHandler(e:Event):void {
swf.removeChild(pr);
cn.graphics.beginFill(0xFFFFFF);
var cnW:uint = e.target.width + 10;
var cnH:uint = e.target.height + 25;
cn.x = (oldSwfW - cnW) / 2;
cn.y = (oldSwfH - cnH) / 2;
cn.graphics.drawRect(0,0,cnW,cnH);
cn.graphics.endFill();
swf.addChild(cn);
ld.x = 5;
ld.y = 5;
cn.addChild(ld);
var tw:Tween = new Tween(ld,'alpha',None.easeIn,0,1,10,false);
var cl:Closer = new Closer();
cl.x = cnW - cl.width - 5;
cl.y = cnH - 20;
cl.buttonMode = true;
cl.mouseChildren = false;
cl.addEventListener(MouseEvent.CLICK,closeLightbox);
cn.addChild(cl);
if(imgLabel.length > 0) {
var tfFormat:TextFormat = new TextFormat();
tfFormat.font = 'Arial';
tfFormat.bold = true;
tfFormat.size = 10;
tfFormat.color = 0x999999;
var tf:TextField = new TextField();
tf.text = imgLabel.toUpperCase();
tf.autoSize = TextFieldAutoSize.LEFT;
tf.x = 5;
tf.y = cnH - 20;
tf.selectable = false;
tf.setTextFormat(tfFormat);
cn.addChild(tf);
}
}
private function closeLightbox(e:MouseEvent):void {
swf.removeChild(cn);
var tw:Tween = new Tween(bg,'alpha',None.easeIn,1,.25,10,false);
tw.addEventListener(TweenEvent.MOTION_FINISH,function(e:TweenEvent) { swf.removeChild(bg); });
}
}
}
I think it must be something to do with this:
stage.scaleMode = StageScaleMode.NO_SCALE;
and I tried
_parent.stage.scaleMode = StageScaleMode.NO_SCALE;
and
_root.stage.scaleMode = StageScaleMode.NO_SCALE;
But Im not really that confident in flash I’m only just learning so I wouldn’t be surprised if I was totally wrong:confused: .
Thanx alot would appriciate any help.