![]() |
|
||||||||||
|
|||||||
|
|
« Предыдущая тема | Следующая тема » |
| Опции темы | Опции просмотра |
|
![]() |
![]() |
|
|
|
|||||
|
Banned
Регистрация: Jun 2005
Сообщений: 68
|
Народ, срочно нужна помощь! В AS я не силен, скажу сразу...
Пытался разобраться с тем, как делать скроллы для текстового поля. Набрел в сети на вот такой вот урок _h**p://www.flashteacher.ru/tutorials/scrolling/index.shtml . Принцип описанный там, прост: создается поле, рисуются скроллы (потом их называют up, down и scrollbar в инстанс-нейм), все это загоняется в символ (contairnerMC), который потом выставляется в сцену. Текста берется из текстовика. Довольно просто... Только вот у меня проблема заключается в том, что мой этот созданный символ contairnerMC находится тоже в символе. Код в примере предусматривает использование onClipEvent (а ведь использовать его можно лишь в сцене) ![]() Вот непосредственно код: onClipEvent (load){
this.loadVariables("text.txt");
scrolling = 0;
frameCounter = 1;
speedFactor = 3;
numLines = 7;
origHeight = scrollbar._height;
origX = scrollbar._x;
needInit = false;
function initScrollbar(){
var totalLines = numLines + daTextBox.maxscroll - 1;
scrollbar._yscale = 100*(numLines)/totalLines;
deltaHeight = origHeight - scrollbar._height;
lineHeight = deltaHeight/(daTextBox.maxScroll - 1);
}
function updateScrollBarPos(){
scrollbar._y = lineHeight*(daTextBox.scroll - 1);
}
}
onClipEvent (enterFrame){
if( needInit ){
if(daTextBox.maxscroll > 1){
initScrollbar();
needInit = false;
}
}
if( frameCounter % speedFactor == 0){
if( scrolling == "up" && daTextBox.scroll > 1){
daTextBox.scroll--;
updateScrollBarPos();
}
else if( scrolling == "down" && daTextBox.scroll < daTextBox.maxscroll){
daTextBox.scroll++;
updateScrollBarPos();
}
frameCounter = 0;
}
frameCounter++;
}
onClipEvent (mouseDown){
if(up.hitTest(_root._xmouse,_root._ymouse)){
scrolling = "up";
frameCounter = speedFactor;
up.gotoAndStop(2);
}
if(down.hitTest(_root._xmouse,_root._ymouse)){
scrolling = "down";
frameCounter = speedFactor;
down.gotoAndStop(2);
}
if(scrollbar.hitTest(_root._xmouse,_root._ymouse)){
scrollbar.startDrag(0,origX,deltaHeight,origX);
scrolling = "scrollbar";
}
updateAfterEvent();
}
onClipEvent (mouseUp){
scrolling = 0;
up.gotoAndStop(1);
down.gotoAndStop(1);
stopDrag();
updateAfterEvent();
}
onClipEvent (mouseMove){
if(scrolling == "scrollbar"){
daTextBox.scroll = Math.round((scrollbar._y)/lineHeight + 1);
}
updateAfterEvent();
}
onClipEvent (data){
needInit = true;
}
Последний раз редактировалось iNils; 08.11.2006 в 13:55. |
|
|||||
|
Banned
Регистрация: Jun 2005
Сообщений: 68
|
Неужели ни у кого мыслей не возникло...
|
|
|||||
|
Квач
Регистрация: Sep 2006
Адрес: Украина, Киев
Сообщений: 1,526
|
2 o-mega:
Есть. Использовать обработчики onMouseMove, onMouseDown и т.д.
__________________
Да не нужно тебе читать документацию по Flash и AS от Adobe - ты слишком умён для этого |
|
|||||
|
Modus ponens
|
var _txt:TextField = _root.createTextField("_txt", 0, 5, 5, 200, 200);
with (_txt) {
border = true;
borderColor = 0;
}
var _str:String = "Test text\rTest line\r";
for (i=0; i<5; i++) {
_str += _str+i;
}
_txt.text = _str;
// Поместить в библиотеку клип небольшого размера, присвоить идентификатор экспорта scroller
var scroller:MovieClip = _root.attachMovie("scroller", "scroller", 2, {_x:_root._txt._width+5, _y:5});
scroller.onPress = function() {
if (this.m_y == undefined) {
this.m_y = this._y;
this.n_y = _root._txt._height+_root._txt._y-this._height;
this._step = this.n_y/_root._txt.maxscroll;
}
this.a_y = this._ymouse;
this.onEnterFrame = function() {
this._y += this._ymouse-this.a_y;
if (this._y<this.m_y) {
this._y = this.m_y;
}
if (this._y>this.n_y) {
this._y = this.n_y;
}
_root._txt.scroll = this._y/this._step;
};
};
scroller.onRelease = function(){
delete this.onEnterFrame;
}
scroller.onReleaseOutside = scroller.onRelease;
__________________
Hell is the possibility of sanity |
![]() |
![]() |
Часовой пояс GMT +4, время: 03:12. |
|
|
« Предыдущая тема | Следующая тема » |
|
|