PDA

View Full Version : Is this menu array scrollable ???


Viriato
11-02-2004, 09:22 PM
Hi everyone
I have this array menu wich is loaded from external txt.
the big problem is that I need to put a large number of items, and I have not enough space in the movie to do so. :(

So I think that the best way to do so is by using an scroller effect(rollover, release, doesnt matter)

I've tried a lot of methods, scrollPane, never worked out, even the mask seems to have no effect.

the menu is composed by:
_root.menu.menuItemBase.(labelName+menuButton)
labelName - dynamic text field
menuItemBase - menuButton

I'm newbie in actionscripting. Any help is very welcome

Here's the code I use in the frame:

submenu = "WEBDESIGN";
i = 0;
test1 = new LoadVars();
test1.load("data/menu1.fst");
test1.onLoad = function(success) {
if (success) {
sectionNames = this.nome.split("|");
sectionImages = this.imagem.split("|");
sectionInfo = this.infos.split("|");
sectionCount = sectionNames.length;
sectionCount2 = sectionNames.length-1;
menuItemSpacing = 1;
for (i=1; i<=sectionCount; i++) {
_root.menu.menuItemBase.duplicateMovieClip("menuItem_"+i, i);
_root.menu["menuItem_"+i].labelName = sectionNames[i-1];
_root.menu["menuItem_"+i].labelImage = sectionImages[i-1];
_root.menu["menuItem_"+i].labelInfo = sectionInfo[i-1];
_root.menu.menuItem_1.gotoAndStop("end");
loadMovie("imgs/"+sectionImages[0], _root.img);
_root.infos = sectionInfo[0];
if (i != 1) {
_root.menu["menuItem_"+i]._y = _root.menu["menuItem_"+(i-1)]._y+_root.menu["menuItem_"+(i-1)]._height+menuItemSpacing;
}
}
}
};
_root.menu.menuItemBase._visible = false;
function checkButtons() {
for (i=1; i<=_root.sectionCount; i++) {
currentItem = "menuItem_"+i;
if (currentItem != _root.activeItem) {
_root.menu["menuItem_"+i].gotoAndStop(1);
}
}
}
next_btn.onRelease = function() {
i++;
if (i>sectionCount2) {
i = 0;
}
loadMovie("imgs/"+sectionImages[i], _root.img);
_root.infos = sectionInfo[i];
_root.menu["menuItem_"+i].gotoAndStop(1);
trace(i);
};
prev_btn.onRelease = function() {
i--;
if (i<0) {
i = sectionCount2;
}
loadMovie("imgs/"+sectionImages[i], _root.img);
_root.infos = sectionInfo[i];
trace(i);
};


I'm using MX2004 but FLA saved as MX
Thank's in advance. :)

Viriato
11-03-2004, 04:46 PM
Hi there,
I finally found a simple, but rudimentar, way to scroll the menu. ;)

on the same frame of the script I create a symbol "checkScroll" with this script inside:
onClipEvent (enterFrame) {
if (_root.upHold) {
_root.menu._y += 2;
trace(_root.menu._y);
}
if (_root.downHold) {
_root.menu._y -= 2;
trace(_root.menu._y);
}
}

then made 2 buttons "up_btn" and "down_btn" with this actions:
//up_btn
on (press) {
_root.upHold = true;
}
on (release) {
_root.upHold = false;
}

//down_btn
on (press) {
_root.downHold = true;
}
on (release) {
_root.downHold = false;
}

It really works but it's a blind scroll, only stops when I release the button.

The thing is that I need a stop action when it reaches the end, and won't allow to scroll up in the begining.

Maybe using the sectionCount var with some math is possible, but I've no clue how to do that. :confused:

If there's anybody who can help me out, I would be very apreciated.

I attached the Fla in MX without the images folder.

Viriato
11-04-2004, 11:52 AM
E U R E K A
I've made it
is not much of a scroll but it's working and it was way simple that I thought
Here's what I've made:
onClipEvent (enterFrame) {
//number of items
itemN = _root.sectionNames.length;
//height of one item
itemH = _root.menu.menuItemBase._height;
//height of all menu
menuH = itemN*itemH+itemN;
//scrollable height view
scrollView = 60;
//initial position same of _root.menu._y
iniPos = 146;
//prevent from sroll the last item to the top
areaView = scrollView+iniPos;
//scroll limit of the menu
limit = areaView-menuH;
if (_root.upHold) {
if (_root.menu._y<iniPos) {
_root.menu._y += 2;
} else {
_root.menu._y += 0;
}
}
if (_root.downHold) {
if (_root.menu._y>limit) {
_root.menu._y -= 2;
} else {
_root.menu._y -= 0;
}
}
}
Now no matter how many items I define on the txt it will scroll to bottom
Any comments or improvements are very welcome