Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 31-01-2004, 14:17   #1 (permalink)
not fast but furious
 
Registriert seit: Jan 2002
Beiträge: 429
Arrow problem mit buttonlänge bei dyn. erzeugten button

hallo

ich erstelle da ein menü bestehend aus den button, den beschriftungen sowie einem hintergrund. soweit so gut. eigentlich müsste es ja so funktionieren, dass beim ändern des wertes für die button-breite auch der hintergrund ändert. wenn ich den wert ändere haut mir flash alles durcheinander :( momentan steht der wert auf 100px. es soll aber jeder wert gehen. warum macht das script das nicht, es müsste doch eigentlich funktionieren.

die button sind versehen mit einem colorfade-effekt und müssten sich auch ganz normal skalieren lassen.

hier habe ich mal das script:

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

bei bedarf kann ich auch eine beispieldatei anhängen.

also ich bin überfordert. ich finde den fehler nicht. für mich sieht alles richtig aus. das ist es aber wohl nicht :(

könnt ihr einen fehler entdecken?

ich bin immer für kürzungen des codes offen. also gebt mir anregungen :)

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 05:02 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele