Penn State University -- School of Visual Arts
Fall 2011
ART 416 Advanced Web and Net Art: Multimedia Publishing
Professor: Eduardo Navas (ean13@psu.edu)
T TH 02:30P - 05:30P

Office Hours: Tuesday 12 PM - 2 PM, by appointment
Please contact me via e-mail

Back to 416 Main Page

Miscellaneous Flash Code

The following code is for the Flash file titled "FrameRate," place it on the top key frame of the main timeline:

buttSlow.addEventListener (MouseEvent.MOUSE_DOWN, slowRate);
buttMed.addEventListener (MouseEvent.MOUSE_DOWN, midRate);
buttFast.addEventListener (MouseEvent.MOUSE_DOWN, fastRate);
buttMultiple.addEventListener (MouseEvent.MOUSE_DOWN, multipleRate);

function slowRate(evt:MouseEvent): void {

stage.frameRate = 6;

}


function midRate(evt:MouseEvent): void {

stage.frameRate = 24;

}

function fastRate(evt:MouseEvent): void {

stage.frameRate = 40;

}

function multipleRate(evt:MouseEvent):void {

if (stage.frameRate == 12) {

trace(stage.frameRate = 24);

}

else if (stage.frameRate == 24){
trace(stage.frameRate = 36);
}

else if (stage.frameRate == 36)
{trace(stage.frameRate = 6);

}

else if (stage.frameRate == 6)
{trace(stage.frameRate = 12);

}
}

 

-----------

The following code is for the file titled "SlideShow" to be placed on the top key frame of the main timeline:

 

PrevButton.addEventListener(MouseEvent.MOUSE_DOWN, moveToPrevSlide);
NextButton.addEventListener(MouseEvent.MOUSE_DOWN, moveToNextSlide);

function

moveToNextSlide(evt:MouseEvent): void {

slides.nextFrame();
slides.alpha(-50);
}

function

moveToPrevSlide(evt:MouseEvent): void {

slides.prevFrame();
}

 

-----------

The following code is to load an xml list into flash:

var xmlLoader:URLLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
xmlLoader.load(new URLRequest("playlistXML.xml"));

function xmlLoaded(event:Event):void {
var playlistXML:XML = new XML(event.target.data);
var item:XML;
for each(item in playlistXML.videoname) {
trace("item: "+item.attribute("flvurl").toXMLString());
myPlayList.addItem({label:item.attribute("desc").toXMLString(), data:item.attribute("flvurl").toXMLString()});

}

------------

The following code is to load an html page into flash:

var urRequest: URLRequest = new URLRequest ('yourPage.html');
var ulLoader: URLLoader = new URLLoader();

var tfDisplay: TextField = new TextField();
tfDisplay.x = 0;
tfDisplay.y = 0;
tfDisplay.width = 500;
tfDisplay.height = 800;
tfDisplay.wordWrap = true;
tfDisplay.border = true;

ulLoader.addEventListener(IOErrorEvent.IO_ERROR, loaderErrorHandler);
//ulLoader.addEventListener(ProgressEvent.PROGRESS, loaderProgressHandler);
ulLoader.addEventListener(Event.COMPLETE, loaderCompleteHandler);

ulLoader.load(urRequest);
addChild(tfDisplay);

 

function
loaderErrorHandler(evt:IOErrorEvent):void {

tfDisplay.htmlText = 'Content has failed to load. Please try again.';


}



/*function
loaderProgressHandler(evt:ProgressEvent):void {
var bLoaded:Number = evt.target.bytesLoaded;
var bTotal: Number = evt.target.bytesTotal;
trace(bLoaded + '/' + bTotal + ' has loaded');


}
*/

function
loaderCompleteHandler(evt:Event): void {

tfDisplay.htmlText = evt.target.data;



}