Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 04-03-2006, 19:52   #1 (permalink)
Digger2k3
Gast
 
Beiträge: n/a
Dynamischer Abstand etwas schwer zu realisieren

Hallo zusammen,

ich stehe wiedermal voll aufm Schlauch und kann wieder mal sehr gut eure klugen Köpfe gebrauchen - bzw. ich bitte euch darum die mir mal kurz auszuleihen

Spaß bei Seite... ich habe das Problem, dass ich drei MCs habe, die beim Klicken ihre Größe verändern, so weit so gut, jedoch möchte ich gerne, dass sie sich immer aneinander orientieren wo sie grade sein sollten, damit der Abstand gleich bleibt, ich bekomme das einfach net hin.

Hier mal mein Versuch

ActionScript:
  1. var farb_zielScaleY:Number = 100;
  2. var farb_zielScaleX:Number = 100;
  3. var button_zielScaleY:Number = 100;
  4. var button_zielScaleX:Number = 100;
  5. var zielScaleY:Number = 100;
  6. var zielScaleX:Number = 100;
  7. var ausfaden:Boolean = false;
  8.  
  9. MovieClip.prototype.farb_button_alpha = function (ausfaden:Boolean) {
  10.     this.farb_mc.onEnterFrame = function() {
  11.         if (ausfaden == true) {
  12.             if (this._alpha > 0) {
  13.                 this._alpha -= 10;
  14.             } else {
  15.                 delete this.onEnterFrame;
  16.             }
  17.         } else if (ausfaden == false) {
  18.             if (this._alpha < 100) {
  19.                 this._alpha += 6;
  20.             } else {
  21.                 delete this.onEnterFrame;
  22.             }
  23.         }
  24.     }
  25. };
  26. MovieClip.prototype.button_grosse = function(zielScaleY:Number, zielScaleX:Number, farb_sichtbar:Boolean, abstandsMC:String) {
  27.     this.onEnterFrame = function() {
  28.         if (abstandsMC != "none") {
  29.             this._x = (_root[abstandsMC+"_mc"]._x) + (_root[abstandsMC+"_mc"]._width/2) + 80;
  30.         }
  31.         this._yscale -= Math.round((this._yscale-zielScaleY)/3);
  32.         this._xscale -= Math.round((this._xscale-zielScaleX)/3);
  33.         this.farb_mc._visible = farb_sichtbar;
  34.     };
  35. }
  36. _root.home_mc.onRollOver = function() {
  37.     this.farb_button_alpha(true);
  38. }
  39. _root.home_mc.onRollOut = onDragOut = function() {
  40.     this.farb_button_alpha(false);
  41. }
  42. _root.home_mc.onPress = onRelease = onReleaseOutside = onDragOut = function() {
  43.     this.button_grosse(100, 150, false, "none");
  44.     _root.about_mc.button_grosse(100,100, true, "home");
  45.     _root.projekte_mc.button_grosse(100,100, true, "about");
  46. }
  47. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  48. _root.about_mc.onRollOver = function() {
  49.     this.farb_button_alpha(true);
  50. }
  51. _root.about_mc.onRollOut = function() {
  52.     this.farb_button_alpha(false);
  53. }
  54. _root.about_mc.onPress = onRelease = onReleaseOutside = onDragOut = function() {
  55.     this.button_grosse(100, 150, false, "home");
  56.     _root.home_mc.button_grosse(100,100, true, "none");
  57.     _root.projekte_mc.button_grosse(100,100, true, "about");
  58. }
  59. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  60. _root.projekte_mc.onRollOver = function() {
  61.     this.farb_button_alpha(true);
  62. }
  63. _root.projekte_mc.onRollOut = function() {
  64.     this.farb_button_alpha(false);
  65. }
  66. _root.projekte_mc.onPress = onRelease = onReleaseOutside = onDragOut = function() {
  67.     this.button_grosse(100, 150, false, "about");
  68.     _root.home_mc.button_grosse(100,100, true, "none");
  69.     _root.about_mc.button_grosse(100,100, true, "home");
  70. }

Ich habe euch auch die fla nochmal angehangen, weil sich das hier nur so als Code bestimmt net gut macht ...

Ich würde mich tierisch über eure Hilfe freuen - wie immer - und DANKE sage ich auch schon im Voraus.

Gruß

Tino
Angehängte Dateien
Dateityp: rar button_test.rar (6,9 KB, 6x aufgerufen)
  Mit Zitat antworten
Alt 04-03-2006, 22:30   #2 (permalink)
brand new user
 
Benutzerbild von RustyCake
 
Registriert seit: May 2002
Ort: Laimbach 6 1/2
Beiträge: 16.884
Servus.
Ich hab mal vor zwei Jahren an so einem Teil rumgebastelt, habs niocht komplett fertig gemacht, und es ist im MX Style!
PHP-Code:
var mcs = ["mc1""mc2""mc3""mc4""mc5"];
var 
kord = [];
MovieClip.prototype.make = function(koordXwidthXspeed) {
    if (
this._x != koordX || this._width != widthX) {
        
this.onEnterFrame = function() {
            var 
deltaX this._x-koordX;
            var 
gamaX this._width-widthX;
            var 
dist Math.sqrt(deltaX*deltaX);
            var 
dist2 Math.sqrt(gamaX*gamaX);
            var 
moveX speed*(deltaX/dist);
            var 
move2X speed*(gamaX/dist2);
            if (
speed>=dist && speed>=dist2) {
                
this._x koordX;
                
this._width widthX;
                
delete this.onEnterFrame;
            } else {
                
this._x -= moveX;
                
this._width -= move2X;
            }
        };
    }
};
MovieClip.prototype.fader = function(ab) {
    
this.onEnterFrame = function() {
        if (
Math.round(this._alpha)<a) {
            
this._alpha Math.round(this._alpha += b);
        } else if (
Math.round(this._alpha)>a) {
            
this._alpha Math.round(this._alpha -= b);
        } else {
            
delete this.onEnterFrame;
        }
    };
};
for (var 
0i<mcs.lengthi++) {
    
kord.push(this[mcs[i]]._x);
    
this[mcs[i]].onRollOver = function() {
        
this.fader(805);
    }
    
this[mcs[i]].onRollOut = function() {
        
this.fader(1005);
    }
    
this[mcs[i]].onPress onRelease onReleaseOutside onDragOut= function() {
        
this._name.slice(23);
        
temp mcs.slice(wmcs.length);
        for (var 
wj<mcs.lengthj++) {
            
this._parent[mcs[j]] != this this._parent[mcs[j]].make(kord[j]+20805) : this.make(kord[j], 12010);
        }
        for (var 
0j<wj++) {
            
this._parent[mcs[j]] != this this._parent[mcs[j]].make(kord[j]-20805) : this.make(kord[j], 12010);
        }
    };

Angehängte Dateien
Dateityp: zip strech_btns.zip (3,3 KB, 7x aufgerufen)
__________________
Bitte keine Fragen, zu Flash per PM. Dazu ist das Forum da. Danke MFG_RustyCake!
"Wer tanzen will, muß erst gehen lernen"
RustyCake ist offline   Mit Zitat antworten
Alt 06-03-2006, 12:02   #3 (permalink)
Digger2k3
Gast
 
Beiträge: n/a
Hi Rusty,

sorry für die späte Antwort, aber ich habe seltsamerweise keine Mail bekommen.
Komisch ...

Danke für deine Variante .... die muss ich mir gleich mal anschauen, ich habe das mal so "gelöst":

ActionScript:
  1. var ScaleX:Number;
  2. var ScaleY:Number;
  3. var newX:Number;
  4.  
  5. MovieClip.prototype.skalieren = function (ScaleX:Number, ScaleY:Number, newX:Number) {
  6.     this.onEnterFrame = function() {
  7.         this._width -= Math.round((this._width - ScaleX)/3);
  8.         this._height -= Math.round((this._height - ScaleY)/3);
  9.         this._x -= Math.round((this._x -newX)/3);
  10.     }
  11. }
  12.  
  13. _root.home_mc.onPress = function() {
  14.     this.skalieren(250,450, 100);
  15.     _root.about_mc.skalieren(150,150,100 + 220);
  16.     _root.arbeiten_mc.skalieren(150,150,100 + 390);
  17.     _root.projekte_mc.skalieren(150,150,100 + 560);
  18. }
  19.  
  20. _root.about_mc.onPress = function() {
  21.     this.skalieren(250,350, 250);
  22.     _root.home_mc.skalieren(150,150,250- 220);
  23.     _root.arbeiten_mc.skalieren(150,150,250 + 220);
  24.     _root.projekte_mc.skalieren(150,150,250 + 390);
  25. }
  26.  
  27. _root.arbeiten_mc.onPress = function() {  // Hier müsste ich nochmal überarbeiten, wegen der Neuzuweisung der X-Werte, bei den ersten beiden hauts schon hin
  28.     this.skalieren(250, 400, this._x);
  29.     _root.home_mc.skalieren(150,150,this._x - 390);
  30.     _root.about_mc.skalieren(150,150,this._x - 220);
  31.     _root.projekte_mc.skalieren(150,150,this._x + 220);
  32. }
  33.  
  34. _root.projekte_mc.onPress = function() {
  35.     this.skalieren(250,400,this._x);
  36.     _root.home_mc.skalieren(150,150,this._x - 560);
  37.     _root.about_mc.skalieren(150,150,this._x - 390);
  38.     _root.arbeiten_mc.skalieren(150,150,this._x - 220);
  39. }

Nachteil bei mir ist nur, dass mal halt die Abstände im Script angeben muss und es somit nicht wirklich dynamisch ist ... ... aber vielleicht schaffe ich das ja noch ... wenn nicht, dann bastel ich mir einfach aus deiner supi funktionierenden Variante was zusammen :P

Gruß und fettes DANKE

Tino

Geändert von Digger2k3 (06-03-2006 um 12:04 Uhr)
  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:31 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele