Solved

Dynamic Menu Spacer

Posted on 2003-11-15
1
357 Views
Last Modified: 2010-04-03
How do I put a spacer of 50 pixels in between each category of this dynamic menu system and not have it put an additional 50 pixel spacer at the bottom?  This 50 pixel spacer should only insert if the there are two or more categories.  

Here's the link:  http://dev.fusionapps.com/wboe/flash/right_nav/flashmenu.html

Here's the code:

data_var = new LoadVars();
data_var.path = this;
data_var.onLoad = function(ok)
{
     if(ok){
          this.path.menuGeneration(this);
     } else {
          trace("CFM PAGE MISSING");    
     }
};

function menuGeneration()
{
     var startY = 1, depth = 0;
     var temp = data_var.cats.split("|");
      
                     //new TextFormat([font, [size, [color, [bold, [italic, [underline, [url, [target, [align, [leftMargin, [rightMargin, [indent, [leading]]]]]]]]]]]]])
     var style1_fmt = new TextFormat("textFont", "14", "0x000000", "bold", "false", "false", "", "", "center");
     var style2_fmt = new TextFormat("Verdana", "12", "0x000000", "true", "false", "false", "", "", "left", "3", "5", "");
     for(var i = 0; i < temp.length; i++){
          var mc = this.createEmptyMovieClip("main" + depth, depth);
          depth++;
          mc.lineStyle(1, 0x912211, 100);
          mc.beginFill(0xEDD593, 100);
          mc.lineTo(198, 0);     mc.lineTo(198, 20);     mc.lineTo(0, 20);     mc.lineTo(0, 0);
          mc.endFill();
          mc.createTextField("text_txt", "1", "0", "0", "198", "20"); //name, depth, x, y, width, height
          mc.text_txt.selectable = false;
          mc.text_txt.embedFonts = true;
          mc.text_txt.text = temp[i];
          mc.text_txt.setTextFormat(style1_fmt);
          mc._x = 1;     mc._y = startY;
          startY += mc._height + 4;
          var subText = data_var["subcats" + i].split("|");
          var subLink = data_var["urls" + i].split("|");
          for(var j = 0; j < subText.length; j++){
               var sc = this.createEmptyMovieClip("sub" + depth, depth);
               depth++;
               sc.createTextField("text_txt", "3", "0", "1", "198", "20");  //name, depth, x, y, width, height
               sc.text_txt.multiline = true;
               sc.text_txt.wordWrap = true;
               sc.text_txt.autoSize = "left";
               sc.text_txt.selectable = false;
               sc.text_txt.embedFonts = false;
               sc.text_txt.text = subText[j];
               sc.text_txt.setTextFormat(style2_fmt);
               var hgt = sc.text_txt._height + 2 > 20 ? sc.text_txt._height + 2 : 20;
               sc.lineStyle(1, 0x912211, 100);
               sc.lineTo(198, 0);     sc.lineTo(198, hgt);     sc.lineTo(0, hgt);     sc.lineTo(0, 0);
               sc._x = 1;     sc._y = startY;
               startY += sc._height + 4;
               var lc = sc.createEmptyMovieClip("click_btn", 2);
               lc._x = lc._y = 1;
               lc.lineStyle(0, 0, 0);
               lc.beginFill(0xEDD593, 100);
               lc.lineTo(197, 0);     lc.lineTo(197, hgt - 1);     lc.lineTo(0, hgt - 1);     lc.lineTo(0, 0);
               lc.endFill();     lc._alpha = 0;
               lc.link = subLink[j];
                     lc.onRollOver = function()     {     this._alpha = 100;               };
               lc.onRollOut = lc.onDragOut = function()     {     this._alpha = 0;               };
               lc.onPress = lc.onDragOver = function()     {     this._alpha = 100;               };
               lc.onRelease = function()          {     this.getURL(this.link);          };
                    
          }
     }
     delete data_var;
}
data_var.load("cats.cfm");
0
Comment
Question by:madasczik
1 Comment
 
LVL 27

Accepted Solution

by:
negatyve earned 500 total points
ID: 9754479
?

data_var = new LoadVars();
data_var.path = this;
data_var.onLoad = function(ok)
{
    if(ok){
         this.path.menuGeneration(this);
    } else {
         trace("CFM PAGE MISSING");    
     }
};

function menuGeneration()
{
    var startY = 1, depth = 0;
    var temp = data_var.cats.split("|");
     
      //new TextFormat([font, [size, [color, [bold, [italic, [underline, [url, [target, [align, [leftMargin, [rightMargin, [indent, [leading]]]]]]]]]]]]])
    var style1_fmt = new TextFormat("textFont", "14", "0x000000", "bold", "false", "false", "", "", "center");
    var style2_fmt = new TextFormat("Verdana", "12", "0x000000", "true", "false", "false", "", "", "left", "3", "5", "");
    for(var i = 0; i < temp.length; i++){
            if(depth > 0){
                  startY += 50;
                  trace("ADDED 50 SPACER")
            }
         var mc = this.createEmptyMovieClip("main" + depth, depth);
         depth++;
         mc.lineStyle(1, 0x912211, 100);
         mc.beginFill(0xEDD593, 100);
         mc.lineTo(198, 0);     mc.lineTo(198, 20);     mc.lineTo(0, 20);     mc.lineTo(0, 0);
         mc.endFill();
         mc.createTextField("text_txt", "1", "0", "0", "198", "20"); //name, depth, x, y, width, height
         mc.text_txt.selectable = false;
         mc.text_txt.embedFonts = true;
         mc.text_txt.text = temp[i];
         mc.text_txt.setTextFormat(style1_fmt);
         mc._x = 1;     mc._y = startY;
         startY += mc._height + 4;
         var subText = data_var["subcats" + i].split("|");
         var subLink = data_var["urls" + i].split("|");
         for(var j = 0; j < subText.length; j++){
              var sc = this.createEmptyMovieClip("sub" + depth, depth);
              depth++;
              sc.createTextField("text_txt", "3", "0", "1", "198", "20");  //name, depth, x, y, width, height
              sc.text_txt.multiline = true;
              sc.text_txt.wordWrap = true;
              sc.text_txt.autoSize = "left";
              sc.text_txt.selectable = false;
              sc.text_txt.embedFonts = false;
              sc.text_txt.text = subText[j];
              sc.text_txt.setTextFormat(style2_fmt);
              var hgt = sc.text_txt._height + 2 > 20 ? sc.text_txt._height + 2 : 20;
              sc.lineStyle(1, 0x912211, 100);
              sc.lineTo(198, 0);     sc.lineTo(198, hgt);     sc.lineTo(0, hgt);     sc.lineTo(0, 0);
              sc._x = 1;     sc._y = startY;
              startY += sc._height + 4;
              var lc = sc.createEmptyMovieClip("click_btn", 2);
              lc._x = lc._y = 1;
              lc.lineStyle(0, 0, 0);
              lc.beginFill(0xEDD593, 100);
              lc.lineTo(197, 0);     lc.lineTo(197, hgt - 1);     lc.lineTo(0, hgt - 1);     lc.lineTo(0, 0);
              lc.endFill();     lc._alpha = 0;
              lc.link = subLink[j];
              lc.onRollOver = function()     {     this._alpha = 100;               };
              lc.onRollOut = lc.onDragOut = function()     {     this._alpha = 0;               };
              lc.onPress = lc.onDragOver = function()     {     this._alpha = 100;               };
              lc.onRelease = function()          {     this.getURL(this.link);          };
                 
         }
    }
    delete data_var;
}
data_var.load("cats.cfm");
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now