| stop(); System.useCodepage = true;
//useage: //you can modify the fellow code: var easing = true;//true or false mean easing or not. var auto = false;//true or false mean autoscroll or not var mouseWheel = true;//true or fale mean support mousewheel or not. var mouseCoord = true;//true or false mean use mouse coordinates or not. var barVisual = true;//when useing mouse Coordinates you can set scroll bar hid or not. false mean hid.Note:If you //didn't use mouse coordinates and set barVisual = false.you will only use mouseWheel scroll //content. var space = 5;//between list item space . var path = "list1.xml";//xml path contentMain.createEmptyMovieClip("back_mc", this.getNextHighestDepth()); contentMain.setMask(maskedView); var myxml = new XML(); myxml.ignoreWhite = true; myxml.onLoad = function(success) { var item = this.firstChild.childNodes; trace(this.firstChild.firstChild.attributes.videotitle); if (success) { for (var i:Number = 0; i<item.length; i++) { var temp_mc = contentMain.attachMovie("item", "item"+i, i); temp_mc._y += i*(temp_mc._height+space); contentMain.back_mc._height = i*(temp_mc._height+space); temp_mc.tname = item[i].attributes.name; temp_mc.tlink = item[i].attributes.link; temp_mc.videotitle =item[i].attributes.videotitle; temp_mc.thumb = item[i].firstChild.firstChild.nodeValue; temp_mc.item_txt.text = temp_mc.tname; temp_mc.item_thumb.loadMovie(temp_mc.thumb); contentHolder_mc.contentinfo.htmlText = item[0].childNodes[1].firstChild.nodeValue; temp_mc.onRelease = function() { vtitle_txt.text = this.videotitle; playBut.onRelease(); videoDisplay.setMedia(this.tlink,"FLV"); }; } //first video and title vtitle_txt.text = this.firstChild.firstChild.attributes.videotitle; videoDisplay.setMedia(this.firstChild.firstChild.attributes.link,"FLV"); scrolling(easing, auto, mouseWheel, mouseCoord, barVisual); } else { trace("error"); } }; myxml.load(path);
function scrolling(easing, auto, mouse) { //you can modify scroll speed. var moveSpeed = 1; //you can modify easing speed. var easingSpeed = 20; var scrollHeight = scrollbg._height; //you donnot need modify the fellowing code.if you are a AS coder you can do . var scrollable = contentMain._height-maskedView._height+2; var top_scroll = contentMain._y; var left = scrollbg._x-2; var top = scrollbg._y; var right = scrollbg._x-2; var bottom = scrollbg._y+scrollbg._height-dragger._height; if (scrollable<0) { dragger._visible = false; btnup._alpha = 0; btndown._alpha = 0; scrollbg._alpha = 0; btnup.enabled = false; btndown.enabled = false; return; } //update scroll content. function updateContentPos() { var percent_scrolled = (dragger._y-btnup._y-btnup._height)/(scrollHeight-dragger._height); contentMain.newY = Math.round(top_scroll-(scrollable*percent_scrolled)); trace(contentMain.newY); } contentMain.onEnterFrame = function() { if (!easing || easing == undefined) { this._y = this.newY; } else { this._y += (this.newY-this._y)/easingSpeed; } }; //dragger function dragger.onPress = function() { startDrag(this, false, left, top, right, bottom); this.onMouseMove = function() { updateContentPos(); }; }; dragger.onRelease = dragger.onReleaseOutside=function () { stopDrag(); delete this.onEnterFrame; }; btnup.onPress = function() { this.onEnterFrame = function() { dragger._y = Math.max(top, dragger._y-moveSpeed); updateContentPos(); }; }; btnup.onRelease = function() { delete this.onEnterFrame; }; btndown.onPress = function() { this.onEnterFrame = function() { dragger._y = Math.min(bottom, dragger._y+moveSpeed); updateContentPos(); }; }; btndown.onRelease = function() { delete this.onEnterFrame; }; updateContentPos(); //++++++++++++++++++++++++++++++++++++++++++ //AutoScroll code if (auto == true) { onEnterFrame = function () { if (dragger._y<bottom) { dragger._y = dragger._y+0.3; updateContentPos(); } else { dragger._y = top; } }; } //+++++++++++++++++++++++++++++++++++++++++++ //mouseWheel code if (mouseWheel == true) { var mouseListener = new Object(); mouseListener.onMouseWheel = function(delta) { if (dragger._y<bottom) { dragger._y += delta+3; updateContentPos(); } else { dragger._y = bottom-3; } if (dragger._y>top) { dragger._y += delta; updateContentPos(); } else { dragger._y = top; } }; Mouse.addListener(mouseListener); } //++++++++++++++++++++++++++++++++++++++++++++ //Mouse coordinate if (mouseCoord == true) { maskedView.onEnterFrame = function() { //trace(this.hitTest(_xmouse, _ymouse, false)); if (this.hitTest(_xmouse, _ymouse, false)) { dragger._y = _ymouse; updateContentPos(); if (dragger._y>bottom) { dragger._y = bottom; updateContentPos(); } } }; } //+++++++++++++++++++++++++++++++++++++++++++ //scroll bar hid setup if (barVisual == false) { dragger._visible = false; btnup._alpha = 0; btndown._alpha = 0; scrollbg._alpha = 0; btnup.enabled = false; btndown.enabled = false; } //+++++++++++++++++++++++++++++++++++++++++++ }
|
|