That's still a pretty tall order. Here's an example.
Sample XML data source (filename: myData.xml):
Code:
<portfolio>
<item id="1" title="Web Site 1" imageURL="images/site1.jpg" url="images/site1.gif" summary="This is a summary of site 1" />
<item id="2" title="Web Site 2" imageURL="images/site2.jpg" url="images/site2.gif" summary="This is a summary of site 2" />
<item id="3" title="Web Site 3" imageURL="images/site3.jpg" url="images/site3.gif" summary="This is a summary of site 3" />
</portfolio>
Create a 2 frame Flash movie. Save it in the same directory as the myData.xml file. Create an image directory and create 3 jpeg images (site1-3.jpg) and save them to the images directory.
In the Flash movie drag an XML Connector and a DataSet to the stage. Name the instance of the Connector "data_con" and the dataSet "data_ds".
Select the XML Connector. Open the component inspector. Set the data source to "myData.xml". Click on the Schema tab and select the import option (the little paper like icon top right). Then select your myData.xml file to import the schema from the xml document. This is very handy! Make sure you double check the data types. (should be id:integer,imageURL:string,summary:String,title:Sring,url:string)
Next: Select the data set. In the component inspector click on Schema. Here you will have to match the items that you just imported to the connector. Click on the plus sign to add them. Match the name of the item and the datatype so they are the same as the connector schema. (should be id:integer,imageURL:string,summary:String,title:Sring,url:string)
With the data set still selected click on Bindings in the component inspector. Click the + sign to add a binding. Select the XML Connector from the list on the left and "item:Array" from the list on the right. Now the Connector will populate the data set.
Now add a new layer "actions" to the main timeline of the Flash movie. (key frames on frame 1 and 2)
In the first frame of "actions":
Code:
//trigger the xml Connection
_root.data_con.trigger();
//Listener to prevent movie from going to second frame before the XML data is loaded.
dataListener = new Object();
dataListener.afterLoaded = function(){
gotoAndPlay(2);
}
//assign the listener to the dataset
_root.data_ds.addEventListener("afterLoaded",dataListener);
stop();
This triggers the data source and adds the listener which tell it to go forward once the data is loaded.
Next create a new movie clip called targetClip (click + in library window). Inside targetClip place 3 dynamic text boxes. Set the var values to "title","url", & "summary". Create another (empty) MC called "imageTarget" and place it in the targetClip stage. Give it the instance name "imageTarget".
Add an "actions" targetClip MC. Insert the following:
Code:
loadMovie(this.imageURL,"imageTarget");
Right click on the targetClip in the Library and select properties. Click on advanced and check the box that says "export for actionscript".
Now return to the main timline (click on Scene 1).
In frame 2 of the "actions" layer add:
Code:
//goto first data set record
_root.data_ds.first();
addMovieClips(0);
function addMovieClips(i) {
//loop through data and create a new instance of the targetClip for each record.
while (_root.data_ds.hasNext()) {
//trace("called else");
attachMovie("targetClip", "site"+i, getNextHighestDepth(), _root.data_ds.currentItem);
_root["site"+i]._y = _root["site"+i]._y+(i*100);
i++;
_root.data_ds.next();//this is important don't leave it out or the script will bomb.
}
}
stop();
Now test your movie. What you should get (if I've explained it correctly) is a vertical list of 3 "targetClips" with the images that you placed in your image directory and the info related to each item in the XML file.
Note: It is not necessary to drag the targetClip MC to the stage.
Phew...
Let me know how it goes!
Wow JT that almost looked like you knew what you were doing!