Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 25-04-2005, 11:50   #1 (permalink)
pensionist
 
Benutzerbild von troner
 
Registriert seit: Jan 2003
Ort: Thalheim b. Wels
Beiträge: 568
Question problem mit meinem scroller mhhh...

hallo

ich habe am we begonnen mir einen scroller zubasteln!
funzt eigentlich auch schon soweit aber es gibt ein mir mysteriös
erscheinendes problem!

erstmal der code:
ActionScript:
  1. TextField.prototype.scroller = function(h_mcFarbe, h_mcLineFarbe, b_mcFarbe) {
  2.     var h_mc = mcCreator(this._name+"bg_mc", _root.getNextHighestDepth(), 11, this._height, h_mcFarbe, h_mcLineFarbe, 1, 100, this._x+this._width, this._y, false);
  3.     var b_mc = mcCreator(this._name+"_mc", _root.getNextHighestDepth(), 10, 50, b_mcFarbe, NULL, NULL, 100, this._x+this._width+1, this._y+1, true);
  4.     var t_mc = this;
  5.     var oben = this._y;
  6.     var unten = (t_mc._height+t_mc._y)-b_mc._height;
  7.     b_mc.onPress = function() {
  8.         var posOnMc = _root._ymouse-this._y;
  9.         ownCourser(true);
  10.         this.onEnterFrame = function() {
  11.             this.moveToY(_root._ymouse-posOnMc, t_mc._y, (h_mc._height+h_mc._y)-b_mc._height, 10);
  12.             t_mc.scroll = -(Math.round(((this._y-oben)/(this._height-t_mc._height))*t_mc.maxscroll));
  13.         };
  14.     };
  15.     b_mc.onRelease = b_mc.onReleaseOutside=function () {
  16.         ownCourser(false);
  17.         this.onEnterFrame = NULL;
  18.     };
  19. };
  20.  
  21. //hier ist mein problem
  22. MovieClip.prototype.moveToY = function(Y, Ymin, Ymax, speed) {
  23.     //funktioniert komischerweise nicht??
  24.     Y>=Ymin ? this._y += (Y-this._y)/speed : this._y=Ymin;
  25.     //das aber tadelos mhhh...
  26.     Y<=Ymax ? this._y += (Y-this._y)/speed : this._y=Ymax;
  27. };
  28.  
  29. //
  30. function mcCreator(mc, tiefe, breite, hoehe, hFrabe, bFarbe, lStarke, alpha, x, y, onOff) {
  31.     this[mc] = this.createEmptyMovieClip(mc, tiefe);
  32.     with (this[mc]) {
  33.         lineStyle(lStarke, bFarbe, alpha);
  34.         beginFill(hFrabe, alpha);
  35.         lineTo(0, 0);
  36.         lineTo(breite, 0);
  37.         lineTo(breite, hoehe);
  38.         lineTo(0, hoehe);
  39.         lineTo(0, 0);
  40.         endFill();
  41.     }
  42.     this[mc]._x = x;
  43.     this[mc]._y = y;
  44.     this[mc].enabled = onOff;
  45.     return this[mc];
  46. }
  47. function ownCourser(showOrHide) {
  48.     if (showOrHide) {
  49.         var mc = _root.attachMovie("upDown", "mc", _root.getNextHighestDepth());
  50.         Mouse.hide();
  51.         mc.onEnterFrame = function() {
  52.             mc._x = _root._xmouse;
  53.             mc._y = _root._ymouse;
  54.         };
  55.     } else {
  56.         mc.removeMovieClip();
  57.         Mouse.show();
  58.     }
  59. }

der balken läst sich oben aus seinem funktionbereich rausscheiben was nicht sein dürfte da:

ActionScript:
  1. //da ja hier überprüft wird ob dieser überschreiten und wenn zurücksetzt
  2. Y>=Ymin ? this._y += (Y-this._y)/speed : this._y=Ymin;

das ganze funzt aber bei der unteren grenze??

hab keinen dunst warum?!

hänge mal funktiontüchtige files an!
Angehängte Dateien
Dateityp: zip scroller_v_3.zip (8,5 KB, 5x aufgerufen)
troner ist offline   Mit Zitat antworten
Alt 25-04-2005, 14:01   #2 (permalink)
agedoubleju
Gast
 
Beiträge: n/a
Check doch mal selbst im Testmodus:
PHP-Code:
MovieClip.prototype.moveToY = function(YYminYmaxspeed) {
    
//funktioniert komischerweise nicht??
    
trace("\nYmin="+Ymin);
    
trace("Y="+Y);
    if(
Y>=Ymin) ? this._y += (Y-this._y)/speed this._y=Ymin;
    
//das aber tadelos mhhh...
    
trace("this._y="+this._y);
    (
Y<=Ymax) ? this._y += (Y-this._y)/speed this._y=Ymax;
    
trace("this._y="+this._y);
}; 
Wie du siehst, wird auch deine zweite if-Schleife immer durchlaufen und ändert beim Hochziehen des Reglers die y-Werte. Versuch mal aus den beiden if-Abfragen eine if-else-Abfrage zu machen...
  Mit Zitat antworten
Alt 25-04-2005, 15:00   #3 (permalink)
pensionist
 
Benutzerbild von troner
 
Registriert seit: Jan 2003
Ort: Thalheim b. Wels
Beiträge: 568
danke holger!

so hab ichs jetzt gemacht!

ActionScript:
  1. //statt
  2. Y>=Ymin ? this._y += (Y-this._y)/speed : this._y=Ymin;
  3. //so
  4. Y>=Ymin ? this._y += (Y-this._y)/speed : Y=Ymin;

mfg mario
troner 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 04:35 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele