/ Published in: ActionScript
Expand |
Embed | Plain Text
/* * _scrollmc( mc:MovieClip, mask:MovieClip ) * * Rend un clip scrollable comme un champ texte * * 01/06/05 - Philippe * */ _global._scrollmc = function(mc, mask, scroll_track, scroll_bar) { trace(mc+", "+mask); // evenements ASBroadcaster.initialize(mc); // proprietes mc.setMask(mask); mc.mask = mask; mc.oy = mc._y; mc.scroll = 1; mc.bottomScroll = mask._height; mc.maxscroll = mc._height-mask._height; mc.scroll_track = scroll_track; mc.scroll_bar = scroll_bar; scroll_bar.oy = scroll_bar._y; scroll_bar._height = (scroll_track._height * mask._height) / mc._height; //*********************** scroll avec la bar scroll_bar.mc = mc; scroll_bar.scroll_track = scroll_track; scroll_bar.scroll_bar = scroll_bar; scroll_bar.onRelease = function(){ delete this.onEnterFrame; } scroll_bar.onReleaseOutside = scroll_bar.onRelease; scroll_bar.onPress = function(){ this.mouse_oy = _root._ymouse - this._y; trace(this.mouse_oy); scroll_bar.onEnterFrame = function(){ this._y += ( Math.min(Math.max(_root._ymouse-this.mouse_oy, this.scroll_track._y) , this.scroll_track._y + this.scroll_track._height - this._height) - this._y ) * .5; var new_scroll = ((this._y - this.scroll_bar.oy) * this.mc.maxscroll) / (this.scroll_track._height-this._height); this.mc.scroll = new_scroll; } } // reactivite de la propriete scroll mc.addProperty("scroll", function() { return Math.min( Math.max(1,this.scroll), this.maxscroll); }, function(value) { // verification valeur value = Math.round(value); value = Math.min( Math.max(1,value), this.maxscroll); if (value == this.scroll) return; // maj this.scroll = value; // scrollbar var new_scroll_bar_y = this.scroll_bar.oy + Math.round(this.scroll * (this.scroll_track._height-this.scroll_bar._height) / this.maxscroll); this.scroll_bar._y = new_scroll_bar_y; // /scrollbar this._y = this.oy-value; this.maxscroll = Math.max(1, this._height+4 - this.mask._height); this.bottomScroll = value + this.mask._height; this._y = this.oy-value; // retour this.broadcastMessage("onScroller", this); } ) trace(mc.scroll+" "+mc.maxscroll); }
You need to login to post a comment.
