-
remove XML loaded items
Hi everybody, I hope you all had a great Christmas
I have a small problem and hope somebody could guide me
Here is the code for the XML
PHP Code:
videosXML.onLoad = function(loaded) {
if (loaded) {
var linknameVid:Array = this.firstChild.childNodes;
for (n=0; n<linknameVid.length; n++) {
videoThumb.push(linknameVid[n].childNodes[0].firstChild.nodeValue);
videoTitle.push(linknameVid[n].childNodes[1].firstChild.nodeValue);
videoCopy.push(linknameVid[n].childNodes[2].firstChild.nodeValue);
videoInfo.push(linknameVid[n].childNodes[3].firstChild.nodeValue);
loadvideo.push(linknameVid[n].childNodes[4].attributes.video);
loadimage.push(linknameVid[n].childNodes[4].attributes.image);
videoWidth.push(linknameVid[n].childNodes[4].attributes.videoWidth);
videoHeight.push(linknameVid[n].childNodes[4].attributes.videoHeight);
video_menu.attachMovie("videos_btn","vdb"+n, video_menu.getNextHighestDepth());
//positioning the thumbnails
video_menu["vdb"+n]._y = sPosY;
video_menu["vdb"+n]._x = sPosX;
sPosX = sPosX+btnWV;
video_menu["vdb"+(n)].video_title.text = (videoTitle[n]);
video_menu["vdb"+(n)].video_copy.text = (videoCopy[n]);
}
} else {
trace("error");
}
}
What code should I add to a button to remove the ["vdb"+n] items that are attached to the video_menu empty movieclip (that were attached in the XML onLoad function)?
Thank you so much, and a HAPPY NEW YEAR
-
FK'n_dog
PHP Code:
// create the array outside of the function to open the scope -
linknameVid = new Array();
videosXML.onLoad = function(loaded) {
if (loaded) {
linknameVid = this.firstChild.childNodes;
len = linknameVid.length; // create len variable
for (var n=0; n<len; n++) {
.....<rest of code>........
};
// to remove the attached clips -
someButton.onRelease = function(){
for (var n=0; n<len; n++) {
video_menu["vdb"+n].removeMovieClip();
}
};
-
Hi a_modified_dog and thanks so much for answering. Your code works great, but unfortunately doesn't work the way I planned. here is why:
I have some other XML buttons that act like categories, that will load an XML file in the videosXML, wich is contained in a mc called video_container, like shown below:
PHP Code:
function categoryReleased () {
var currentBut:String = this._name;
currentCat = currentBut.substr(3, 5);
_parent.video_container.videosXML.load(loadCategory[currentCat])
}
So if I press a category button the first time, an XML is loaded normally in the videosXML, but if I press another button to choose another category, everything screws up, because I use the attachMovie method. So I thought that by removing the movieclips created by the videosXML.onLoad, everything will work fine, but it doesn't . Do you have any idea what I could do? Basically I want to achieve this: when I press a category button, the videosXML will reload with the new items, and remove the rest of the items. Thanks
-
FK'n_dog
what is the result of the traces ?
PHP Code:
function categoryReleased () {
var currentBut:String = this._name;
trace(currentBut);
currentCat = currentBut.substr(3, 5);
trace(currentCat);
trace(loadCategory[currentCat]);
_parent.video_container.videosXML.load(loadCategory[currentCat])
}
-
trace:
PHP Code:
ctb1
1
artists/artistOne/chapterTwo/videos.xml
The XML code is correct, that's not the problem. The thing is that if I attach the first time
PHP Code:
video_menu.attachMovie("videos_btn","vdb"+n, video_menu.getNextHighestDepth());
the next time I load another category the buttons are attached like crap, that's why I was trying to remove the existing buttons first. But it doesn't work at all when I do that, meaning nothing gets attached is I remove the existing buttons first. I worked this problem out, but in a very unprofessional way .
I added two extra keyframes in the video_container (the second keyframe is labelled "test" and the third keyframe has a gotoAndStop(1) actions), and I wrote this code in the categoryReleased function:
PHP Code:
_parent.video_container.gotoAndPlay("test")
_parent.video_container.onEnterFrame = function () {
if(_parent.video_container._currentframe==1){
delete _parent.video_container.onEnterFrame
_parent.video_container.videosXML.load(loadCategory[currentCat])
}
}
It works,however, I would like a more professional aproach . Do you have any ideas? Thanks modified
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|