Hey everybody, I’m having trouble grasping the clone() concept. From my code below, I am loading pictures from an XML file to random locations on the stage, and I plan on having them slightly rotated at random intervals, but they become all pixelated. I read somewhere that I will need to clone each movie clip and then remove the originals so I can set a higher quality to the pictures. As you can see, i got as far as importing the BitmapData class before hitting a wall Would anyone be able to take a second and give me a rundown on how to clone each of the movieclips that become loaded please? I would greatly appreciate it. Thanks!
import mx.transitions.Tween;
import mx.transitions.easing.*;
import flash.display.BitmapData;
var i:Number;
function loadXML(loaded) {
var singleNodes:Array = new Array();//Array to hold the different nodes
if (loaded) {
var xmlNode = this.firstChild;
var menuItems = xmlNode.childNodes;
var smallPics:Array = new Array();
for (i=0; i<=menuItems.length-1; i++) {
var menuTitles = xmlNode.childNodes*.attributes.titles;
smallPics.push(xmlNode.childNodes*.childNodes*.attributes.small);
singleNodes.push(xmlNode.childNodes*);//Add node to singleNodes
attachButtons();
_root["button"+i].name_txt.text = menuTitles;
_root["button"+i].onRollOver = onButtonRollOver;
_root["button"+i].onRollOut = onButtonRollOut;
_root["button"+i].i = i;//Property called i
_root["button"+i].onRelease = function() {
for (j=0; j<=singleNodes[this.i].childNodes.length-1; j++) {//Length for each one
_root.createEmptyMovieClip("pictureHolder"+j, _root.getNextHighestDepth()+10);
_root["pictureHolder"+j]._x = randRange(300, 800)
_root["pictureHolder"+j]._y = randRange(0, 500)
_root["pictureHolder"+j]._highquality = 2;
_root["pictureHolder"+j]._rotation = randRange(-10, 10)
_root["pictureHolder"+j].loadMovie(singleNodes[this.i].childNodes[j].attributes.small);
}
};
}
} else {
trace("file not loaded!");
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("menu.xml");
function attachButtons() {
attachMovie("button","button"+i,i,{_x:0, _y:(i*20)+50});
}
function onButtonRollOver() {
var tw:Tween = new Tween(this.name_txt, "_x", Strong.easeOut, this.name_txt._x, 20, 0.5, true);
var tw2:Tween = new Tween(this.button_bg, "_alpha", Strong.easeOut, this.button_bg._alpha, 100, 0.5, true);
}
function onButtonRollOut() {
var tw:Tween = new Tween(this.name_txt, "_x", Strong.easeOut, this.name_txt._x, 9, 0.5, true);
var tw2:Tween = new Tween(this.button_bg, "_alpha", Strong.easeOut, this.button_bg._alpha, 60, 0.5, true);
}
function randRange(min:Number, max:Number):Number {
var randomNum:Number = Math.round(Math.random() * (max-min+1) + (min-.5));
return randomNum;
}