What I am aiming for is one movieclip in flash to duplicate depending on how many images are declared in xml and display them like a grid. But I have no idea how to do this. Here is an example of the XML file.
do you already have a movieClip on the stage you want duplicated? or are you saying you just want to load in the XML..and depending on ow many image names/nodes you have..you want to display each image in the XML in a 'grid' (row/column) pattern?
var myXML:XML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function(){
//parse XML data:
var imagesNode = myXML.firstChild;
var totalImages = myXML.firstChild.childNodes.length;
for(i=0; i<totalImages; i++){
var imgNode = imagesNode.childNodes[i].childNodes[0].firstChild.nodeValue;
var textNode = imagesNode.childNodes[i].childNodes[1].firstChild.nodeValue;
trace("test: "+imgNode);
trace("test: "+textNode);
//attatch template clips to hold images & text
var newClip = _root.attachMovie("templateClip", "templateClip"+i, _root.getNextHighestDepth());
//Define the grid columns (in number of cells);
var columns:Number = 4;
//Define the item hSpacing;
var hSpacing:Number = 10;
//Define the item hSpacing;
var vSpacing:Number = 10;
Whispers, I've been going over your solution here. I have figured out how it works and appreciate the explanation. I am looking to build a grid of images as a landing effect. Difference is that I want each image to tween in randomly to build the grid. Then be able to control the fade out of groups of image to show navigation.
I my mind I would have to apply the tween (i am trying to use Fuse) where you commented the template clip is populated.
1. Like and interstitial. When you enter site I want the entire stage(which will float center in HTML) to fill with individual images (small thumbs). Random would be great, but not sure if that will enhance the design.
2. When they appear they fade in rather than just pop on stage.
3. Once on stage you have the grid. my nav panels will be two verticle rectangular bars on the left and right of the stage. After the images all appear on stage, count 3 secs. or so and three rows on each side fade out and the nav will appear over that.
Don't have a comp mach-up now but can make it. Does that help.
I really want to get a better understanding of presenting information in thie sense. I guess it is an array issue.. I see a need for this function in a lot of future work I will go after. So to say, I really want to understand the process and not duplicate it! I appreciated above solution and commenting in the as!
Hi,
1. Yes, Say I have a bunch of images in a folder that is pointed to by XMl. I want to randomly populate that grid space. Not by row one, then two, etc.
Interstitial mean between. Like a landing page that has the old"you need flash to view this site". I will have a landing interstitial that has the getFlash thingy, view site and view iphone version.
Not sure how many thumbs yet. Let's just call it 800 x 500 for the sake of argument.
I know this thread has been inactive for quite some time... but I have been searching for an answer to this problem for weeks! So thank you Whispers for providing that solution... you saved my bacon!
However, i now have a new problem. I am loading my swf with the grid of images into another swf using the LoadMovie function... but for some reason its not showing up. Static text and other stuff shows up but not the dynamically loaded images....
yep put this._lockroot = true; in the external swf in the first frame right at the beginning..that should sort your issue out.. if it's not already sorted
Thanks for whispers who put out the code.
I was working on this as well.
By the way, I am new here. but I checked out the forum some times if I could not figure this out by myself. But here now.. I am asking for some help.
I would like to click on a "newClip" and see some addition information.
let me post the actionscript code.
Code:
var myXML:XML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function(){
//parse XML data:
var imagesNode = myXML.firstChild;
var totalImages = myXML.firstChild.childNodes.length;
var i:Number;
for(i=0; i<totalImages; i++){
var imgNode = imagesNode.childNodes[i].childNodes[0].firstChild.nodeValue;
var textNode = imagesNode.childNodes[i].childNodes[1].firstChild.nodeValue;
trace("test: "+imgNode);
trace("test: "+textNode);
//attatch template clips to hold images & text
var newClip = _root.attachMovie("templateClip", "templateClip"+i, _root.getNextHighestDepth());
var contentClip = _root.attachMovie("content", "content"+i, _root.getNextHighestDepth());
//Define the grid columns (in number of cells);
var columns:Number = 4;
//Define the item hSpacing;
var hSpacing:Number = 10;
//Define the item hSpacing;
var vSpacing:Number = 10;
//position clip
newClip._x = 10;
newClip._y = 10;
newClip._x += ((i % columns)) * (newClip._width + hSpacing);
newClip._y += Math.floor(i / columns) * (newClip._height + vSpacing);
contentClip._y = Stage.height/2;
contentClip._x = Stage.width/2;
contentClip._visible = false;
//populate template clip
newClip.textField_txt.text = textNode;
newClip.imageHolder.loadMovie(imgNode);
newClip.onRelease = function () {
contentClip._visible = true;
contentClip.tekst.text = textNode;
}
contentClip.onRelease = function () {
this._visible = false;
}
}
}
myXML.load("data.xml");
* I have made a new movieclip with a id called "content" with a dynamic textfield called "tekst".
As you can see I have changed minor things to make this newClip clickable.
But it seems that the text showed up in the contentClip will always be the last text what the textNode will be displaying.
I would like to be able when I click on a newClip, the text of that newClip will be shown and not the last text of the xml file.