• User Newbie

    scrolling orizontale

    Buon giorno ragazzi sono nuova di questo forum e di flash non mastico tanto.
    Vi espongo il mio problema: sto modificando il flash media player di jeroenwijering
    http://www.jeroenwijering.com/ per avere uno scrolling orizontale della lista di video flv.
    Sono riuscita a modificare alcuni script per avere l'autoscrolling orizzontale, solo che questo non si ferma all'inizio della lista e alla fine.
    Sarei grata a chiunque di voi voglia aiutarmi a risolvere questo problema.

    Ciao, Baci a tuttiimage

    di seguito la pagina di script che presumo sia alla base del problema:
    /**

    • Manages scrolling of a designated MovieClip, automatic or with scrollbar.
    • @example
    • var myScroller = new com.jeroenwijering.utils.Scroller(myMovie,myMask);
    • myscroller.scrollTo(200);
    • @author Jeroen Wijering
    • @version 1.7
      **/

    import com.jeroenwijering.utils.Animations;
    import com.jeroenwijering.utils.Draw;

    class com.jeroenwijering.utils.Scroller {

    /** Movieclip that should be scrolled /
    private var targetClip:MovieClip;
    /
    Mask of the movieclip /
    private var maskClip:MovieClip;
    /
    Use automatic scroling, defaults to false /
    private var autoScroll:Boolean = false;
    /
    scrollbar front color /
    private var frontColor:Number = 0x000000;
    /
    scrollbar highlighting color /
    private var lightColor:Number = 0x000000;
    /
    size ratio clip:mask /
    private var sizeRatio:Number;
    /
    scroll interval id for autoscroller and dragging of scrollbar /
    private var scrollInterval:Number;
    /
    corrent scroll index /
    private var currentScroll:Number = 0;
    /
    autoscroll multiplier /
    private var AUTOSCROLL_SPEED:Number = 0.1;
    /
    Movieclip the scrollbar is drawn into /
    private var SCROLLER_CLIP:MovieClip;
    /
    Color object of the scrollbar back /
    private var SCROLLER_BACK_COLOR:Color;
    /
    Color object of the scrollbar front **/
    private var SCROLLER_FRONT_COLOR:Color;

    /**

    • Sets up scrolling behaviour and scrollbar
    • @param tgt MovieClip that should be masked
    • @param msk Movieclip that shoulld be used as mask
    • @param asc (optional) Boolean for using autoscroll
    • @param fcl (optional) scrollbar color
    • @param hcl (optional) scrollbar rollover color
      **/
      function Scroller(tgt:MovieClip,msk:MovieClip,asc:Boolean,
      fcl:Number,hcl:Number) {
      targetClip = tgt;
      maskClip = msk;
      arguments.length > 2 ? autoScroll = asc: null;
      arguments.length > 3 ? frontColor = fcl: null;
      arguments.length > 4 ? lightColor = hcl: null;
      sizeRatio = maskClip._width/targetClip._width;
      if(autoScroll == false) {
      drawScrollbar();
      } else {
      scrollInterval = setInterval(this,"doAutoscroll",0);
      }
      var isMac = System.capabilities.os.toLowerCase().indexOf("mac" )!=-1;
      if(isMac && _root._url.indexOf("http://") > -1) {
      flash.external.ExternalInterface.addCallback(
      "externalMouseEvent",this,onMacMouseWheel);
      } else {
      Mouse.addListener(this);
      }
      };

    /** Draw the scrollbar. **/
    private function drawScrollbar() {
    targetClip._parent.createEmptyMovieClip("scrollbar ",
    targetClip._parent.getNextHighestDepth());
    SCROLLER_CLIP = targetClip._parent.scrollbar;
    SCROLLER_CLIP._x = 3;
    SCROLLER_CLIP._y = maskClip._y+30;
    SCROLLER_CLIP.createEmptyMovieClip("back",0);
    SCROLLER_CLIP.back._alpha = 0;
    SCROLLER_CLIP.back._y = maskClip._y+30;
    Draw.square(SCROLLER_CLIP.back,maskClip._width,20, frontColor);
    SCROLLER_CLIP.createEmptyMovieClip("bar",1);
    SCROLLER_CLIP.bar._x = 3;
    SCROLLER_CLIP.bar._alpha = 50;
    Draw.square(SCROLLER_CLIP.bar,maskClip._width,20,f rontColor);
    SCROLLER_CLIP.createEmptyMovieClip("front",2);
    SCROLLER_CLIP.front._x = 3;
    Draw.square(SCROLLER_CLIP.front,50,20,frontColor);
    SCROLLER_CLIP.front.createEmptyMovieClip("bg",1);
    SCROLLER_CLIP.front.bg._x = 3;
    SCROLLER_CLIP.front.bg._alpha = 0;
    Draw.square(SCROLLER_CLIP.front.bg,50,20,frontColo r);
    SCROLLER_FRONT_COLOR = new Color(SCROLLER_CLIP.front);
    setScrollbarEvents();
    };

    /** Set use of mousewheel to scroll playlist. **/
    public function onMouseWheel(dta:Number) {
    scrollTo(currentScroll-dta*20);
    };

    /** Set use of mousewheel to scroll playlist (MAC). **/
    function onMacMouseWheel(dta:Number) {
    scrollTo(currentScroll-dta*20);
    };

    /** Set autoscroll events. **/
    private function doAutoscroll() {

    if (
    maskClip._xmouse>0 && maskClip._xmouse<maskClip._width/
    (maskClip._xscale/100) && maskClip._ymouse>0 &&
    maskClip._ymouse<maskClip._height/(maskClip._yscale/100)) {
    var dif:Number = maskClip._xmouse*(maskClip._xscale/100)-maskClip._width/2;
    scrollTo(currentScroll+Math.floor(dif*AUTOSCROLL_S PEED));
    }
    };

    /** All scrollbar mouse events grouped together. **/
    private function setScrollbarEvents():Void {
    var instance:Scroller = this;
    SCROLLER_CLIP.front.onRollOver =
    SCROLLER_CLIP.back.onRollOver = function() {
    instance.SCROLLER_FRONT_COLOR.setRGB(instance.ligh tColor);
    };
    SCROLLER_CLIP.front.onRollOut =
    SCROLLER_CLIP.back.onRollOut = function() {
    instance.SCROLLER_FRONT_COLOR.setRGB(instance.fron tColor);
    };
    SCROLLER_CLIP.back.onPress = function() {
    if(this._xmouse > this._parent.front._x +
    this._parent.front._width) {
    instance.scrollTo(instance.currentScroll +
    instance.maskClip._width/2);
    } else if (this._xmouse < this._parent.front._x) {
    instance.scrollTo(instance.currentScroll -
    instance.maskClip._width/2);
    }
    };
    SCROLLER_CLIP.front.onPress = function() {
    this.startDrag(false,0,0,instance.SCROLLER_CLIP.ba r._width - this._width,0);
    instance.scrollInterval = setInterval(instance,"scrollTo",100);
    };
    SCROLLER_CLIP.front.onRelease =
    SCROLLER_CLIP.front.onReleaseOutside = function() {
    this.stopDrag();
    clearInterval(instance.scrollInterval);
    };
    scrollTo(maskClip._x - targetClip._x);
    };

    /**

    • Scroll the MovieClip to a given Y position.
    • @param yps The y position the clip should scroll to.
      **/
      public function scrollTo(xps:Number):Void {
      if(arguments.length == 0 && autoScroll == false) {
      xps = SCROLLER_CLIP.front._x*maskClip._width / SCROLLER_CLIP.front._width;
      }

    else if (xps>targetClip._width-maskClip._width) {
    xps = targetClip._width - maskClip._width;
    }
    Animations.easeTo(targetClip,targetClip._x - xps, maskClip._y);
    SCROLLER_CLIP.front._x = xps*SCROLLER_CLIP.front._width / maskClip._width;
    currentScroll = xps;
    };

    /** Remove the scrollbar from stage **/
    public function purgeScrollbar() {
    clearInterval(scrollInterval);
    Mouse.removeListener(this);
    scrollTo(0);
    SCROLLER_CLIP.removeMovieClip();
    };

    }


  • Super User

    Ciao cica e benvenuta nella sezione Flash 🙂

    Hai controllato anche queste 2 classi ?
    import com.jeroenwijering.utils.Animations;
    import com.jeroenwijering.utils.Draw;

    Il codice non è poco e purtroppo il tempo è quello che è... però appena ho un' oretta libera gli do un' occhiata. Mi dispiace ma al momento di più non posso fare 🙂


  • User Newbie

    Grazie flep per la tua attenzione.
    Si ho controllato le due classi:
    Per quanto ho capito la classe draw.as è funzionale solo alla creazione grafica della scroll bar, mentre più interessante è questa parte di codice presente nella classe animation.as che riporto:
    /**

    • Easing enterframe function for a Movieclip.
    • @param tgt MovieClip of the balloon to iterate
    • @param xps Final x position.
    • @param yps Final y position.
    • @param spd Speed of the ease (1 to 10)
      **/
      public static function easeTo(tgt:MovieClip,xps:Number,yps:Number,spd:Number):Void {
      arguments.length < 4 ? spd = 2: null;
      tgt.onEnterFrame = function() {
      this._x = xps-(xps-this._x)/(1+1/spd);
      this._y = yps-(yps-this._y)/(1+1/spd);
      if (this._x>xps-1 && this._x<xps+1 && this._y>yps-1 && this._y<yps+1) {
      this._x = Math.round(xps);
      this._y = Math.round(yps);
      delete this.onEnterFrame;
      }
      };
      };

    Oddio! sto diventando pazza!:o
    con tutto questo codice non sto capendo più nulla!:bho:
    Daii Flep, me lo dai un piccolo aiuto?
    Daiii!!!


  • User Attivo

    ciao cica e benvenuta, ma non fai prima a creare uno scroll orizzontale separato e puntare il video nel Player di http://www.jeroenwijering.com/ che sicuramente avrà un metodo per caricare video dinamicamente.:?


  • User Newbie

    Sarà ma al punto in cui sono arrivata (scrolling orizzontale funzionante), devo solo riuscire ad impostare i limiti oltre cui il target non deve andare.
    Oltretutto la stessa lista è formattata graficamente da un'altra classe.as PlaylistView.as, quindi realizzare un nuovo filmato mi porrebbe nuovi problemi d'integrazione.
    Qualcuno di voi sa dirmi come s'impostano i limiti del filmato target nel caso di uno scrolling orizzontale?
    Comunque grazie a tutti coloro che vorranno dedicarmi un pò del loro tempo:vai:


  • User Attivo

    ciao cica,function easeTo è sicuramente quella che produce il Motion Tween.

    Bisogna quindi individuare un LimiteMassimo di scroll. per poi forzare il movimento entro quel limite. Struttura una piccola modifica alla funzione sperando sia quella che gestisce il controllo X.

    public static function easeTo(tgt:MovieClip,xps:Number,yps:Number,spd:Num ber):Void {

    LarghezzaAreaAttiva = maskClip._width
    limitMax = tgt-LarghezzaAreaAttiva
    var percX:Number = (xps/limitMax*LarghezzaAreaAttiva);
    var newX:Number =(limitMax/LarghezzaAreaAttiva)percX;
    arguments.length < 4 ? spd = 2: null;
    tgt.onEnterFrame = function() {
    this._x = Math.round((this._x)+(((-newX)-this._x)/spd));
    /

    commento vecchio codice x animare x
    this._x = xps-(xps-this._x)/(1+1/spd);;
    */
    this._y = yps-(yps-this._y)/(1+1/spd)
    if (this._x>xps-1 && this._x<xps+1 && this._y>yps-1 && this._y<yps+1) {
    this._x = Math.round(xps);
    this._y = Math.round(yps);
    delete this.onEnterFrame;
    }
    };

    };

    get Try..


  • User Newbie

    Edo ho provato a fare come mi hai detto tu, ma il risultato è quello di bloccare lo scrolling. :arrabbiato:
    Sono stata stanotte fino alle tre a provare e riprovare ma niente, sono proprio confusa.😢
    Comunque molte grazie, così almeno so dove concentrare le mie attenzioni.
    Ragazzi pago da bere a chiunque mi tirerà fuori da questo casino! giuro!:fumato:


  • User Attivo

    @cica said:

    Edo ho provato a fare come mi hai detto tu, ma il risultato è quello di bloccare lo scrolling. :arrabbiato:
    Sono stata stanotte fino alle tre a provare e riprovare ma niente, sono proprio confusa.😢
    Comunque molte grazie, così almeno so dove concentrare le mie attenzioni.
    Ragazzi pago da bere a chiunque mi tirerà fuori da questo casino! giuro!:fumato:

    ehh ma io non so effettiavemnete non avendolo provato quale sia La funzione che gestisce Il controllo Mouse in questa classe. alla mia formula suggerita, dovrebbe arrivare tempestivamente
    la nuova posizione del mouse sull'area mask "" e non sulla root.

    Prova

    LarghezzaAreaAttiva = 400

    anzicchè

    LarghezzaAreaAttiva = maskClip._width

    non vorrei che non ti ritorna la largehzza giusta della maskera. per via delle variabili non globali e incluse nella funzione.

    Quindi gli output daverificare sarebbero

    trace(xps)
    trace(maskClip._width)
    trace(spd)

    resumando

    public static function easeTo(tgt:MovieClip,xps:Number,yps:Number,spd:Num ber):Void {

    trace(xps)
    trace(maskClip._width)
    trace(spd)
    LarghezzaAreaAttiva = 400

    limitMax = tgt-LarghezzaAreaAttiva
    var percX:Number = (xps/limitMax*LarghezzaAreaAttiva);
    var newX:Number =(limitMax/LarghezzaAreaAttiva)percX;
    arguments.length < 4 ? spd = 2: null;
    tgt.onEnterFrame = function() {
    this._x = Math.round((this._x)+(((-newX)-this._x)/spd));
    /

    commento vecchio codice x animare x
    this._x = xps-(xps-this._x)/(1+1/spd);;
    */
    this._y = yps-(yps-this._y)/(1+1/spd)
    if (this._x>xps-1 && this._x<xps+1 && this._y>yps-1 && this._y<yps+1) {
    this._x = Math.round(xps);
    this._y = Math.round(yps);
    delete this.onEnterFrame;
    }
    };

    };

    aggiornaci sugli output e non scoraggiarti. che ci siamo quasi


  • User Newbie

    Grazie edo! sei davvero gentile!:vai:
    Dopo pranzo provo con le indicazioni che mi hai dato e ti faccio sapere.
    Ciao


  • User Newbie

    Allora edo ho fatto i tentativi che mi hai suggerito.
    non riesco a fare i trace dei parametri, però posso dire che la larghezza della maschera corrisponde alla larghezza del filmato che in questo caso è di 400 px.
    ho impostato la funzione easeTo:
    public static function easeTo(tgt:MovieClip,xps:Number,yps:Number,spd:Number):Void {
    trace(xps)
    trace(spd)
    var LarghezzaAreaAttiva:Number = 400;
    var limitMax:Number = tgt._width-LarghezzaAreaAttiva;
    var percX:Number = (xps/limitMax*LarghezzaAreaAttiva);
    var newX:Number =(limitMax/LarghezzaAreaAttiva)*percX;
    arguments.length < 4 ? spd = 2: null;
    tgt.onEnterFrame = function() {
    this._x = Math.round((this._x)+(((-newX)-this._x)/spd));
    this._y = yps-(yps-this._y)/(1+1/spd);
    if (this._x>xps-1 && this._x<xps+1 && this._y>yps-1 && this._y<yps+1) {
    this._x = Math.round(xps);
    this._y = Math.round(yps);
    delete this.onEnterFrame;
    }
    };
    };

    questo è il risultato:http://www.pasticciotto.it/player/
    qualche idea?


  • User Newbie

    tieni conto che comunque imposti la var LarghezzaAreaAttiva il risultato non cambia


  • User Attivo

    ummm mi sà che va in conflitto
    puoi provare ad allegare il lfa?? e eventuali file correlati?


  • User Newbie

  • User Attivo

    scusa cica.. ma un esempio funzionale correlato dal difetto, come quello che ci hai linkato in anteprima che generi già quei box sottostanti, non riesci ad allegarmelo? trovo difficoltà a ricomporre il tutto. non ho tempo di studiarmi studiarmi questo video player. Sarei anche ben disposto. Se magari non desideri pubblicarne i sorgenti puoi inviarmi illink in pvt. vorrei almeno provarci dato che ho flash quasi sempre parto, e se si tratta di un piccolo bugs magari ci do una sistematina:yuppi:


  • User Newbie

    Ti chiedo scusa edo! non volevo abusare della tua pazienza e non voglio incasinarti.
    ho ritenuto giusto inviarti l'intero blocco di codici perchè pensavo potesse aiutarti.
    Comunque per quanto riguarda il mio problema sono solo tre classi ad avere importanza:
    /source/com/jeroenwijering/utils/scroller.as
    /source/com/jeroenwijering/utils/animations.as (alla riga 89)
    /source/com/jeroenwijering/players/playlistView.as attorno (alla riga 143)

    che sono poi i files che io ho modificato per avere lo scrolling orizzontale.

    la funzione easeTo si trova nel file scroller.as (attorno alla riga 177)
    e nel file animations.as (attorno alla riga 89)

    Grazie edo e se non hai tempo non importa.
    Per il resto sono a tua disposizione:ciauz: