|
Best form of drag movies
/**********************************************************
best form of dragin a movieClip
simply copy and paste on flash this prototype
**********************************************************/
_global.MovieClip.prototype.moveMe=function()
{
if((arguments[0]==true)||(typeof(arguments[0])=="undefined"))
{
this.onMouseMove=function()
{
this._x=/:_xmouse;
this._y=/:_ymouse;
updateAfterEvent();
}
}
if(arguments[0]==false)
{
delete this.onMouseMove;
}
}
myMovie.moveMe();//myMovie is a MovieClip in the root
//this command drag myMovie in the stage
//to stopDrag use:
myMovie.moveMe(false);
Posted by: Victor Fernandes fogaça | website http://www.oscobras.cjb.net |
// Drawing a rectangle with corner radius option and inner bevel gradient fill. // // 2005 by www.advance-media.com // // width of the rectangle xWidth = 600; // height of the rectangle. Setting the width or height to 2 times the value of the cornerRadius creates a navigation pill. yHeight = 400; // size of the gradient bevel fill bevel = 66; // corner radius. Set to zero to draw a rectangle with bevel but without round corners. The corner radius should be greater than the bevel size. cornerRadius = 133; // outer hexadecimal color of the rectangles gradient fill color1 = 0x000000; // outer color alpha alpha1 = 100; // inner hexadecimal color of the rectangles gradient fill color2 = 0x00ff00; // inner color alpha. Set alpha to zero to create a mask effect alpha2 = 23; // creating a MovieClip for the filled rectangle, draw all its pieces in one MC to avoid scaling problems this.createEmptyMovieClip("rectangle", 69); // stop the created movieClip, cpu usage this.rectangle.stop(); // draw a rectangle with bevel gradient fill and with corner radius if (cornerRadius) { // A corner radius small than the bevel is not supported if (cornerRadius<bevel) { // setting the bevel as minimum value of the corner radius cornerRadius = bevel; } // calculating the hexadecimal value of the ratio of the radial fill in accordance to the set bevel value radialBevelRatio = Math.round(255/cornerRadius*(cornerRadius-bevel)); // begin to draw with (this.rectangle) { // draw four corner pieces and four side pieces, starting with the top left corner beginGradientFill("radial", [color2, color1], [alpha2, alpha1], [radialBevelRatio, 255], {matrixType:"box", x:0, y:0, w:2*cornerRadius, h:2*cornerRadius, r:0}); lineTo(cornerRadius, 0); lineTo(cornerRadius, cornerRadius); lineTo(0, cornerRadius); endFill(); // left side beginGradientFill("linear", [color1, color2], [alpha1, alpha2], [0, 255], {matrixType:"box", x:0, y:0, w:bevel, h:bevel, r:0}); moveTo(0, cornerRadius); lineTo(bevel, cornerRadius); lineTo(bevel, yHeight-cornerRadius); lineTo(0, yHeight-cornerRadius); endFill(); // top side beginGradientFill("linear", [color1, color2], [alpha1, alpha2], [0, 255], {matrixType:"box", x:0, y:0, w:bevel, h:bevel, r:(90/180)*Math.PI}); moveTo(cornerRadius, 0); lineTo(xWidth-cornerRadius, 0); lineTo(xWidth-cornerRadius, bevel); lineTo(cornerRadius, bevel); endFill(); // top right corner beginGradientFill("radial", [color2, color1], [alpha2, alpha1], [radialBevelRatio, 255], {matrixType:"box", x:xWidth-2*cornerRadius, y:0, w:2*cornerRadius, h:2*cornerRadius, r:0}); moveTo(xWidth-cornerRadius, 0); lineTo(xWidth, 0); lineTo(xWidth, cornerRadius); lineTo(xWidth-cornerRadius, cornerRadius); endFill(); // bottom left corner beginGradientFill("radial", [color2, color1], [alpha2, alpha1], [radialBevelRatio, 255], {matrixType:"box", x:0, y:yHeight-2*cornerRadius, w:2*cornerRadius, h:2*cornerRadius, r:0}); moveTo(0, yHeight-cornerRadius); lineTo(cornerRadius, yHeight-cornerRadius); lineTo(cornerRadius, yHeight); lineTo(0, yHeight); endFill(); // bottom side beginGradientFill("linear", [color1, color2], [alpha1, alpha2], [0, 255], {matrixType:"box", x:0, y:yHeight-bevel, w:bevel, h:bevel, r:(270/180)*Math.PI}); moveTo(cornerRadius, yHeight); lineTo(cornerRadius, yHeight-bevel); lineTo(xWidth-cornerRadius, yHeight-bevel); lineTo(xWidth-cornerRadius, yHeight); endFill(); // bottom right corner beginGradientFill("radial", [color2, color1], [alpha2, alpha1], [radialBevelRatio, 255], {matrixType:"box", x:xWidth-2*cornerRadius, y:yHeight-2*cornerRadius, w:2*cornerRadius, h:2*cornerRadius, r:0}); moveTo(xWidth-cornerRadius, yHeight-cornerRadius); lineTo(xWidth, yHeight-cornerRadius); lineTo(xWidth, yHeight); lineTo(xWidth-cornerRadius, yHeight); endFill(); // right side beginGradientFill("linear", [color1, color2], [alpha1, alpha2], [0, 255], {matrixType:"box", x:xWidth-bevel, y:0, w:bevel, h:bevel, r:Math.PI}); moveTo(xWidth-bevel, cornerRadius); lineTo(xWidth, cornerRadius); lineTo(xWidth, yHeight-cornerRadius); lineTo(xWidth-bevel, yHeight-cornerRadius); endFill(); // if the center of the rectangle is filled if (alpha2) { // drawing the solid color filled center piece in accordance to the corners beginFill(color2, alpha2); moveTo(cornerRadius, cornerRadius); lineTo(cornerRadius, bevel); lineTo(xWidth-cornerRadius, bevel); lineTo(xWidth-cornerRadius, cornerRadius); lineTo(xWidth-bevel, cornerRadius); lineTo(xWidth-bevel, yHeight-cornerRadius); lineTo(xWidth-cornerRadius, yHeight-cornerRadius); lineTo(xWidth-cornerRadius, yHeight-bevel); lineTo(cornerRadius, yHeight-bevel); lineTo(cornerRadius, yHeight-cornerRadius); lineTo(bevel, yHeight-cornerRadius); lineTo(bevel, cornerRadius); endFill(); } } } else { // draw a rectangle with bevel but without round corners with (this.rectangle) { // drawing 4 sides, starting with the top side beginGradientFill("linear", [color1, color2], [alpha1, alpha2], [0, 255], {matrixType:"box", x:0, y:0, w:bevel, h:bevel, r:(90/180)*Math.PI}); lineTo(bevel, bevel); lineTo(xWidth-bevel, bevel); lineTo(xWidth, 0); endFill(); // left side beginGradientFill("linear", [color1, color2], [alpha1, alpha2], [0, 255], {matrixType:"box", x:0, y:0, w:bevel, h:bevel, r:0}); moveTo(0, 0); lineTo(bevel, bevel); lineTo(bevel, yHeight-bevel); lineTo(0, yHeight); endFill(); // bottom beginGradientFill("linear", [color1, color2], [alpha1, alpha2], [0, 255], {matrixType:"box", x:0, y:yHeight-bevel, w:bevel, h:bevel, r:(270/180)*Math.PI}); moveTo(0, yHeight); lineTo(bevel, yHeight-bevel); lineTo(xWidth-bevel, yHeight-bevel); lineTo(xWidth, yHeight); endFill(); // right beginGradientFill("linear", [color1, color2], [alpha1, alpha2], [0, 255], {matrixType:"box", x:xWidth-bevel, y:bevel, w:bevel, h:bevel, r:Math.PI}); moveTo(xWidth, yHeight); lineTo(xWidth-bevel, yHeight-bevel); lineTo(xWidth-bevel, bevel); lineTo(xWidth, 0); endFill(); // if the center of the rectangle is filled if (alpha2) { // draw the solid colored center rectangle piece beginFill(color2, alpha2); moveTo(bevel, bevel); lineTo(xWidth-bevel, bevel); lineTo(xWidth-bevel, yHeight-bevel); lineTo(bevel, yHeight-bevel); endFill(); } } } Posted by: Folko Langner | website http://www.advance-media.com |
//function by missing-link
//Create a text field and add text
_root.createTextField("myText",0,0,0,150,150);
myText.text="Blinking letters";
//Create our start text format
start = new TextFormat();
start.size = 20;
start.color = (0x000000);
start.align="center";
//create the blink format and make it however you wish
blink = new TextFormat();
blink.color = (0xFF0000);
blink.underline=true;
//Set another text format to make each letter go back to normal
//make sure it counteracts the blink format
clear = new TextFormat();
clear.color = (0x000000);
clear.underline=false;
//set the initial format
myText.setTextFormat(start);
//this function will go through each letter and set the blink format
TextField.prototype.blinkingLetters = function () {
if(i<=this.text.length){
this.setTextFormat(i,i+1, blink);
i++;
}else{
//this resets the variable i
i=0;
}
//this cleans each letter after the format has gone through
this.setTextFormat(i-3, i-1, clear);
}
//Run the function
_root.onEnterFrame = function (){
myText.blinkingLetters();
}Posted by: missing-link | website http://www.evolutionar-e.com |
/* Class buildMatrix builds an grafic effect usage: set a 10x10 pix movieclip with id name "mcItem" and have fun! code by www.flash.andihaas.de */ function buildMatrix(hoch, weit, zb, anz) { var mytl = this; var temp_xarr = []; var temp_yarr = []; var c = 0; for (i=0; i<anz; i++) { mytl.attachMovie("mcItem", 'btn'+i, i, {_x:2500, _y:0}); temp_xarr.push((i%zb)*(weit)); temp_yarr.push(Math.floor(i/zb)*(hoch)); } this.doOnPos = function() { mytl["btn"+c].slideTo(temp_yarr[c], temp_xarr[c], 4); c<anz ? c++ : (clearInterval(setter), trace("Ready!!")); }; setter = setInterval(doOnPos, 100); } MovieClip.prototype.slideTo = function(w, h, speed) { h = Math.floor(h); w = Math.floor(w); this.onEnterFrame = function() { this._x += ((h-Math.round(this._x))/speed); this._y += ((w-Math.round(this._y))/speed); if (Math.round(this._y) == h && Math.round(this._x) == w) { delete this.onEnterFrame; } }; }; // aufruf function onMouseDown() { buildMatrix(20, 20, 10, 50); } Posted by: andi haas | website http://www.flash.andihaas.de |
// CharSkipper for Flash by Jochen Preusche / www.jochenpreusche.de // Version 1.0 | july — august 2004 // You may use this script for free in your own projects. // please leave this lines intact. thanks! // --> requires A button named: BTN_Start :to get it running. <-- // check this adress to see it in action: // http://www.jochenpreusche.de/Invisible_Items/CharSkipperFlash.htm // features: // • calculates from one Text to another by skipping each character that isn't equal to the target char. // • Handles any character. // • Editable and Self-completing character index (this is toadjust the skip effect). // important notes: // Line Feed (\r) in the Text causes irritating extra breaks during the calculation process : // to avoid this write a function that counts the LineFeeds, filters them out of calc-string // and makes appear only LFs at accurate positions // simpler but less flexible: use more TextFields than one. // to reduce calc-steps and time: use only lowerCase-Chars or only upperCase-chars. // some characters need to be prepared with a backslash - So ' becomes \' — otherwise it is part of ActionScript // I would appreciate any comments & improvements. Please contact me via my website. // check my website to see how I recreated it for AfterEffects 6.x Text0='From text'; Text1='To text'; // jam the text-chars together to find Chars that are not in the CharIndex-array allChars=Text0+Text1; // if you're using dynamic text: don't forget to update the char index: // • define allchars by jamming your vars together // • completeCharIndex (CI); // • delete allChars; // so you can use really ANY character in your variables. // Char Index: feel free to edit it: only one char each array-item CI = [' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']; CIString = CI.join(''); completeCharIndex (CI); delete allChars; function completeCharIndex (CI){ for (i=0; (i<=allChars.length); i++){ checkThisChar = allChars.substr(i,1); if (CIString.indexOf(allChars.substr(i,1))<0){ CI[(CI.length)]=allChars.substr(i,1); CIString = CI.join(''); } } } _root.createTextField('TF_1', 10, 0, 0, 600, 100); TF_1.multiline = true; TF_1.wordWrap = true; TF_1.border = '1'; Format = new TextFormat(); Format.font = 'Courier New'; Format.color = 0x333333; Format.size = 14; TF_1.text = Text0; TF_1.setTextFormat(Format); function writeCurText (CurText) { TF_1.text = CurText; TF_1.setTextFormat(Format); } BTN_Start.onRelease = function() { FTCNumA = []; // From Text -Char -Number -Array : empty TTCNumA = []; // To Text -Char -Number -Array : empty CurStrNumA = []; // Current String Number Array CurStrA = []; // Current String Array FromText=Text0; ToText=Text1; CalcCurText(FromText, ToText); } function getCINum (Char){ CINum = CIString.indexOf(Char); } // fromText Create Char arrays function CreateFTCAs (catlos, FromText, ToText){ if (FTCA<=0){FTCA = [];} // if there is no such array, create one for(i=0; (i<=catlos); i++){ FromTextCharAt = FromText.substr(i, 1); if(i>=FromText.length){FTCA[i] = ' ';} // could also be any other char from the charArray above else {FTCA[i] = FromText.substr(i, 1);}; // FTCA => array with the chars ot text FromText getCINum (FTCA[i]); FTCNumA[i] = CINum; CurStrA = FTCA; // FTCNumA => array with the char Index Numbers ot text FromText } } // ToText Create Char arrays function CreateTTCAs (catlos, FromText, ToText){ if (TTCA<=0){TTCA = [];} // if there is no such array, create one for(i=0; (i<=catlos); i++){ ToTextCharAt = ToText.substr(i, 1); if(i>=ToText.length){TTCA[i] = ' ';} // could also be any other char from the charArray above else {TTCA[i] = ToText.substr(i, 1);}; // TTCA => array with the chars ot text ToText getCINum (TTCA[i]); TTCNumA[i] = CINum; // TTCNumA => array with the char Index Numbers ot text ToText } } // Current Char function getCurChar (catlos, CurStrNumA, TTCNumA) { if ((CurStrNumA[CPos])!= (TTCNumA[CPos])){ tempCPos = ((CurStrNumA[CPos])+1)%(CI.length) CurStrNumA[CPos] = tempCPos; CurChar = CI[tempCPos]; } else{CurChar = CurStrA[CPos];} } // Current String function getCurStr (catlos, CurStrNumA, TTCNumA) { for(CPos=CPosInit; (CPos<=catlos); CPos++){ getCurChar (catlos, CurStrNumA, TTCNumA); CurStrA[CPos] = CurChar; CurStr=CurStrA.join(''); if(CPos==catlos){ setCurStr (CurStr); } } } function setCurStr (CurStr){ _root.onEnterFrame = function (){ writeCurText(CurStr); if(CurStr == ToText){ delete _root.onEnterFrame } else{ getCurStr (catlos, CurStrNumA, TTCNumA); } } } function CalcCurText(FromText, ToText){ // catlos == number of chars at the longer string - to be handeled in arrays: -1 (ToText.length <= FromText.length) ? catlos = (FromText.length)-1 : catlos = (ToText.length)-1; CreateFTCAs (catlos, FromText, ToText); CreateTTCAs (catlos, FromText, ToText); CurStrNumA = FTCNumA; CPosInit=0; getCurStr(catlos, CurStrNumA, TTCNumA); } stop(); Posted by: Jochen Preusche | website http://jochenpreusche.de |

