Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    Ridimensionare mc: traduzione codice

    Salve a tutti!!
    C'é qualcuno di buon cuore che mi può "tradurre questo codice", con qualche spiegazione, in modo da poterne capire la tecnica?.. sto cercando di imparare la logica con la quale vengono scritte certe funzioni, ma da solo é un bel problema...



    //++++++++++++++++++++++++++++++++++++++++++++++++++ ++++
    // AUTHOR: Charles Miller, Simon Hooper, Braingiants.com
    // CREATED: March 22, 2006
    // LAST MODIFIED: May 9, 2006
    // Design, Educate, Teach, Inspire.
    //++++++++++++++++++++++++++++++++++++++++++++++++++ ++++
    fscommand("allowscale", false);
    //Creates a unique ID number for each bounce function call
    uniqueBounceID = 0;
    function bounce(param, endingVal, clipName, speedFactor, bounceFactor) {
    //Do not run if the clipName does not exist
    if (clipName._x<>undefined) {
    //Clear old setIntervals with same param name that might still be firing - prevents the clipName movie from being caught between two different parameter values
    clearInterval(_root["bounceInterval"+clipName[param+"ID"]]);
    //Reassign variables to make them private variables of the movie clip
    var bounceID = _root.uniqueBounceID++;
    clipName["param"+bounceID] = param;
    clipName["endingVal"+bounceID] = endingVal;
    clipName["speedFactor"+bounceID] = speedFactor;
    clipName["bounceFactor"+bounceID] = bounceFactor;
    clipName["startingParamVal"+bounceID] = clipName[param];
    clipName["changedParamVal"+bounceID] = 0;
    //Store the bounceID for this parameter into a variable in the clipName movieclip - used to clear the setInterval if the movie clip is removed before the function completes
    clipName[param+"ID"] = bounceID;
    //Bounce function called from the setInterval
    clipName["callBounce"+bounceID] = function () {
    //If the clip no longer exists, clear the setInterval
    if (clipName._x == undefined) {
    clearInterval(_root["bounceInterval"+bounceID]);
    } else {
    // Don't fire if the destination position is met
    if (clipName["endingVal"+bounceID]<>Math.round(clipName[clipName["param"+bounceID]])) {
    // Modify the changedParamVal by using a simple friction equation
    clipName["changedParamVal"+bounceID] = clipName["changedParamVal"+bounceID]*clipName["bounceFactor"+bounceID]+(clipName["endingVal"+bounceID]-clipName["startingParamVal"+bounceID])/clipName["speedFactor"+bounceID];
    // Increment the startingParamVal by the new changedParamVal
    clipName["startingParamVal"+bounceID] += clipName["changedParamVal"+bounceID];
    // Snaps bouncing object to the pixel to reduce blinking effect and keep fonts pixelized
    clipName[clipName["param"+bounceID]] = Math.round(clipName["startingParamVal"+bounceID]);
    } else {
    //Ensure final destination
    clipName[clipName["param"+bounceID]] = clipName["endingVal"+bounceID];
    // Clear the setInterval
    clearInterval(_root["bounceInterval"+bounceID]);
    }
    }
    //trace(clipName+" "+bounceID+":"+clipName["param"+bounceID]+" = "+clipName[clipName["param"+bounceID]]);
    };
    //Call the bounce function 100 times per second
    _root["bounceInterval"+bounceID] = setInterval(clipName["callBounce"+bounceID], 10);
    }
    }



    Spero nel vostro aiuto

  2. #2

    Re: Ridimensionare mc: traduzione codice

    Up!!

  3. #3
    ...up


Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.