Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Next/ Previous In Xml Menu Array



Hello!

I'm having a heck of time figuring out how to break this set of functions up...
I'm working on a project where a menu list is dynamically created from an xml doc. That list will only show a determined amount of buttons according to a variable set in the attributes of the XML doc (n = amount of btns).

What I need to figure out is how to write a function that determines where the array is at and how to add or subtract in clicking previous or next.

if you can point me in the right direction, I would be so grateful!



FlashKit > Flash Help > Flash ActionScript
Posted on: 06-25-2007, 06:16 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

How Do You Get The Previous Number In An Array?
I'm loading data into a movie clip via XML and an array system that duplicates a single movie clip any number of times, as defined by the XML file. The code is working, but what I would like to do now is be able to get the previous number from the array.

Here's the script I'm using:

ActionScript Code:
stop();
var newsXML:XML = new XML();
_level0.homeMC.newsMC.newsClips.newsXML.ignoreWhite = true;
_level0.homeMC.newsMC.newsClips.newsXML.load('news.xml');
_level0.homeMC.newsMC.newsClips.newsXML.onLoad = function():Void  {
    _level0.homeMC.newsMC.newsClips.nodeLength = this.firstChild.childNodes.length;
    for (i=0; i<nodeLength; i++) {
        newsPath = _level0.homeMC.newsMC.newsClips;
        newsPath.newsClipping.duplicateMovieClip('newsClipping'+i, newsPath.getNextHighestDepth());
        newsPath['newsClipping'+i]._y += getProperty(newsPath['newsClipping'+(i-1)], _y)+getProperty(newsPath['newsClipping'+(i-1)], _height);
        newsPath['newsClipping'+i].newsTitle.text = this.childNodes[0].childNodes[i].childNodes[0].firstChild;
        newsPath['newsClipping'+i].newsDate.text = this.childNodes[0].childNodes[i].childNodes[1].firstChild;
        newsPath['newsClipping'+i].newsMessage.text = this.childNodes[0].childNodes[i].childNodes[2].firstChild;
    }
    _level0.homeMC.newsMC.newsClips.newsClipping.unloadMovie();
};

The problem is on line 10 where I try to define the "_y" value for the duplicated movie clips. Since each clip is set to auto-size to fix the text content, I can't have them a set distance apart. What I'm hoping to be able to do is to have it get the "_height" and "_y" values from the previous movie clip (so if it's "newsClipping3" I want the values from "newsClipping2" and so on).

I'm new to the whole usage of arrays in scripting and this is the first time I've used this sort of script before so If anyone can tell me what I need to do or point me in the direction of a tutorial that will explain it that'd be of great help!

Time is a bit of a rush as I need this entire project done by Monday morning though... So the sooner I get an answer the better! Thanks!

How Do You Get The Previous Array Item?
I'm loading data into a movie clip via XML and an array system that duplicates a single movie clip any number of times, as defined by the XML file. The code is working, but what I would like to do now is be able to get the previous number from the array.

Here's the script I'm using:

ActionScript Code:
stop();var newsXML:XML = new XML();_level0.homeMC.newsMC.newsClips.newsXML.ignoreWhite = true;_level0.homeMC.newsMC.newsClips.newsXML.load('news.xml');_level0.homeMC.newsMC.newsClips.newsXML.onLoad = function():Void  {    _level0.homeMC.newsMC.newsClips.nodeLength = this.firstChild.childNodes.length;    for (i=0; i<nodeLength; i++) {        newsPath = _level0.homeMC.newsMC.newsClips;        newsPath.newsClipping.duplicateMovieClip('newsClipping'+i, newsPath.getNextHighestDepth());        newsPath['newsClipping'+i]._y += getProperty(newsPath['newsClipping'+(i-1)], _y)+getProperty(newsPath['newsClipping'+(i-1)], _height);        newsPath['newsClipping'+i].newsTitle.text = this.childNodes[0].childNodes[i].childNodes[0].firstChild;        newsPath['newsClipping'+i].newsDate.text = this.childNodes[0].childNodes[i].childNodes[1].firstChild;        newsPath['newsClipping'+i].newsMessage.text = this.childNodes[0].childNodes[i].childNodes[2].firstChild;    }    _level0.homeMC.newsMC.newsClips.newsClipping.unloadMovie();};


The problem is on line 10 where I try to define the "_y" value for the duplicated movie clips. Since each clip is set to auto-size to fix the text content, I can't have them a set distance apart. What I'm hoping to be able to do is to have it get the "_height" and "_y" values from the previous movie clip (so if it's "newsClipping3" I want the values from "newsClipping2" and so on).

I'm new to the whole usage of arrays in scripting and this is the first time I've used this sort of script before so If anyone can tell me what I need to do or point me in the direction of a tutorial that will explain it that'd be of great help!

Time is a bit of a rush as I need this entire project done by Monday morning though... So the sooner I get an answer the better! Thanks!

Targeting Previous Clip In An Array
I can get this to load the next swf in the array but can't seem to create a "previus button" and get it to load the previous swf in the array. Thanks in advance for any help.


Quote:




swfArray = new Array("images/argentina/1.swf", "images/argentina/2.swf", "images/argentina/3.swf");


this.createEmptyMovieClip("target1", 1);
this.createEmptyMovieClip("target2", 2);


target1.loadMovie(swfArray[0]);


target2._alpha = 0;


activeTarget = target1;
currentIndex = 0;


this.onEnterFrame = function() {
if (obj1._alpha>0) {
obj1._alpha -= 10;
}
if (obj2._alpha<100) {
obj2._alpha += 10;
}


nextButton.onRelease = function() {
if (activeTarget == target1) {
obj1 = target1;
obj2 = activeTarget=target2;
} else {
obj1 = target2;
obj2 = activeTarget=target1;
}


if (currentIndex<swfArray.length-1) {
currentIndex++;
} else {
currentIndex = 0;
}


obj2.loadMovie(swfArray[currentIndex]);


obj1.onEnterFrame = function() {
if (this._alpha<=0) {
this.unloadMovie();
delete this.onEnterFrame;
}
};
};

Accessing Next/previous Items In Array
This is probably something very simple, but I'm not too sure of the code used to access items within an array.

Suppose I have an array like this (using Kirupa's Arrays example):

grocery = ["bananas", "oranges", "apples", "kiwis"];
trace(grocery);

And we've loaded up the corresponding variables/text for "bananas", thus the current item = bananas.
Therefore the next item would be "oranges". How can I tell Flash that I want to access this next item?? (I'd like to be able to access it through a variable so that the same action can be applied when the item is "oranges" to move to the next item, which would now be "apples"). Thanx

Make New Array From Previous Answers
Need some help. Trying to learn.
I have sections with questions and answers which I can get.
But, I need to save each section into new array and tally all the final scores.
The screen will show the section score of current section that was just completed
and the final score.

I know the code has lots of problems - attached.

For the total scores the dynamic text boxes var's are totalnumcorrect, totalnumIncorrect, totaluserScore.

For the section score the dynamic text boxes var's are numcorrect, totalnumIncorrect, totaluserScore.


The title changes for each section, so I using that with if statement.

Can someone help please.

Thanks

How To Check For Previous Array Item?
Hi,

I have a loop that is checking to see if the value of a field is the same as the previous item in the array. This was working fine with:

questionlist[i] = [coursename[i],courseid[i], coursecategory[i], coursefriendlydate[i], coursestartdate[i], coursetime[i]];

if (coursecategory[i] != coursecategory[i-1])

but now I have to check for it inside a multidimensional array:

questionlist[i] = [coursename[i],courseid[i], coursecategory[i], coursefriendlydate[i], coursestartdate[i], coursetime[i]];

if (questionlist[i].coursecategory != questionlist[i-1].coursecategory)

but I get "term is not defined" errors.

I have also tried

if (questionlist[i][2] != questionlist[i-1][2])



Any help is appreciated!

Tony

[MX04] Sort Array In Same Order Like Previous One
Hi all,
I am willing to sort an array in the same way like another array..
Explained: I have one array with x coordinates that I had sorted descending , now I have another one array , that I would like to sort (same order of indexes) like the first one..??
Thanx in advance for any answers
Meerah

Array Positions Modify Geoff Stearns >Next <Previous
The script below was initially set to x positions but I have gotten it to work with y positions. Five buttons take me to yPositions but I also want a button that would increment one step at a time, as in >Next <Previous. I know this is a "if" statement but I can't figure it out. I need a detailed explanation please, any vagueness and I'm lost.

Yes, Geoff sent me here to get assistance. Here is his reply but honestly I need a description that is not quite as vague.
_____
if you want back and next buttons, the slider has to know what position it's at - 1 through 5

so the currentSelection var is just a number that tells you what position it's at.

so, every time a user pushes the next button, you add one to currentSelection, and tell the slider to go to that spot in the array.

if they click back, you subtract one from currentSelection and move the slider to that position in the array.

once you have that in place, you want to check to make sure you don't go past the end or the beginning of the array (That's what the if() statement checks for - you can't go past the end of the array, or lower than 0.

i'd recommend checking out flashkit.com or ultrashock.com - they are usually pretty good about helping people out with code needs

Here is the working file
http://www.easternshorevirginia.com/...menu_test.html

fscommand ("allowscale", false);
var yPositions = new Array(0,-481,-142,201,550,897); // this is an array for storing the positions of the slider
function jumpTo (number) { // this function takes the variable "number" that is passed from the buttons and takes the corresponding value from the array of positions, then sets the new position in the slider to the new position.
slider.newY = yPositions[number];
}
stop ();

// Copyright (C) 2001 Ultrashock Inc. // Geoff Stearns. For information regarding terms of use go to http://www.ultrashock.com/legal/terms_of_use.htm

Past Frame Numbers Stored In Array For 'previous' Button
I have an swf with buttons that load to different pages (frames of the swf), and what I'd like to do, each time the frame is changed, is push the current frame into an array so that on a couple of 'previous' and 'next' buttons I can change to pages already visited and back forward again if the user chooses

it's a little tricky for me, considering that I don't want to keep pushing the same pages into the array if someone goes back and forth a few times, so maybe some additional code would be needed to check and see if the frame number is already in the array, and if so, ignore the push code?

I don't know. before I get started, does this approach sound like the simplest/best?

Return To A Previous Menu State
Hi - I'm not sure if I am over complicating this in my head, but I'll describe the problem and see what people think.

I have a menu that is comprised of main sections that when clicked slide open to reveal two or three submenus underneath. There are onMouseOvers on the menus for the purpose of lighting them up.

What I want to do is click on a menu, say the first one and open it up. Then explore the menus underneath. A little later, I click on mainmenu header 2, which shuts the first header and opens the second. But then I decide that maybe the click was wrong and I want to go back to the first menu, so when I mouse off the second menu, I want the first menu to reopen automatically.

I assume this has to be down to storing the current and previous locations and running a function that obtains the previous location and sends the movie to this position. But I don't know how to set it up so that the function doesn't run when you mouse off the mainmenu to click on the submenus ie when you have made the right choice.

This sounds like to me being a lot less complicated than I'm thinking it is but I can't think around the problem.

Any suggestions anyone?

thanks

frank

Deactivate Previous Menu Items
Hello,

I have a menu of 10 items.
I want that the selected item be highlighted. So i have a function "highlight item", called by the item listener on MOUSE_UP event.

myItem.addEventListener(MouseEvent.MOUSE_UP, selectedOn);

The question is: how can I deactivate the previous highlighted items in the menu ? Can you please write down an example of the code ? thanks

Patrick

Deactivate Previous Menu Items
Hello,

I have a menu of 10 items.
I want that the selected item be highlighted. So i have a function "highlight item", called by the item listener on MOUSE_UP event.

myItem.addEventListener(MouseEvent.MOUSE_UP, selectedOn);

The question is: how can I deactivate the previous highlighted items in the menu ? Can you please write down an example of the code ? thanks

Patrick

Menu Drops Down, Previous Page Dissappears
Hey there,
Got my menu and my pages interacting with each other as i want them. Just whenever I'm wanting to switch to another page i roll over them menu and the page i was just on goes. Preferably I'd like to roll over the menu and have the last page still there? It's probably easy as, i just can't think of where to go to do it..

Adding Linear Next And Previous Navigation For An XML Menu
Ive been trying to add a next and previous button to an xml menu for the last couple of days with no success, i just dont get how to go about it.

Ive just downloaded a menu from kirupa.com and added a scroller to it but cant the linear buttons to work. I need to include linear navigation to it as this will a nav for an educational type course.

Cant figure out the syntax on how to do this, its driving me nuts...

You can download the fla below. Also here is the code from the fla file

This appears on the first frame to establish the XML Nodes.

ActionScript Code:
/**************
   Xml Menu_v2
    By hga77
   20/02/2004
     
**************/

stop();
var XMLfile = "xmlstuff/menu.xml";
importXML = new XML();
importXML.varTarget = this;
importXML.ignoreWhite = true;
importXML.onLoad = function (success)
{
    if (success)
    {
        var vt = this.varTarget;
        var root = this.firstChild;
        vt.menuObj = new Object();
        var i;
        var j;
        var k;
        var m;
        (i = root.lastChild, j = 1);
        while (i != null)
        {
            vt.menuObj["item" + j] = new Object();
            vt.menuObj["item" + j].name = i.attributes.name;
            vt.menuObj["item" + j].action = typeof(i.attributes.action) == "undefined" ? null : i.attributes.action;
            vt.menuObj["item" + j].sub = false;
            if (i.hasChildNodes())
            {
                vt.menuObj["item" + j].sub = true;
                (k = i.lastChild, m = 1);
                while (k != null)
                {
                    vt.menuObj["item" + j]["sub" + m] = new Object();
                    vt.menuObj["item" + j]["sub" + m].name = k.attributes.name;
                    vt.menuObj["item" + j]["sub" + m].action = k.attributes.action;
                    (k = k.previousSibling);
                    m++;
                }
            }
            (i = i.previousSibling);
            j++;
        }
        _global.Number_Items = j - 1;
        vt.play();
    }
    else
    {
        trace("ERROR PARSING XML");
    }
};
importXML.load(XMLfile);

This is what builds the menus:


ActionScript Code:
onClipEvent (load)
{
    function executeAction(action, subItem)
    {
        //loadMovie( action , _parent.content);
       
        /*
        Uncomment the above line to get the menu working
        and add a content mc on the stage (with the instance name "content") to
        load in your stuff (swf's, jpg's, etc).
        */
       
        previousSub.gotoAndStop("10");
        this.subHolder[subItem].gotoAndPlay("11");
        previousSub = this.subHolder[subItem];
    }
    function selectItem(item)
    {
        if (this[item].action != null && curItem != item)
        {
            executeAction(this[item].action);
            previousItem.gotoAndStop("10");
            this[item].gotoAndPlay("11");
            previousItem = this[item];
        }
        if (this[item].sub == false || curItem == item)
        {
            curItem = null;
            removeSub();
        }
        else
        {
            curItem = item;
            buildSub(item);
        }
    }
    function buildSub(item)
    {
        var i;
        var s;
        var j;
        var d = 0;
        this.attachMovie("subholder", "subholder", 100);
        var k = this.subholder;
        var total_subs = 0;
        var correct_item = (Number_Items - item) + 1;
        for (i in menuObj["item" + correct_item])
        {
            if (typeof(menuObj["item" + correct_item]) == "object" && i!="sub" && i!="action")
            {
                total_subs++;
            }
        }
        var Present_sub = total_subs - 1;
        for (i = 1;i < total_subs;i++)
        {           
            k.attachMovie("sub", i, d);
            s = k[i];
            s.name = menuObj["item"+correct_item]["sub"+Present_sub].name;
            s.action = menuObj["item"+correct_item]["sub"+Present_sub].action;
            s._x = 20;
            s._y = (s._height + subSpacer) * d;
            d++;
            Present_sub--;
        }
        k._y = this[item].basey + this[item]._height + menuSpacer;
        var u=1;
        for (i in menuObj)
        {   
            j = this[u];
            if (this[item]._y < j._y)
            {
                j.target = j.basey + k._height + menuSpacer;
            }
            else
            {
                j.target = j.basey;
            }
            u++;
        }
        subs=total_subs;
        onenterframe = menuAnimation;
    }
    function removeSub()
    {
        this.subholder.removeMovieClip();
        depth = 1;
        for (i in menuObj)
        {
            this[depth].target = this[depth].basey;
            depth++;
        }
        onenterframe = menuAnimation;
    }
    function menuAnimation()
    {
        var i;
        var j;
        var k = true;
        var depth = 1;
        for (i in menuObj)
        {
            j = this[depth];
            j._y = j._y + (j.target - j._y) / menuSpeed;
            if (menuTolerance < Math.abs(j.target - j._y))
            {
                k = false;
            }
            else
            {
                j._y = j.target;
            }
            depth++;
        }
        if (k)
        {
            onenterframe = null;
            if (curItem != null)
            {
                activateSub();
            }
        }
    }
    function activateSub()
    {
        var d = 0;
        for (i=1;i<subs;i++)
        {
            subholder[i].start = getTimer();
            subholder[i].delay = subDelay * d;
            subholder[i].gotoAndPlay(2);
            d++;
        }
    }
    MovieClip.prototype.activateMenu = function()
    {
        var d = 0;
        for (i=1;i<Number_Items+1;i++)
        {
            this[i].start = getTimer();
            this[i].delay = itemDelay * d;
            this[i].gotoAndPlay(3);
            d++;
       }
    }
    var menuSpacer = 1;  //sets the vertical space between main items
    var subSpacer = 1;    //sets the vertical space between sub items
    var menuSpeed = 5;    //sets the menu animation speed
    var menuTolerance = 1;
    var subDelay = 170;  //set the delay for the sub items entering the stage
    var itemDelay = 100;    //set the delay for the main items entering the stage
    var curItem = null;
    var menuObj = _parent.menuObj;
    var onenterframe = null;
    var Present_item = Number_Items;
    var loop_condition = Number_Items + 1;
    for (d = 1; d<loop_condition; d++)
    {
        this.attachMovie("item", d, d);
        k = this[d];
        k._x = 20;
        k._y = (k._height + menuSpacer) * d;
        k.name = menuObj["item" + Present_item].name;
        k.action = menuObj["item" + Present_item].action;
        k.sub = menuObj["item" + Present_item].sub;
        k.basey = k._y;
        if (k.sub == false)
        {
            k.icon._visible = false;
        }
        Present_item--;
    }
    activateMenu();
}
onClipEvent (enterFrame)
{
    onenterframe();
}

Desperate... Cant Get These Next And Previous Buttons To Work With Xml Menu...
Maybe im double posting from the xml menu thread, but im soooooooooo stuck its making me crazy...

Using the Xml_Menu_v2_buttonDown that hga77 created, ive been trying to add a next and previous button to it with no success.

I can sort of get the buttons to move between the sub levels but, cant get actions to execute and move to the next or previous parent nodes.


Code:
_parent.next_btn.onRelease = function()
{
trace(current);
if (curItem != item)
{
currentbtn = parseInt(previousSub._name)+1;
executeAction(action,previousSub);
trace(current)
}
}
Its doing my head in... Ive spent the last 3 days looking at this and i cant let it go... Please put me out of my misery...

"gallery" Reading From Array, Next And Previous Button Headache
Alright, I'm doing this to make a catalogue better for people on dial-up.
Theres two movie clips, one will be hidden at all times, the next image is loaded into the hidden movieclip.

The next button is working fine, although the previous is not, the objIndex changes down although that array index is not called in loadMovie();

I plan to switch over to colin moocks' preloader later when I get this working, make it draw/attach a preloader into each movieclip incase the movie has not loaded before the user presses "next".

Anyway, code is below, looks fine to be but I've been looking at it too long.

Any ideas folks?


Code:
var objIndex = -1;
picPath = "";
pics = ['winterrangep1.jpg', 'winterrangep2.jpg', 'winterrangep3.jpg', 'winterrangep4.jpg', 'winterrangep5.jpg', 'winterrangep6.jpg'];
_root.createEmptyMovieClip("holder_mc", 1);
_root.holder_mc.createEmptyMovieClip("image_1", depth++);
_root.holder_mc.createEmptyMovieClip("image_2", depth++);
var mc_1 = _root.holder_mc.image_1;
var mc_2 = _root.holder_mc.image_2;
mc_2._alpha = 0; // set the second to be hidden *IMPORTANT*
mc_2._x = 500; // move it outta the way while testing so I can see whats going on
MovieClip.prototype.loadPic = function(i, action) {
thisObj = this;
objIndex = (objIndex+i)%_root.pics.length;
thisObj.loadMovie(picPath+_root.pics[objIndex]);
if (objIndex<0) {
objIndex += _root.pics.length;
}
};
MovieClip.prototype.swapVis = function(action) {
trace(this._name+": "+action+" objIndex = "+objIndex);
if (this._alpha == 100) {
this._alpha = 0;
if (action == "prev") {
this.loadPic(-1, "prev");
} else if (action == "next") {
this.loadPic(1, "next");
}
} else if (this._alpha == 0) {
this._alpha = 100;
}
};
mc_1.loadPic(1, "next");
mc_2.loadPic(1, "next");
nextButton.onRelease = function() {
mc_1.swapVis("next");
mc_2.swapVis("next");
};
prevButton.onRelease = function() {
mc_1.swapVis("prev");
mc_1.swapVis("prev");
};

"gallery" Reading From Array, Next And Previous Button Headache
Alright, I'm doing this to make a catalogue better for people on dial-up.
Theres two movie clips, one will be hidden at all times, the next image is loaded into the hidden movieclip.

The next button is working fine, although the previous is not, the objIndex changes down although that array index is not called in loadMovie();

I plan to switch over to colin moocks' preloader later when I get this working, make it draw/attach a preloader into each movieclip incase the movie has not loaded before the user presses "next".

Anyway, code is below, looks fine to be but I've been looking at it too long.

Any ideas folks?


Code:
var objIndex = -1;
picPath = "";
pics = ['winterrangep1.jpg', 'winterrangep2.jpg', 'winterrangep3.jpg', 'winterrangep4.jpg', 'winterrangep5.jpg', 'winterrangep6.jpg'];
_root.createEmptyMovieClip("holder_mc", 1);
_root.holder_mc.createEmptyMovieClip("image_1", depth++);
_root.holder_mc.createEmptyMovieClip("image_2", depth++);
var mc_1 = _root.holder_mc.image_1;
var mc_2 = _root.holder_mc.image_2;
mc_2._alpha = 0; // set the second to be hidden *IMPORTANT*
mc_2._x = 500; // move it outta the way while testing so I can see whats going on
MovieClip.prototype.loadPic = function(i, action) {
thisObj = this;
objIndex = (objIndex+i)%_root.pics.length;
thisObj.loadMovie(picPath+_root.pics[objIndex]);
if (objIndex<0) {
objIndex += _root.pics.length;
}
};
MovieClip.prototype.swapVis = function(action) {
trace(this._name+": "+action+" objIndex = "+objIndex);
if (this._alpha == 100) {
this._alpha = 0;
if (action == "prev") {
this.loadPic(-1, "prev");
} else if (action == "next") {
this.loadPic(1, "next");
}
} else if (this._alpha == 0) {
this._alpha = 100;
}
};
mc_1.loadPic(1, "next");
mc_2.loadPic(1, "next");
nextButton.onRelease = function() {
mc_1.swapVis("next");
mc_2.swapVis("next");
};
prevButton.onRelease = function() {
mc_1.swapVis("prev");
mc_1.swapVis("prev");
};

Adding Linear "next And Previous" Navigation To A XML Menu
Ive been trying to add a next and previous button to an xml menu for the last couple of days with no success, i just dont get how to go about it.

Ive downloaded a menu from kirupa.com and added a scroller to it but cant the linear buttons to work. I need to include linear navigation to it as this will be a nav for an educational type course.

You can download the fla below. Also here is the code from the fla file

Trying To Combine "Next"/"Previous" With Slideshow Array
I need help replacing my navigation system on this movie.

My original has a button for each jpg in the array with this AS telling the script where to stop.


ActionScript Code:
on (release) {    rot = POZ[0];} {



ActionScript Code:
on (release) {    rot = POZ[1];} {


I'd like to replace this nav system with a simple "NEXT" or "PREVIOUS" but I want to keep the sliding action. Is this possible?

thanks,
Troy

Trying To Combine "Next"/"Previous" With Slideshow Array
I need help replacing my navigation system on this movie.

My original has a button for each jpg in the array with this AS telling the script where to stop.


ActionScript Code:
on (release) {    rot = POZ[0];} {



ActionScript Code:
on (release) {    rot = POZ[1];} {


I'd like to replace this nav system with a simple "NEXT" or "PREVIOUS" but I want to keep the sliding action. Is this possible?

thanks,
Troy

Menu Array
hi there,

I have a menu array that is vertical, but would like to make it horizontal.

I believe this is the code that i change, but not sure how too.

for(i=1;i<=8;i++){
clip.duplicateMovieClip("clip"+(i+0), +i)
height = _root.clip._height

_root["clip"+(i+0)]._y = _root.clip._y +height * i
_root["clip"+(i+0)]._alpha = 75
_root["clip"+(i+0)].names = names[i];
_root["clip"+i].link = _root["url"+i];
_root["clip"+i].onPress = function() {
getURL(this.link);
};
}

Any help is appreciated.

Array Menu
dear flash community,


iam a newbie.i have very little basic knowledge on flash.

please can anyone kindly help with this horizontal menu i want to use for my site

i had found this on flashkit.but i dont know how to configure it...it is done completely with actionscript.how can i assign flash movies urls to load within flash to the menu and submenu links

swf is here
http://www.geocities.com/madhav_shet...yadvanced2.swf

the fla is here http://www.geocities.com/madhav_shet...yadvanced2.fla


thank u very very much
madhav shetty

[F8] Help With Array In Tab Menu
am creating a horizontal tab menu (no drop downs). I am able to get the rollovers to work, but am struggling with the releases.

The trouble is, when a tab is clicked, it needs to have a different color. I can do this, but then how do i get it to stay this color until another tab is clicked? And to turn off the rollover/out functionality for just this button?

I am using an array to accomplish this, thinking this would be the best way to handle it.

Any insight would be great...I'm just not sure what direction to go from here.

Here is my code thus far:


code:
var ButtonArray:Array = [Button1, Button2, Button3, Button4, Button5, Button6, Button8];

for (var i = 0; i <= ButtonArray.length; i++) {
ButtonArray[i].onRollOver = over;
ButtonArray[i].onRollOut = out;
ButtonArray[i].onRelease = release;
}

function over(){
this.gotoAndPlay("In");
}

function out(){
this.gotoAndPlay("Out");
}

function release() {
this.gotoAndPlay("Selected");
var clicked = i;
}

Menu Array Help
I have a main menu on my stage which consists of 5 MC's which act as my buttons. Inside each there is a little animation that happens and highlights the button. If the button is clicked however, the MC's animation should stay on the last frame which keeps it highlighted, until another button is clicked, in which case the previous button reverses it's animation. There is also a button that has a unique animation which is excluded from the array. The tricky part for me is giving each button the abiliy to load it's external swf in to the movie. Heres what i'm working with. Can someone guide me in a better way of achieving this. Any help is very much appreciated.

code:
public class WaiaStudios extends MovieClip {
var container:Sprite = new Sprite();
//Loader
private var loader:Loader;
private var progressOutput:TextField;
//Menu Button MC Array
private var menu:Array = [about, services, contact, getquote];

public function WaiaStudios() {
//Default stop actions
about.stop();
portfolio.stop();
services.stop();
contact.stop();
getquote.stop();


addChild(container);

for each (var element:MovieClip in menu)
{
element.addEventListener(MouseEvent.CLICK, navActive);
element.addEventListener(MouseEvent.ROLL_OVER, navOver);
element.addEventListener(MouseEvent.ROLL_OUT, navOut);
}

//Custom If Portfolio is Rolled Over
hitTest.addEventListener(MouseEvent.MOUSE_OVER, navOver2);
hitTest.addEventListener(MouseEvent.MOUSE_OUT, navOut2);

//Loader & Content
mainContent();
}


// **NAV ROLLOVER & OUT SCRIPT**
private function navOver(btn:MouseEvent):void {
var theButton = btn.target;
var bleep:Bleep = new Bleep();

if (theButton.currentFrame == 1) {
theButton.play();
bleep.play();
}
}


private function navOut(btn:MouseEvent):void {
var theButton = btn.target;
theButton.addEventListener(Event.ENTER_FRAME, out);
}
private function out(btn:Event) {
var theButton = btn.target;
if (theButton.currentFrame > 1) {
theButton.prevFrame();
} else if (theButton.currentFrame == 1) {
theButton.removeEventListener(Event.ENTER_FRAME, out);
}
}

private function navActive(e:MouseEvent):void {
e.target.removeEventListener(MouseEvent.ROLL_OUT, navOut);
container.addChild(e.target);
switchBtn();
}

private function switchBtn():void {
trace(container.numChildren);
for (var i:int; i < container.numChildren; i++){
container.removeChildAt(0);
}
}

//Portfolio Button
private function navOver2(e:MouseEvent):void {
var bleep:Bleep = new Bleep();
Tweener.addTween(portfolio, {y:45, time:1.5});
Tweener.addTween(subMenu.sub_web, {alpha:1, time:0.8});
Tweener.addTween(subMenu.sub_print, {alpha:1, time:1.5});
Tweener.addTween(subMenu.sub_video, {alpha:1, time:2.2});

if (portfolio.currentFrame == 1) {
portfolio.play();
bleep.play();
}
}
private function navOut2(e:MouseEvent):void {
portfolio.addEventListener(Event.ENTER_FRAME, out2);
Tweener.addTween(portfolio, {y:59.5, time:1.5});
Tweener.addTween(subMenu.sub_web, {alpha:0, time:2.0});
Tweener.addTween(subMenu.sub_print, {alpha:0, time:1.5});
Tweener.addTween(subMenu.sub_video, {alpha:0, time:0.8});
}
private function out2(e:Event) {
if (portfolio.currentFrame > 1) {
portfolio.prevFrame();
} else if (portfolio.currentFrame == 1) {
portfolio.removeEventListener(Event.ENTER_FRAME, out2);
}
}
// **END NAV ROLLOVER SCRIPT**

Menu With Array Help
hi i have created a menu with xml which works fine

but i now wanted to create a menu with arrays

below is the attached file
pls help me in this

Array Menu
so im making this portfoli
and i have the menu working finally.
i cant figure out how to make it stop opening a window and a url,
i want it to go to a frame and play.
below is the code for it
ive tried messing around with it but no sucess


thanks

code -

PHP Code:



var names = new Array(4)
names[1] = "home"
names[2] = "about"
names[3] = "portfolio"
names[4] = "contact"

var link = new Array(4)


//frame1="5";
//url2="http://www.googla.ca";
//url3="http://www.googla.ca";
//url4="http://www.googla.ca";


for(i=1;i<=4;i++){
     clip.duplicateMovieClip("clip"+(i+0), +i)
     height = _root.clip._height + 2

     _root["clip"+(i+0)]._y = _root.clip._y +height * i
     _root["clip"+(i+0)]._alpha = 75
     _root["clip"+(i+0)].names = names[i];
     _root["clip"+i].link = _root["url"+i];
     _root["clip"+i].onPress = function() {
          getURL(this.link);
     };
}

_root["clip"+(i+1)]._alpha = 75
_root["clip"+(i+1)].name = names[i];
_root.clip._visible = false
stop() 

Array For Menu
Is my array setup properly? Why can't I trace the length of the nested array subMenuItem?
Here is my code, if you notice anything peculiar please let me know. I also know I can shorten this but I need to know how to do it first.







Attach Code

var menuItem = Array = new Array();
var subMenuItem = Array = new Array();
menuItem[0] = {label: "ANIMUS", link: "#"};
menuItem[0].subMenuItem = new Array();
menuItem[0].subMenuItem[0] = {label: "HISTÓRIA", link:"movies/historia.swf"};
menuItem[0].subMenuItem[1] = {label: "EQUIPE", link:"movies/equipe.swf"};
menuItem[0].subMenuItem[2] = {label:"PREMIAÇÃO", link:"movies/premiacao.swf"};
menuItem[1] = {label:"CLIENTES", link:"movies/clientes.swf"};
menuItem[2] = {label:"PORTIFÓLIO", link:""};
menuItem[2].subMenuItem = new Array();
menuItem[2].subMenuItem[0] = {label: "BRANDING", link:"movies/branding.swf"};
menuItem[2].subMenuItem[1] = {label: "EMBALAGEM", link:"movies/embalagem.swf"};
menuItem[2].subMenuItem[2] = {label:"MERCHANDISING", link:"movies/merchandising.swf"};
menuItem[2].subMenuItem[3] = {label: "AMBIENTE DE", link:"movies/ambiente_de.swf"};
menuItem[2].subMenuItem[4] = {label: "VAREJO", link:"movies/varejo.swf"};
trace(menuItem[2].subMenuItem.length);

























Edited: 11/28/2006 at 10:49:31 PM by breez11

Menu Using Array
Hi, I'm beginning to look at using Arrays for menus as they are cleaner.

Arrays are new to me, and I have problems getting them to work.

Currently I'm doing something like this.

menu1.onRollOver = function() {
menu1.gotoAndStop("Selected");
};
menu1.onRollOut = function() {
menu1.gotoAndStop("Normal");
};
menu1.onRelease = function() {
do something;
};

This is the code I've tried and it doesn't work.

var mainMenu:Array = ["menu1","menu2","menu3","menu4"];
for (i = 0; i < mainMenu.length; i++) {
mainMenu[i].onRollOver = function() {
mainMenu[i].gotoAndStop("Selected");
}
};

Somebody advise me on how I should get it working?

Menu Reorder - Array?
Hi-
having trouble deciding how this problem should be solved.
I have a three item menu:

A
B
C

when the user clicks on A - i want the menu to reorder, so that A moves down to the C postion and C and B move up - and so on with the other possibilities...

Do i create an array of movie clips and .y positions? Or is this a Tell Target situation? or maybe even swap depths?
As you can see i am not sure how to start.

thanks in advance for any help.

cheers

Shawn

Array Menu Problem
hey there, i have this there little floating mouse tool tip, that is supposed to display the name of an object in the menu array, "tip" but for some god awful reason that i can't figure out, the loop doesn't give the array property to every menu item, instead it waits till the end and populates all of them?

anyway heres the code see if you can tell what i'm doing wrong

// -- this is the array -- //

Code:
on (release) {
if (nMenuOpen == false) {
e = "_base.jpg";
nDropList.menuData = [{url:b+"166"+e, tip:"166 BASE"}, {url:b+"163e"+e, tip:"163E BASE"}, {url:b+"163g"+e, tip:"163G BASE"}, {url:b+"245"+e, tip:"245 BASE"}, {url:b+"401"+e, tip:"401 BASE"}, {url:b+"547g"+e, tip:"547G BASE"}, {url:b+"1062"+e, tip:"1062 BASE"}, {url:b+"b2"+e, tip:"B2 BASE"}, {url:b+"b332"+e, tip:"B332 BASE"}, {url:b+"b522"+e, tip:"B522 BASE"}];
nMenuOn(108.05);
} else if (nMenuOpen == true) {
nMenuOff();
}
}
// -- and this here is the function -- //


Code:
function nSlideDown() {
_parent.nDropList._visible = false;
for (i=0; i<menuData.length; i++) {
this.attachMovie("nDropDown", "item"+i, i);
this["item"+i].nThumb.loadMovie(menuData[i].url);
trace(["tip START "+i+" : "]+menuData[i].tip);
this["item"+i].nBtn.onRollOver = function() {
toolTip.alphaTo(100, .2, "linear", .02);
// this line ****s it up
toolTip.toolTipText.text = ["hello ****o"+i]; //menuData[i].tip;
};
this["item"+i].nBtn.onRollOut = function() {
toolTip.alphaTo(0, .2, "linear", .02);
};
this["item"+i].nBtn.onRelease = function() {
};
onEnterFrame = function () {
var t = this["item"+i].nThumb.getBytesTotal();
var a = this["item"+i].nThumb.getBytesLoaded();
var b = t-a;
var p = int((a/t)*100);
if (p>99) {
this["item"+i].nThumb._visible = true;
}
};
trace(["tip END "+i+" : "]+menuData[i].tip);
trace("hello there "+i);
}
this._visible = true;
for (i=0; i<menuData.length; i++) {
this["item"+i].tween("_y", this["item"+i]._height*i, 0.2, "linear");
}
_parent.nMenuOpen = true;
}
any help would be marvelous

[F8] Multidimensional Array For Nav Menu?
Ok, I have a feeling that I'm going about this all wrong, but anywho:

I have a site with a three level nav bar. I've created movie clips for the menu elements (easier for positioning) with mc_level1, mc_sub1, mc_sub2, mc_tert1_2, mc_tert2_1, etc.

In my actionscript, where I'm defining menu behavior/tweens, I want to have a multidimensional array to keep the elements of the menu, so that:

menu = new Array(4)
menu[0] = new Array(2)
menu[0][1] = new Array(mc_tert_0_0, mc_tert_0_1, mc_tert_0_2)

but I'd also like to be able to reference level 1 and level 2 menu items by the array like:

menu[0] = mc_Support
menu[0][1] = mc_Volunteer
menu[0][1][2] = mc_tert_0_2


Does this make sense? Are you allowed to have aliases for array levels, or should I just create three arrays?

Arrange Menu Array
Hi all,

Im after a menu that will do the following

Say theres 10 items, when you click on item 4 for example, that will move to the top of the array and the rest will arrange themself below that automatically, click on another item below that it will go to the top of the array and the remaining items below will rearrange etc.

I've searched through this site a heap of times already and found nothing to that effect, also googled it but im not really sure what terms i should be using.

cheers

Xml Menu/array Problem
I've been trying to fix this menu for a while but it's all going a bit pear shaped. sorry for posting the whole code but i really have hit a brick wall!

basically i have a menu that reads an xml file - it has one level of drop downs.

the vertical position of each drop down menu item is stored in an array and then used later when the drop down becomes visible.


PHP Code:



heightPos = item._y+(_root.itemHeight*(j+1))
_root.menuArray[i][j] = heightPos; 




for some reason some of the values are not being stored and as a result the drop downs aren't positioning correctly - but tracing the value 'heightPos' shows that it is there?!

any ideas what i'm doing wrong?

ps. if i change the order of the menu items in the xml file it seems to effect the first one?

Sliding Menu Array
Hi all! I was wondering if anyone could help me out with this. I am trying to recreate this menu system http://www.karinabednorz.de...the part where you click on one of the names under the word "fotografen", and I'm really new to scripting, and have come up with this (see below), which obviously isn't working. Could someone please help me out?

Thanks very much in advance,
-Melanie


ActionScript Code:
_root.targety = 1;
speed = 4;
slide_array = new Array("0", "200", "300");
_root.i=0

_root.onEnterFrame=function(){
        starty = this._y;
        vertikal = _root.targety-starty;
        this._y= starty+(vertikal/speed);
}
_root.print.onRelease=function(){
_root.targety=1
_root.i=0
}
_root.web.onRelease=function(){
_root.targety=200
_root.i=1
}
_root.photo.onRelease=function(){
_root.targety=300
_root.i=2
}
_root.next.onRelease=function(){
if(_root.i==2){
_root.i=0}
_root.targety=slide_array[_root.i]
}
_root.previous.onRelease=function(){
if(_root.i==0){
_root.i=1}
_root.targety=slide_array[_root.i]
}

Help With Really Simple Array/menu
OK. This is probably excruciatingly simple to most of you, but it's driving me a bit mad. I have movieclip names, and the links they should link to.

In my "for" statement, it should run through each movieclip and associate each with its link.

The problem is that onRelease, the getURL always goes to the last URL (oLinks.link4 = "free.html").

I understand that this is because that's the last value the thisLink variable is given, but I really don't know how to fix it. Any ideas?

Cheers


Code:
var oLinks:Object = new Object();
oLinks.mc0 = mcAbout;
oLinks.mc1 = mcCoaching;
oLinks.mc2 = mcTraining;
oLinks.mc3 = mcContact;
oLinks.mc4 = mcFree;
oLinks.link0 = "about.html";
oLinks.link1 = "coaching.html";
oLinks.link2 = "training.html";
oLinks.link3 = "contact.html";
oLinks.link4 = "free.html";
//
var numberOfLinks:Number = 5;
//
for (var i = 0; i<numberOfLinks; i++) {
thisMC = oLinks["mc"+i];
thisLink = oLinks["link"+i];
//trace("thisMC is"+thisMC+" and thisLink is: "+thisLink);
thisMC.onRelease = function() {
//trace("onRelease called");
getURL(thisLink);
};
}

Collapsing Menu From Array
I need to create a dynamic collapsing menu from an array. so far I have the array and first level of the menu working. Now I need to create the functionality of the subMenu and I am stumped. Is there any good references out there that might be able to walk me through this process? Here is my code and my source file can be found here http://www.actionscript.org/forums/showthread.php3?t=122921







Attach Code

var menuItem:Array = new Array();
menuItem[0] = {label:"ANIMUS", link:"#"};
menuItem[0].subMenuItem = new Array();
menuItem[0].subMenuItem[0] = {label:"HISTÓRIA", link:"http://www.kirupa.com"};
menuItem[0].subMenuItem[1] = {label:"EQUIPE", link:"http://www.actionscript.org"};
menuItem[0].subMenuItem[2] = {label:"PREMIAÇÃO", link:"http://www.actionscript.com"};
menuItem[1] = {label:"CLIENTES", link:"http://www.flashpope.com"};
menuItem[2] = {label:"PORTIFÓLIO", link:"#"};
menuItem[2].subMenuItem = new Array();
menuItem[2].subMenuItem[0] = {label:"BRANDING", link:"movies/branding.swf"};
menuItem[2].subMenuItem[1] = {label:"EMBALAGEM", link:"movies/embalagem.swf"};
menuItem[2].subMenuItem[2] = {label:"MERCHANDISING", link:"movies/merchandising.swf"};
menuItem[2].subMenuItem[3] = {label:"AMBIENTE DE", link:"movies/ambiente_de.swf"};
menuItem[2].subMenuItem[4] = {label:"VAREJO", link:"movies/varejo.swf"};
menuItem[3] = {label:"DESIGN ESTRATÉGICO", link:"movies/design_estrategico.swf"};
menuItem[4] = {label:"CONTATO", link:"movies/contato.swf"};
////////////////////////////////////////////////
////////////////////////////////////////////////
var xPos = 19;
var yPos = 45;
for (i=0; i<menuItem.length; i++) {
attachMovie("container", "new"+i, i, {_x:xPos, _y:yPos});
yPos += this["new"+i]._height;
this["new"+i].label_txt.text = menuItem[i].label;
this["new"+i].url_btn._url = menuItem[i].link;
trace(menuItem[i].link);
}
////////////////////////////////////////////////

























Edited: 11/29/2006 at 08:01:10 PM by breez11

Array For Catagorical Menu
Where can I get a tutorial on how to create a catagorial menu with a built in array?
I want to create the structure below using actionscript without XML. A nested loop thing?

Books
red books
blue books
Cars
red cars
blue cars

thanks,
yogi

Menu Array Problem
is there a way to load a movie into a container from an array menu..

newmenu= new Array();
newmenu[0]="About";

n = new Array();
n[0] = 3;

fields=new Array();
fields[0]="Testimony";
fields[1]="Careers";
fields[2]="Executive Team";

links=new Array();
links[0]="http://www.tyadam.com";
links[1]="http://www.tyadam.com";
links[2]="http://www.tyadam.com";

is the menu array code... is there a way to substitute the URL link.. for a loadMovie style command?..

like

on (release){
loadMovie("blah.swf", "_root.container1");
}

thanks for the help !

Splicing An Array For A Drop Down Menu
I've created a drop down menu with code, but
I'm having trouble with the sub-menu.

The sub menu options don't appear.

The code I'm using:

var menuContent:Array = ["News", "Portfolio", "Biography", "Contact"];
var spacing:Number = this.item_mc._height+8;
// ------------------------------------------------------------------------
function populateList() {
for (i=0; i<menuContent.length; i++) {
item_mc.duplicateMovieClip("item"+i+"_mc", _root.getNextHighestDepth(), {_y:175+i*spacing});
// ---- define what text to appear -------------------------------
_root["item"+i+"_mc"].itemName_txt.text = menuContent[i];
_root["item"+i+"_mc"].pictureID = i+1;
_root["item"+i+"_mc"].list_btn.onRelease = function() {
// ------ Passing value to function -----------------------------
itemClicked(this.pictureID);
};
}
}
// ------------ function to create subMenu -------------------------------
function itemClicked(pictureID:Number) {
if (pictureID == 2) {
menuContent.splice(2, 0, ["– People", "– Nature", "– Entertainment", "– Art", "– Food", "– Sports", "– Fashion"]);
for (i=0; i<menuContent.length; i++) {
_root.item_mc.duplicateMovieClip("item"+i+"_mc", _root.getNextHighestDepth(), {_y:176+i*spacing});
}
//populateList();
}
}
// ------------- Populate Main Menu list ------------------------------------
enterSite_btn.onRelease = function() {
populateList();
this._visible = false;
};
// -----------------------------------------------------------------------
stop();


Thanks

Font Color In Array Menu.
dear flashkit comunity,


please help me with this.
can anyone tell me how can i change the color of the fonts in this actionscript menu.

http://www.geocities.com/madhav_shet...yadvanced2.fla

regards

Effecient Way To Run Loadmovie From An Array/menu
Just want to assign seperate actions to each of the six buttons........



#include "mc_tween2.as"
var myButtons = [this.home, this.company, this.developments, this.rentals, this.brochure, this.contact];
for (var i = 0; i<myButtons.length; i++) {
myButtons[i].originalY = myButtons[i]._y;
myButtons[i].onRollout = myButtons[i].onReleaseOutside=function () {
this.tween("_y", this.originalY, 0.2);
};
myButtons[i].onRollOver = function() {
this.alphaTo(100, 0.2);
};
myButtons[i].onRollOut = function() {
this.alphaTo(60, 0.2);
};
myButtons[i].onRelease = function() {
this._parent.activateItem(this);
this.tween("_y", this.originalY+4, 1);
// INA
trace("Hey, button "+this+" was clicked.");
};
}
this.activateItem = function(item) {
if (this.currentItem != false) {
this.deActivateItem();
}
this.currentItem = item;
this.currentItem.alphaTo(100, 1);
this.currentItem.enabled = false;
};
this.deActivateItem = function() {
this.currentItem.enabled = true;
this.currentItem.alphaTo(60, 0.2);
this.currentItem.tween("_y", this.currentItem.originalY, 0.2);
this.currentItem = undefined;
};
this.stop();

How To Place Array Menu Within Mc And Add Scrolling
I would like to to place a menu (that is created with arrays and dynamically created MCs and textfields inside a movie clip so that the content can be scrolled. Anyone know how to make this work? My experiments have failed so far. I'm using Flash X 2004. I'm guessing that the container clip would need a background with _alpha set to 0 to give the clip a visible width and height so that the scroller can be attached to it.

Menu Array Doesn´t Work
I got a menu array with some buttons that are connected with some sections. Originally, they should be disabled, when pressed, but somehow it only works for the first array button:


ActionScript Code:
var menu_array:Array;
var section_array:Array;
       
var currentSection:int=0;
var nextSection:int;

init();
       
function init():void
        {
            menu_array=new Array(main_navi.navi_mc.tasten_link.nav1_btn,main_navi.navi_mc.tasten_link.nav2_btn);
            section_array=new Array(section_mc.section_1,section_mc.section_2);
           
            stopAll();
           
            addMenuEvents();
           
            hideCurrentSection();
        }
       
function stopAll():void
        {
            for(var i:int=0;i < menu_array.length;i++)
            {
                menu_array[i].stop();
                section_array[i].stop();
            }
        }
       
function addMenuEvents():void
        {
            for(var i:int=0;i < menu_array.length;i++)
            {
                menu_array[i].mouseChildren=false;
                menu_array[i].buttonMode=true;
               
                menu_array[i].id=i;
                menu_array[i].isPressed=false;
               
                menu_array[i].addEventListener(MouseEvent.MOUSE_OVER,setOver);
                menu_array[i].addEventListener(MouseEvent.MOUSE_OUT,setOut);
                menu_array[i].addEventListener(MouseEvent.MOUSE_DOWN,setDown);
                menu_array[i].addEventListener(MouseEvent.MOUSE_UP,setUp);
            }
        }
       
function setOver(evt:MouseEvent):void
        {
            if(evt.target.isPressed==false)
                evt.target.gotoAndStop(2);
        }
       
function setOut(evt:MouseEvent):void
        {
            if(evt.target.isPressed==false)
                evt.target.gotoAndStop(1);
        }
       
function setDown(evt:MouseEvent):void
        {
            nextSection=evt.target.id;
            checkState(evt.target.id);
           
            evt.target.gotoAndStop(3);
            hideCurrentSection();
           
            currentSection=evt.target.id;
        }
function setUp(evt:MouseEvent):void
        {
            if(evt.target.isPressed==false)
                evt.target.gotoAndStop(1);
        }
       
function checkState(n:int):void
        {
            for(var i:int=0;i < menu_array.length;i++)
            {   
                menu_array[i].buttonMode=false;
                menu_array[i].removeEventListener(MouseEvent.MOUSE_DOWN,setDown);
                if(i==n)
                    menu_array[i].isPressed=true;
                else
                {
                    menu_array[i].isPressed=false;
                    menu_array[i].gotoAndStop(1);
                }
            }
        }
       
function hideCurrentSection():void
        {
            section_array[currentSection].gotoAndPlay(21);
            showSection();
        }
       
function showSection():void
        {
            section_array[nextSection].gotoAndPlay(2);
            section_array[nextSection].addEventListener(Event.ENTER_FRAME,checkFrame);
        }
       
function checkFrame(evt:Event):void {
            if(evt.target.currentFrame==2)
            {
                evt.target.removeEventListener(Event.ENTER_FRAME,checkFrame);
                for(var i:int=0;i < menu_array.length;i++)
                {
                    menu_array[i].buttonMode=true;
                    menu_array[i].addEventListener(MouseEvent.MOUSE_DOWN,setDown);
                }
            }

Could someone help?:confused::confused:
}

Popuplating My Menu With Info From An Array
Hi,

I'd like to know how to populate a menu with using words from an array.

So say I have:

Code:
BmacNames = ["maps", "web", "news", "gmail", "PHOTOS", "LINKS"];
and then I wan to put them into a text field.

So I have this:

Code:

function CatMenu()
{
gmcCatMenu = this;
BmacButtons = [];
gmcCatMenu._x = Stage.width-555;
var _l2 = 0;
while (_l2 < CAT_COUNT)
{
BmacButtons[_l2] = this.attachMovie("sCatButton", "mcCat" + _l2, _l2, {name: BmacNames[_l2], index: _l2});
_l2++;
} // end while
nextX = 0;
_l2 = 0;
while (_l2 < CAT_COUNT)
{
(BmacButtons[_l2]._x = BmacButtons[_l2].origX = nextX, nextX = nextX + (BmacButtons[_l2].mcName.mcText.txtText.textWidth / 2 + BmacButtons[_l2 + 1].mcName.mcText.txtText.textWidth / 2 + CATMENU_RESTSPACE));
_l2++;
} // end while
this.shiftBackItems();
}



function CatButton()
{
this.mcName.mcText.txtText.text = this.name;
this.hitArea = this.mcHitArea;
this.mcHitArea._visible = false;
this.folderName = "/" + this.name.toLowerCase() + "/";
this.mycol = new Color(this);
if (gCurURL != undefined && gCurURL == this.folderName)
{
this.mcName.gotoAndStop("selected");
this.enabled = false;
} // end if
} // End of the function
BmacNames = ["maps", "web", "news", "gmail", "PHOTOS", "LINKS"];
Can someone tell me why this isn't working?

Thanks

Dynamic Menu With Array And Loop
hi, i am trying to create a dynamic menu. i have used an array for the data and then used a loop to create the menu. i am now trying to add funcionality to the menu so that when a button is released...it will load another movie, etc. also...two of the buttons need to have drop downs...i created those using an array/loop as well but i can't figure out how to have it appear only when the button is rolled over. here is my code so far...any help or recommendations for other tutorials would be appreciated. thanks!









Attach Code

this.attachMovie("bkgrnd", "background", this.getNextHighestDepth());


var xPos = 10;
var yPos = 40;


var menuDepth:Array = new Array();
var metainfo:Array = new Array();
/
metainfo[0] = new Object();
metainfo[0].title = "button1";
metainfo[0].section = "button1";
metainfo[0].view = "button1";
metainfo[0].link = "/button1.html";
metainfo[0].data = new Array();
metainfo[0].data[0] = { title: "subnava", view: "subnava", subview: null, data: null, link:"/subnava.html" };
metainfo[0].data[1] = { title: "subnavb", view: "subnavb", subview: null, data: null, link:"/subnab.html" };
metainfo[0].data[2] = { title: "subnavc", view: "subnavc", subview: null, data: null, link:"/subnavc.html" };

metainfo[1] = new Object();
metainfo[1].title = "button2";
metainfo[1].section = "button2";
metainfo[1].view = "button2";
metainfo[1].link = "/button2.html";
metainfo[1].data = null;

metainfo[2] = new Object();
metainfo[2].title = "button3";
metainfo[2].section = "button3";
metainfo[2].view = "button3";
metainfo[2].link = "/button3.html";
metainfo[2].data = new Array();
metainfo[2].data[0] = { title: "subnava", view: "subnava", subview: null, data: null };

metainfo[3] = new Object();
metainfo[3].title = "button4";
metainfo[3].section = "button4";
metainfo[3].view = "button4";
metainfo[3].link = "/button4.html";
metainfo[3].data = null;


for (i=0; i<metainfo.length; i++) {
attachMovie("container", "nav"+i, menuDepth.push(this), {_x:xPos});
xPos += this["nav"+i]._width - 25;
this["nav"+i].label_txt.text = metainfo[i].title;
this["nav"+i].url_btn._url = metainfo[i].link;
this["nav"+i].view = metainfo[i].view;




if (metainfo[i].data!=null) {
for (j=0; j<metainfo[i].data.length; j++) {
attachMovie("subContainer", "subNav"+j, menuDepth.push(this), {_y:yPos});
yPos += this["subNav"+j]._height;
this["subNav"+j].subLabel_txt.text = metainfo[i].data[j].title;
this["subNav"+j].subUrl_btn._url = metainfo[i].data[j].link;
this["subNav"+j].view = metainfo[i].data[j].view;

}

}




}

Array-based Drop-down Menu
I'm trying to create an array based drop-down menu, or drop-up in this case. Can anyone help? Know of any tutorials? Any help would be appreciated!

Here's what I have so far. It basically just populates a multiline text field with each array item on a seperate line.


Code:
drop_array = new Array("item1", "item2", "item3");

for (i=0; i < drop_array.length; i++) {
drop_down.text += drop_array[i] + "
";
}

How To Place Array Menu Within Mc And Add Scrolling
I would like to to place a menu (that is created with arrays and dynamically created MCs and textfields inside a movie clip so that the content can be scrolled. Anyone know how to make this work? My experiments have failed so far. I'm using Flash X 2004. I'm guessing that the container clip would need a background with _alpha set to 0 to give the clip a visible width and height so that the scroller can be attached to it.

Files attached.

[AS3] Help With Dynamic XML Or Array Tree Menu
Hi everybody,

I am a AS3 newb, I have been playing with AS2 for a while but not with Class. Now, I like to create a dynamic XML or Array tree menu with customized graphic with AS3. I have learned some basic from the on-line examples but I have problem to addChild dynamically. Will anybody show me how to achieve that with some simple example?

Thanks in Advance.

Array-based Drop-down Menu
I'm trying to create an array based drop-down menu, or drop-up in this case. Can anyone help? Know of any tutorials? Any help would be appreciated!

Here's what I have so far. It basically just populates a multiline text field with each array item on a seperate line.


Code:
drop_array = new Array("item1", "item2", "item3");

for (i=0; i < drop_array.length; i++) {
drop_down.text += drop_array[i] + "
";
}

Copyright © 2005-08 www.BigResource.com, All rights reserved