home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Twoje Kino Czerwiec 2005
/
TwojeKINO.iso
/
cinema
/
shell.as
< prev
next >
Wrap
Text File
|
2005-02-24
|
11KB
|
459 lines

import com.macromedia.flashvideogallery.*;
var firstFrameExporter:MovieClip;
var cover:MovieClip;
var zIndex:Number = 1;
var xmlFileToLoad:String = "content.xml";
// XML data is stored in the following. These correspond to the top level nodes.
var labels:Object;
var regions:Object;
var sites:Array;
// Number of sites. Used throughout for looping.
var siteCount:Number;
// Store the check boxes in an array for filtering.
var regionCheckBoxArray:Array;
// Number of CheckBoxes for each filter.
var regionCheckBoxCount:Number;
// Listeners for the CheckBoxes.
var checkBoxListener:Object;
// Detail view on the right.
var detailView:MovieClip;
// Assets in the welcome area.
var logo:MovieClip;
var title:TextField;
// Stores all of the thumbs.
var thumbArray:Array;
// Used in Thumb for swapDepths() when mousing over.
var topThumb:MovieClip;
// Bubble RollOver text.
var thumbRolloverText:MovieClip;
// Number of MovieClips to change when viewing/hiding detail.
var mainMovieClipCount:Number;
function init():Void
{
firstFrameExporter.unloadMovie();
var contentXML:XML = new XML();
contentXML.ignoreWhite = true;
contentXML["container"] = this; // "Trick" the compiler into adding a dynamic property to the XML object.
// Dot syntax will create a compiler error.
contentXML.onLoad = function(success:Boolean)
{
if (success)
{
this["container"].onXMLLoaded(this);
}
}
contentXML.load(xmlFileToLoad);
}
function onXMLLoaded(contentXML:XML):Void
{
// Parse through the XML.
var node:Object = contentXML.firstChild.firstChild;
while (node != null)
{
switch (node.nodeName)
{
case "naglowki":
labels = xmlNodesToObject(new Object(), node);
break;
case "premiery":
regions = xmlNodesToObject(new Object(), node);
break;
case "filmy":
sites = xmlSiteNodesToArray(node);
break;
}
node = node.nextSibling;
}
siteCount = sites.length;
onXMLParsed();
}
function xmlSiteNodesToArray(node:Object):Array
{
var sites:Array = new Array();
var site:Object;
var siteNode:Object;
var childNode:Object = node.firstChild;
while (childNode != null)
{
// Create a new site Object to store the data.
site = xmlAttributesToObject(new Object(), childNode);
// Store the region and industry IDs in an array for filtering later.
// Regions and industries are attributes in the <site> node.
site.regions = site.data.split(",");
siteNode = childNode.firstChild;
while (siteNode != null)
{
switch (siteNode.nodeName)
{
case "developers":
// Store the developers in an Array of Objects that contain the
// developer URL and title.
site.developers = xmlDeveloperNodesToArray(siteNode);
break;
default:
site[siteNode.nodeName] = siteNode.firstChild.nodeValue;
break;
}
siteNode = siteNode.nextSibling;
}
sites.push(site);
childNode = childNode.nextSibling;
}
return sites;
}
function xmlDeveloperNodesToArray(node:Object):Array
{
var a:Array = new Array();
var childNode:Object = node.firstChild;
while (childNode != null)
{
a.push({url: childNode.attributes.url, title: childNode.firstChild.nodeValue});
childNode = childNode.nextSibling;
}
return a;
}
function xmlAttributesToObject(o:Object, node:Object):Object
{
var a:Object = node.attributes;
for (var i in a)
{
o[i] = a[i];
}
return a;
}
function xmlNodesToObject(o:Object, node:Object):Object
{
var a:Object;
var childNode:Object = node.firstChild;
while (childNode != null)
{
o[childNode.nodeName] = childNode.firstChild.nodeValue;
// This loop is for the URL attribute in the labels.
// Appends the attribute name to nodeName.
a = childNode.attributes;
for (var i in a)
{
o[childNode.nodeName + i] = a[i];
}
childNode = childNode.nextSibling;
}
return o;
}
function xmlNodesToArray(node:XML):Array
{
var a:Array = new Array();
var childNode:Object = node.firstChild;
while (childNode != null)
{
a.push(childNode.firstChild.nodeValue);
childNode = childNode.nextSibling;
}
return a;
}
// Called after the shell and XML has been loaded and parsed.
function onXMLParsed():Void
{
detailView.swapDepths(9);
// Set the global styles for the components.
_global.style.setStyle("fontSize", 10);
_global.style.setStyle("fontFamily" , "verdana");
_global.style.setStyle("color", 0xFFFFFF);
globalStyleFormat.textFont = "verdana";
globalStyleFormat.textSize = 11;
globalStyleFormat.selection = 0xCC3300;
globalStyleFormat.scrollTrack = 0x666666;
globalStyleFormat.face = 0x999999;
globalStyleFormat.darkshadow = 0x000000;
globalStyleFormat.shadow = 0x909090;
globalStyleFormat.background = 0x4A99D3;
globalStyleFormat.highlight = 0x666666;
globalStyleFormat.highlight3D = 0x4D4D4D;
globalStyleFormat.applyChanges();
// Set the text fields.
title.autoSize = "left";
title.htmlText = "<b>"+labels.title+"</b>";
// Create the listener objects for the CheckBoxes and the RadioButtons.
checkBoxListener = new Object();
checkBoxListener.container = this;
checkBoxListener.click = function(o:Object)
{
this.container.onClick_checkBox(o.target);
}
// Set the beginning coordinates of the CheckBoxes.
var checkBoxYBegin:Number = 150;
var checkBoxXBegin:Number = 30;
var checkBoxWidth:Number = 110;
var checkBoxHeight:Number = 22;
// Number of checkboxes per row.
var checkBoxesPerRow:Number = 4;
// Horizontal spacing between each checkboxes.
var xSpacing:Number = 110;
var ySpacing:Number = 20;
var checkBox, deltaX;
regionCheckBoxArray = new Array();
j = 0;
for (var i in regions)
{
deltaX = j - Math.floor(j / checkBoxesPerRow) * checkBoxesPerRow;
checkBox = attachMovie("CheckBox", "checkBox" + zIndex++, zIndex,
{_x: deltaX * (xSpacing) + checkBoxXBegin, _y: Math.floor(j / checkBoxesPerRow) * (ySpacing) + checkBoxYBegin});
checkBox.label = " " + regions[i]; // This is to add spacing. Tried using textIndent but the end
// gets truncated. The spaces are removed below when filtering.
checkBox.addEventListener("click", checkBoxListener);
checkBox.setSize(checkBoxWidth, checkBoxHeight);
checkBox.data = {id: i, filter: "region"};
checkBox.selected = true;
checkBox._visible = true; // Turn off the region CheckBoxes since industry is selected first.
regionCheckBoxArray.push(checkBox);
// Set the "view all" check box. This is used later for filtering.
if (i == "viewAll") viewAllRegionCheckBox = checkBox;
j++;
}
regionCheckBoxCount = regionCheckBoxArray.length;
// Add the thumbs. ---------------------------------
var thumb;
var thumbXBegin:Number = 63;
var thumbYBegin:Number = 237;
var thumbsPerRow = 6;
xSpacing = 6;
ySpacing = 6;
createEmptyMovieClip("ikony",10);
thumbArray = new Array();
//CB.addItem("");
for (var i = 0; i < siteCount; i++)
{
deltaX = i - Math.floor(i / thumbsPerRow) * thumbsPerRow;
thumb = ikony.attachMovie("thumb", "thumb" + i, zIndex++,
{_x: deltaX * (thumb._width + xSpacing) + thumbXBegin,
_y: Math.floor(i / thumbsPerRow) * (thumb._height + ySpacing) + thumbYBegin});
thumb.setData(i, sites[i]);
thumbArray.push(thumb);
CB.addItem(sites[i].title,i); trace("dodaje "+i+" "+sites[i].title);
}
//CB.sortItemsBy("label", "ASC");
_root.CB.onPress();
_global.topThumb = thumb;
// Move the rollover text to the top.
thumbRolloverText.swapDepths(11);
// Set the labels in the detailView.
detailView.setLabels(labels, siteCount);
showDetail(ikony.thumb0);
cover.unloadMovie();
}
// Filter the thumbs according to industry or region.
function filterBy(filter:String):Void
{
if (this["viewAll" + filter + "CheckBox"].selected)
{
for (var i = 0; i < siteCount; i++) // Set the state of the thumbs.
{
thumbArray[i].setActive(true);
}
}
else
{
var checkBox;
var checkBoxArray:Array = this[filter + "CheckBoxArray"];
var checkBoxCount:Number = checkBoxArray.length;
// Passed to each thumb for filtering.
var checkedArray:Array = new Array();
for (var i = 0; i < checkBoxCount; i++) // Find out which CheckBoxes are checked.
{
checkBox = checkBoxArray[i];
if (checkBox.selected)
{
checkedArray.push(checkBox.data.id);
}
}
for (var i = 0; i < siteCount; i++) // Filter the thumb.
{
thumbArray[i].filterBy(checkedArray, filter);
}
}
}
function onClick_checkBox(cb:MovieClip):Void
{
_root.CB.removeAll(); _root.CB.onPress();
//tt=_root.CB.getLength();trace(tt);
//for (var i = 0; i < tt; i++){ trace(i+" usuwam:"+_root.CB.getItemAt(i).label); }
//_root.CB.addItem("");
//_root.CB.additem(title);
var checkBoxArray:Array = this[cb.data.filter + "CheckBoxArray"];
var checkBoxCount:Number = checkBoxArray.length;
if (cb == viewAllRegionCheckBox || cb == viewAllIndustryCheckBox) // "View all" checkbox was selected.
{
var checkBox;
var isChecked:Boolean = cb.selected;
for (var i = 0; i < checkBoxCount; i++) // Set the state of the checkboxes.
{
checkBoxArray[i].selected = isChecked;
}
for (var i = 0; i < siteCount; i++) // Set the state of the thumbs.
{
thumbArray[i].setActive(isChecked);
if(isChecked) _root.CB.additem(thumbArray[i].title,thumbArray[i].index);
}
}
else
{
var isAllChecked:Boolean = true;
var viewAllCheckBox = this["viewAll" + cb.data.filter + "CheckBox"];
// Check to see if all the CheckBoxes are selected.
for (var i = 0; i < checkBoxCount; i++)
{
if (!checkBoxArray[i].selected && checkBoxArray[i] != viewAllCheckBox)
{
isAllChecked = false;
break;
}
}
// All CheckBoxes are selected so check viewAllCheckBox.
if (isAllChecked)
{
viewAllCheckBox.selected = true;
onClick_checkBox(viewAllCheckBox);
return;
}
// Not all selected so deselect viewAllCheckBox and then filter.
viewAllCheckBox.selected = false;
filterBy(cb.data.filter);
}
}
function showDetail(th:MovieClip)
{ detailView.blysk.play();
detailView.setData(sites[th.index]);
}
function onClose_detail():Void
{
detailView._visible = false;
}
// Used for tracking on Macromedia.com.
function sendOmnitureEvent(s:String):Void
{
var s:String = s.split("'").join(""); // Remove apostrophes.
s = s.split("?").join(""); // Remove question marks.
s = s.split("&").join(""); // Remove ampersands.
}
// Create a global function for the TextLinks.
_global.onRelease_textLink = function(link:MovieClip):Void
{
getURL(link.url, "videoGallery");
}
init();
stop();