I’ve got a small movieclip that reads 5 images, captions, and unique IDs from an XML file. Everytime the movie starts up, the Arrays are populated then randomly sorted. After they are done sorting, an instance of a movieclip containing the image and caption are added to the stage through attachMovie and a for loop.
Through the SWFObject javascript, the values of particular variables are defined then passed to the SWF. If the value of **imgID **is the same as any of the movieclips, its highlighted. When the movie starts up it finds the value of imgID from the HTML and highlights that image. When a movieclip is clicked a javascript function is called, and that movieclip’s unique ID is passed to it.
What I want it to do once a movieclip is clicked is to disable the onRollOver, onRollOut, and onRelease functions for that movieclip and re-enable previous movieclip’s over/out/release functions.
I’ve tried using button.enabled = true/false in loop in the onRelease function, but they stay enabled regardless of what I do. I’ve tried deleting the onRollOut function, but that doesn’t work either.
Can someone point me in the right direction?
#include "mc_tween2.as"
import flash.external.ExternalInterface;
// Opacity of the Black overlay ------------------------------
var overlayOpacity:Number = 50;
// Variable Declarations -------------------------------------
var imgNum:Number;
var imgID:String;
var images:Array = new Array();
var captions:Array = new Array();
var pids:Array = new Array();
var sortRandMap = new Array();
sortRandMap.index = 0;
var mcl:MovieClipLoader = new MovieClipLoader();
var listener:Object = new Object();
var xml:XML = new XML();
var myStage:Object = this;
//var mainColor:String = "0x2a8cbf";
//var strokeColor:String = "0x51b5e9";
var mainColor:String;
var strokeColor:String;
// Color Settings
bg.bgBack.colorTo(mainColor, 0, "linear");
bg.bgStroke.colorTo(strokeColor, 0, "linear");
triangle.colorTo(mainColor, 0, "linear");
bg.grad._alpha = 60;
function shuffle(a, b):Number {
var randNum:Number = Math.floor(Math.random()*2)-1;
trace(randNum);
return randNum;
}
// XML Stuff -------------------------------------------
xml.ignoreWhite = true;
xml.onLoad = function(success) {
if (success) {
var nodes = xml.firstChild.childNodes;
for (var n:Number = 0; n<nodes.length; n++) {
images.push(nodes[n].attributes.src);
captions.push(nodes[n].attributes.cap);
pids.push(nodes[n].attributes.pid);
}
randomizeArrays();
}
}
function randomizeArrays(){
images.sort(sortRand);
captions.sort(sortLastRand);
pids.sort(sortLastRand);
loadImages();
}
// Randomize Array Sorting Functions--------------------------
function sortRand(a, b) {
//var randNum:Number = Math.floor(Math.random()*2)-1;
var randNum = Math.random() - .5;
sortRandMap[sortRandMap.index] = randNum;
sortRandMap.index++;
return randNum;
}
function sortLastRand(a, b) {
if (sortRandMap.index >= sortRandMap.length) {
sortRandMap.index = 0;
}
var randNum = sortRandMap[sortRandMap.index];
sortRandMap.index++;
return randNum;
}
function loadImages(){
for (var i:Number = 0; i < images.length; i++) {
var imgLink:MovieClip = myStage.attachMovie("imgLink", "imgLink"+i, myStage.getNextHighestDepth(), {_x:11 + (i*117), _y:11});
imgLink._alpha = 0;
imgLink.overlay._alpha = overlayOpacity;
imgLink.imgHighlight._alpha = 0;
imgLink.alphaTo(100, .25, "easeOutExpo", .2 * i);
imgLink.titleText.text = captions*;
imgLink.id = pids*;
trace(images*+" -- "+captions*+" -- "+ imgLink.id);
mcl.loadClip(images*, imgLink.imgHolder);
if (imgID == imgLink.id){
triangle.slideTo(imgLink._x + 57, 126, .5, "easeOutExpo");
imgLink.imgHighlight.alphaTo(100, 1, "easeOutExpo");
imgLink.overlay.alphaTo(0, 1.5, "linear");
} else {
imgLink.onRollOver = over;
imgLink.onRollOut = out;
imgLink.onRelease = imgClick;
}
}
}
xml.load("images.xml");
// Button Functions ----------------------------------------------
function over(){
this.overlay.alphaTo(0, .25, "easeOutExpo");
}
function out(){
this.overlay.alphaTo(overlayOpacity, .5, "linear");
}
function imgClick(){
ExternalInterface.call("loadNewPage", this.id);
//getURL("?imgNum="+this.id, "");
for (var z:Number = 0; z < pid.length; z++){
if (imgID == this.id){
//this.enabled = false;
delete this.onRollOut;
} else {
this.onRollOut = out;
//this.enabled = true;
}
}
}