Hi all,
I have a .fla that has a load of imgs in an array, each image has its own instance of a mc.
I move the _x coordinates of the holding mc and they all scroll.
You can drag and drop the images onto a canvas and when this is done it will remove the images from the array.
When I scroll it still moves the images on the canvas as it is still part of the holding mc.
AIM: To move only the images contained in the array.
I presume then I will have to avoid moving the holding mc (mc_1) all together but cannot suss out how to move the mc’s created in the buildIconList function as a whole?
Cheers Si
import mx.transitions.easing.*;
import mx.transitions.Tween;
// BUILD DEFAULT TITLES ARRAY
titles = [];
titles.push ("Iola & mum");
titles.push ("Iola & Boo");
titles.push ("Iola by the sea");
titles.push ("Iola & mum again");
titles.push ("Iola & Ba");
titles.push ("page six");
//==================
// STOP THINGS ON PAGE 1
content_mc.stop ();
//==================
//build icons from each img on key frames in icon mc
show = [];
_global.nameOf = new Object ();
function buildIconList () {
var spacing:Number = 100;
var iconY:Number = 280;
var iconX:Number = 60;
//Creates a parent movie clip to hold the container
this.createEmptyMovieClip ("mc_1", 0);
//creates a child movie clip inside of "mc_1"
//this is the movie clip the image will replace
mc_1.attachMovie ("contentmc", "content_mc", 1);
mc_1.content_mc._x = -238;
mc_1.content_mc._y = 860;
mc_1.content_mc.stop ();
mc_1.content_mc._height = 60;
mc_1.content_mc._width = 80;
for (var i = 0; i < mc_1.content_mc._totalframes; ++i) {
var newName:String = "icon_mc" + i;
var clip:MovieClip = mc_1.content_mc.duplicateMovieClip (newName, 10000 + i);
show.push (clip);
clip.gotoAndStop (i + 1);
clip._y = iconY;
clip._x = iconX + i * spacing;
clip.homeX = clip._x;
clip.homeY = clip._y;
clip._alpha = 80;
clip.icon_btn.onPress = function () {
removeImage (this._parent);
startDrag (this._parent);
title_txt.text = titles[this._parent._currentframe - 1];
};
clip.icon_btn.onRollOver = function () {
this._parent._alpha = 100;
this._parent._height = 80;
this._parent._width = 100;
};
clip.icon_btn.onRollOut = function () {
this._parent._alpha = 80;
this._parent._height = 60;
this._parent._width = 80;
};
clip.icon_btn.onRelease = function () {
iconReleased (this._parent);
stopDrag ();
};
}
}
buildIconList ();
//==================
this.createEmptyMovieClip ("menu_mc", 1);
this.menu_mc._x = 10;
this.menu_mc._y = 30;
function move (index:Number, pos:Number):Void {
image_twn = new Tween (this.mc_1, "_x", Regular.easeOut, this.mc_1._x, -(80 * index), 10);
bar_twn = new Tween (this.bar_mc, "_x", Regular.easeOut, this.bar_mc._x, pos, 10);
}
for (i = 0; i < show.length; i++) {
this.menu_mc.attachMovie ("as", "button" + i + "_mc", i);
this.menu_mc["button" + i + "_mc"]._x = 3 + (12 * i);
this.menu_mc["button" + i + "_mc"].index = i;
this.menu_mc["button" + i + "_mc"].onRollOver = function () {
this._parent._parent.move (this.index, this._x + this._parent._x);
};
}
//if mc in the array then move it else don't
//==================
function iconReleased (icon:MovieClip) {
if (eval (icon._droptarget) != _root.canvas_mc) {
icon._x = icon.homeX;
icon._y = icon.homeY;
addImage (icon);
}
trace ('ARRAY: ' + tArray);
}
//==================
var tArray:Array = show.slice ();
//function to remove elements of array
function removeImage (clip) {
for (var j = 0; j <= tArray.length; j++) {
if (clip == tArray[j]) {
tArray.splice (j, 1);
break;
}
}
}
function addImage (clip) {
tArray.push (clip);
tArray.sort ();
}