This works:
http://eqube.com/mecca_preview/fp/~try6.html
This doesn’t:
http://solagin.com/temp/frank/work2/~try6.html
These files are identical.
The only difference is the server they’re hosted on. I didn’t realize Flash could suffer from these kinds of problems. This movie clip uses three classes, and here is the code:
menuItem class (controls the yellow links at the bottom)
class com.menu.MenuItem extends MovieClip
{
var tLabel, onRollOver, onRollOut, _selected, _label, __get__label, _index, __get__index, __get__selected, __set__index, __set__label, __set__selected;
function MenuItem()
{
super();
this.init();
} // End of the function
function init()
{
tLabel.autoSize = true;
onRollOver = ascb.util.Proxy.create(this, over);
onRollOut = ascb.util.Proxy.create(this, out);
} // End of the function
function over()
{
var _loc2 = new TextFormat();
_loc2.size = 12;
_loc2.bold = true;
_loc2.color = 16763904;
tLabel._y = -1;
tLabel.setTextFormat(_loc2);
} // End of the function
function out()
{
if (!_selected)
{
var _loc2 = new TextFormat();
_loc2.size = 11;
_loc2.bold = false;
_loc2.color = 16777215;
tLabel._y = 0;
tLabel.setTextFormat(_loc2);
} // end if
} // End of the function
function set label($label)
{
_label = $label;
tLabel.text = $label;
null;
//return (this.label());
null;
} // End of the function
function set index($index)
{
_index = $index;
null;
//return (this.index());
null;
} // End of the function
function get index()
{
return (_index);
} // End of the function
function set selected($state)
{
var _loc2 = new TextFormat();
if ($state)
{
_loc2.size = 12;
_loc2.bold = true;
_loc2.color = 16763904;
tLabel._y = -1;
}
else
{
_loc2.size = 11;
_loc2.bold = false;
_loc2.color = 16777215;
tLabel._y = 0;
} // end else if
tLabel.setTextFormat(_loc2);
_selected = $state;
null;
//return (this.selected());
null;
} // End of the function
} // End of Class
Menu class (controls the menu transition and loads the XML)
class com.menu.Menu extends MovieClip
{
var xData, createEmptyMovieClip, bgItems, menuBar, attachMovie, arrowLeft, arrowRight, menuItems, selectedIndex, onEnterFrame, bgTween1, bgTween2, getURL, _x;
function Menu()
{
super();
this.init();
} // End of the function
function init()
{
Stage.scaleMode = "noScale";
var _loc2 = new Object();
_loc2.onResize = ascb.util.Proxy.create(this, stageResize);
Stage.addListener(_loc2);
xData = new XML();
xData.ignoreWhite = true;
xData.onLoad = ascb.util.Proxy.create(this, xDataLoad);
xData.load("menuData.xml");
} // End of the function
function xDataLoad()
{
this.generateMenu();
} // End of the function
function generateMenu()
{
bgItems = this.createEmptyMovieClip("bgItems", 1);
menuBar = this.createEmptyMovieClip("menuBar", 2);
menuBar.beginFill(0, 70);
menuBar.lineTo(710, 0);
menuBar.lineTo(710, 30);
menuBar.lineTo(0, 30);
menuBar.lineTo(0, 0);
menuBar._y = 210;
arrowLeft = this.attachMovie("ArrowLeft", "arrowLeft", 3);
arrowRight = this.attachMovie("ArrowRight", "arrowRight", 4);
arrowLeft._y = 225;
arrowRight._y = 225;
arrowLeft.onRelease = ascb.util.Proxy.create(this, arrowLeftRelease);
arrowRight.onRelease = ascb.util.Proxy.create(this, arrowRightRelease);
menuItems = this.createEmptyMovieClip("menuItems", 5);
menuItems._y = 217;
var _loc4 = xData.firstChild.childNodes;
var _loc6 = _loc4.length;
for (var _loc3 = 0; _loc3 < _loc6; ++_loc3)
{
var _loc5 = menuItems.attachMovie("MenuItem", "menuItem" + _loc3, _loc3);
_loc5.label = _loc4[_loc3].childNodes[0].firstChild.nodeValue;
_loc5.index = _loc3;
_loc5.onRelease = ascb.util.Proxy.create(this, menuItemRelease, _loc5);
var _loc2 = bgItems.attachMovie("BgItem", "bgItem" + _loc3, _loc6 - _loc3);
_loc2.bg.loadMovie(_loc4[_loc3].attributes.bgImage);
_loc2.tCitat.autoSize = true;
_loc2.tCitat.text = _loc4[_loc3].childNodes[1].firstChild.nodeValue;
_loc2.link._y = _loc2.tCitat._y + _loc2.tCitat._height + 4;
_loc2.link.tLink.autoSize = true;
_loc2.link.tLink.text = _loc4[_loc3].childNodes[2].firstChild.nodeValue;
_loc2.link.linkURL = _loc4[_loc3].childNodes[2].attributes.link;
_loc2.mainlink.linkURL = _loc4[_loc3].childNodes[2].attributes.link;
_loc2.link.linkWindow = _loc4[_loc3].childNodes[2].attributes.window;
_loc2.mainlink.linkWindow = _loc4[_loc3].childNodes[2].attributes.window;
_loc2.link.onRelease = ascb.util.Proxy.create(this, linkRelease, _loc2.link);
_loc2.mainlink.onRelease = ascb.util.Proxy.create(this, linkRelease2, _loc2.mainlink);
_loc2._visible = false;
} // end of for
selectedIndex = Number(xData.firstChild.attributes.selected);
trace (selectedIndex);
if (selectedIndex < 0 || selectedIndex > _loc6 - 1)
{
//selectedIndex = Math.floor(Math.random() * _loc6);
selectedIndex = Math.floor(Math.random());
} // end if
trace (selectedIndex);
bgItems["bgItem" + selectedIndex]._visible = true;
menuItems["menuItem" + selectedIndex].selected = true;
this.fitToWidth();
onEnterFrame = ascb.util.Proxy.create(this, thisEnterFrame);
} // End of the function
function menuItemRelease(menuItem)
{
this.changeTo(menuItem.index);
trace ("GUG " + menuItem.index);
} // End of the function
function changeTo(to)
{
trace ("--> " + to);
var _loc4 = selectedIndex;
selectedIndex = to;
trace (to);
menuItems["menuItem" + _loc4].selected = false;
menuItems["menuItem" + selectedIndex].selected = true;
var _loc3 = bgItems["bgItem" + _loc4];
var _loc2 = bgItems["bgItem" + selectedIndex];
this.showOnly(_loc2, _loc3);
var _loc7 = 240;
var _loc5 = 0;
_loc2._y = -240;
_loc3._y = 0;
bgTween1 = new mx.transitions.Tween(_loc3, "_y", mx.transitions.easing.Regular.easeInOut, _loc3._y, _loc7, 5.000000E-001, true);
bgTween2 = new mx.transitions.Tween(_loc2, "_y", mx.transitions.easing.Regular.easeInOut, _loc2._y, _loc5, 5.000000E-001, true);
} // End of the function
function showOnly(one, two)
{
var _loc4 = xData.firstChild.childNodes.length;
for (var _loc3 = 0; _loc3 < _loc4; ++_loc3)
{
var _loc2 = bgItems["bgItem" + _loc3];
if (_loc2 != one && _loc2 != two)
{
_loc2._visible = false;
continue;
} // end if
_loc2._visible = true;
} // end of for
} // End of the function
function thisEnterFrame()
{
var _loc7 = xData.firstChild.childNodes.length;
var _loc8 = 0;
for (var _loc3 = 0; _loc3 < _loc7; ++_loc3)
{
var _loc2 = bgItems["bgItem" + _loc3];
var _loc5 = _loc2.bg.getBytesLoaded();
var _loc6 = _loc2.bg.getBytesTotal();
var _loc4 = _loc5 / _loc6 * 100;
_loc2.preloader.bar._xscale = _loc4;
if (_loc4 == 100 && _loc5 > 100)
{
_loc2.preloader._visible = false;
++_loc8;
} // end if
} // end of for
if (_loc8 == _loc7)
{
delete this.onEnterFrame;
} // end if
} // End of the function
function arrowLeftRelease()
{
var _loc2 = selectedIndex;
--_loc2;
if (_loc2 == -1)
{
_loc2 = xData.firstChild.childNodes.length - 1;
} // end if
this.changeTo(_loc2);
} // End of the function
function arrowRightRelease()
{
var _loc2 = selectedIndex;
++_loc2;
if (_loc2 == xData.firstChild.childNodes.length)
{
_loc2 = 0;
} // end if
this.changeTo(_loc2);
} // End of the function
function linkRelease(link)
{
this.getURL(link.linkURL, link.linkWindow);
} // End of the function
function linkRelease2(mainlink)
{
this.getURL(mainlink.linkURL, mainlink.linkWindow);
} // End of the function
function setTiles(bgTile, image)
{
} // End of the function
function fitToWidth()
{
var _loc6 = Stage.width;
var _loc9 = 65;
var _loc7 = _loc6 - _loc9 * 2;
_x = Math.round(-(_loc6 - 710) / 2);
var _loc5 = xData.firstChild.childNodes.length;
for (var _loc2 = 0; _loc2 < _loc5; ++_loc2)
{
var _loc3 = menuItems["menuItem" + _loc2];
_loc7 = _loc7 - _loc3._width;
} // end of for
_loc7 = _loc7 / (_loc5 - 1);
var _loc8 = _loc9;
for (var _loc2 = 0; _loc2 < _loc5; ++_loc2)
{
_loc3 = menuItems["menuItem" + _loc2];
_loc3._x = Math.round(_loc8);
_loc8 = _loc8 + (_loc3._width + _loc7);
} // end of for
for (var _loc2 = 0; _loc2 < _loc5; ++_loc2)
{
var _loc4 = bgItems["bgItem" + _loc2];
_loc4.bg._x = _loc6 - 710;
_loc4.bgTile._width = _loc6 - 600;
} // end of for
menuBar._width = _loc6;
arrowLeft._x = 20;
arrowRight._x = _loc6 - 20;
} // End of the function
function stageResize()
{
this.fitToWidth();
} // End of the function
function antiCache()
{
var _loc1 = System.capabilities.playerType;
if (_loc1 == "PlugIn" || _loc1 == "ActiveX")
{
return ("?nocache=" + new Date().getTime());
}
else
{
return ("");
} // end else if
} // End of the function
} // End of Class
Proxy class (ascb/util/proxy.as) - used by my predecessor and I’m not sure of its function.
class ascb.util.Proxy
{
function Proxy()
{
} // End of the function
static function create(oTarget, fFunction)
{
var aParameters = new Array();
for (var _loc2 = 2; _loc2 < arguments.length; ++_loc2)
{
aParameters[_loc2 - 2] = arguments[_loc2];
} // end of for
var _loc4 = function ()
{
var _loc2 = arguments.concat(aParameters);
fFunction.apply(oTarget, _loc2);
};
return (_loc4);
} // End of the function
} // End of Class
I’d appreciate any guidance you can give me, especially where you have experienced Flash working differently on different hosting platforms. The working example is IIS, the non-working example is LAMP (linux apache).
This code is AS 2.0 Flash CS3, flash player 8.