Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 03-02-2004, 21:34   #1 (permalink)
not fast but furious
 
Registriert seit: Jan 2002
Beiträge: 429
Angry button-länge lässt sich nicht verändern

hallo

ich habe da ein kleines problem mit der unten aufgeführten funktion. bis jetzt ist die länge der einzelnen button auf 100 pixel festgelegt. wenn ich aber die grösse ändere, ist alles verschoben. komischerweise sehe ich da nicht, was in dem script falsch läuft.

das script soll button mit entsprechender beschriftung erzeugen. hinter den button liegt noch ein hintergrund. dieser soll eigentlich grösser bzw. kleiner werden, je nachdem wie die buttonlänge ist.

ActionScript:
  1. x_pos_main = 450;
  2. y_pos_main = 0;
  3.  
  4. s = new Sound();
  5. s.attachSound ("krach");
  6.  
  7. function buildSubMenu(wert){
  8.  
  9. cont = createEmptyMovieClip("mc_contain", 2);
  10. cont._x = x_pos_main;
  11. mc_x_pos = cont._x / 100;
  12.  
  13. txt_format = new TextFormat();
  14. txt_format.font = "pixelfont";
  15. txt_format.size = 8;
  16. txt_format.color=0xFFFFFF;
  17.  
  18. arrText1 = [['OPEN','home'],['USEFUL TOOLS','skills'],['PIXELFONTS','dl']];
  19. arrText2 = [['TUTORIALS','tut'],['FUNNY STUFF','fun'],['FREE SCRIPTS','scr']];
  20.  
  21. arrName = wert;
  22.  
  23. for(i=0;i<=_root[wert].length-1;i++) {
  24.  
  25. var length_button = 100;
  26. var dist_button = 1;
  27.  
  28. tmpObj = _root.mc_contain.attachMovie("mc_fade_button", "mc_fade"+i, i, {_x:(length_button+dist_button)*(i-1)});
  29.                
  30. tmpObj._y = y_pos_main;
  31. tmpObj._width = length_button; // breite button
  32. tmpObj._height = 20;         // hoehe button
  33. tmpObj.id = i;
  34.  
  35. mc_width = tmpObj._width;
  36. mc_height = tmpObj._height;
  37. x_pos = (tmpObj._x-(tmpObj._width/2))+_root.mc_x_pos*tmpObj._width;
  38. y_pos = tmpObj._y-(tmpObj._height/2);
  39.  
  40.  
  41. // erstelle beschriftungen
  42. tempText = _root.createTextField("txt_sub"+i, i+100, Math.round(x_pos), Math.round(y_pos), Math.round(mc_width), 30);
  43. tempText = _root["txt_sub"+i];
  44. tempText.text = _root[wert][i][0];
  45. weite = _root["txt_sub"+i].textWidth;
  46. length_button = weite;
  47.  
  48. tempText.embedFonts = true;
  49. tempText.selectable = false;
  50. tempText.autoSize = "center";
  51. tempText.setTextFormat(txt_format);
  52.  
  53. // zeichne hintergrund für button
  54. x_pos_rect = x_pos;
  55. y_pos_rect = y_pos;
  56.  
  57. length_rect = tmpObj._width + (_root[wert].length-1);
  58. heigth_rect = tmpObj._height;
  59.  
  60. mc = createEmptyMovieClip('mc'+i, i-10);
  61. mc._x = x_pos_rect;
  62. mc._y = y_pos_rect;
  63. mc.beginFill(0x000000);
  64. mc.lineTo (length_rect, 0);
  65. mc.lineTo (length_rect, heigth_rect);
  66. mc.lineTo (0, heigth_rect);
  67. mc.lineTo (0, 0);
  68. mc.endFill();
  69.  
  70.  // button-fade funktionen
  71.  tmpObj.mc_button.onEnterFrame = function() {
  72.  !this.doit ? this.prevFrame() : this.nextFrame();
  73.  };
  74.                
  75.  tmpObj.mc_button.bt_invisible.onRollOver = function() {
  76.  this._parent.doit = true;
  77.  };
  78.              
  79.  tmpObj.mc_button.bt_invisible.onRelease = function() {
  80.  // getURL("javascript:"+arrText[this._parent._parent.id][1]+"()");
  81.  s.start(0,1)   //die 1 ist die wiederholungszahl
  82.  }
  83.    
  84.  tmpObj.mc_button.bt_invisible.onRollOut = function() {
  85.  this._parent.doit = false;
  86.  };
  87.  
  88. }
  89.  
  90. }
  91.  
  92.  
  93. bt_mk1.onRelease = function(){
  94.  buildSubMenu('arrText1');
  95. }
  96.  
  97. bt_mk2.onRelease = function(){
  98.  buildSubMenu('arrText2');
  99. }
  100.  
  101.  
  102. // loeschen des ganzen
  103. _root.mc_sub.bt_invisible.onRelease = function(){
  104.  
  105.  cont.removeMovieClip();
  106.  mc_sub._visible = false;
  107.  
  108.  for (i=0; i<_root[arrName].length; i++) {
  109.   _root["txt_sub"+i].removeTextField();
  110.   _root["mc"+i].unloadMovie();
  111.  }
  112.  
  113. }

es wäre nett, wenn ihr mir weiterhelfen könntet.

bis dann, lionhead
__________________
There is no spoon! Neo - Matrix

www.web-und-service.com
LionHead ist offline   Mit Zitat antworten
Antwort

Lesezeichen

Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks sind an
Pingbacks sind an
Refbacks sind an



Alle Zeitangaben in WEZ +1. Es ist jetzt 00:24 Uhr.

Domains, Webhosting & Vserver von Host Europe
Unterstützt das Flashforum!
Adobe User Group


Copyright ©1999 – 2012 Marc Thiele