Home » Actionscripts library » Misc Scripts
|
// fed up on changing instance name for hundreds of MovieClip ???
// Create a Flash Javascript file
///////////////////////////////////////////
// ins_name.jsfl //
///////////////////////////////////////////
var my_val;
if(my_val == undefined){
my_val = -1;
}
my_val ++;
fl.getDocumentDOM().selection[0].name = "m_" + my_val;
// "m_" is the abbreviation with the increment instance names - change it to your needs ::
//Place the jsfl file into your commands folder.
//Select a movieclip and run the script.
//You will notice the instance of the MC was changed.
//:: To change the value of the string in the same way
fl.getDocumentDOM().selection[0].setTextString(my_val);
/////////////////////////////////////////
/// [email protected] //
Posted by: Elangovan | website http://www.chellamtamil.com |
//first make a black square the size of the whole panel (cover everything) //make a circle in the middle, then delete it (should leave a whole) //put two lines in the circle they should look like this: // | // | // _______|_______ // | // | // | //select the square/rectangle and hit F8 (convert to symbol) //do it again, so that in the MC there is another MC //name the MC “scope_mc” in the instance name box // (actually do it in both of the movie clips) now enter this script in the //movie clips (yes, do the same text for both) onClipEvent (enterFrame) { Mouse.hide scope_mc._x = _xmouse scope_mc._y = _ymouse } //create a second layer and disable the sight for layer1(so you can’t see it) // on the second layer create 1 little figure or target to shoot at //whatever it is make it a Btn (F8 again) //go inside the new Btn and use a “stop();” command for the first frame // (not in the button, in the frame) // on the third frame (make three frames) delete the movie clip and add another // stop command(if you want you can make the target fall on the second frame) //go back to level0 (the layer with everything on it (hit the blue back button)) //make another frame on level0 and take your targets(oh yeah you can just copy //and paste your target and have more fun) and everything else on the screen // (except for the scope) and scale it to at least twice its size //go back to the first frame, make a button, and type this script: in the Btn: on (keypress”Space”) { gotoAndStop(2) } //on frame two, take the script and insert a one where the two is // like this gotoAndStop(1) //if it works, you should be able to switch back and forth between // frames in the swf. file every time you hit space // if you have a sound that you want to use for a gunshot read the rest ----Sounds---- //make a third layer, put under the layer with the targets, under the scope //layer, but over the background (if you have one) create another square //(any color, it wont matter) the size of the drawing field(like the scope) // make it a button and put the alpha all the way up/ down to 0% // double-click the box so that you are inside it, and use a stop command // in frame1 make a second frame, import the sound to the library(Ctrl+R) // and drag the sound to the stage on frame2, still in the button //hit F5 to carry out the sound, hit it until the blue line in the frames ends //go to any target dbl-click and drag the sound onto frame two(do it only on //one because it works for all) // if you have done this correctly you should be able to shoot targets with the //crosshairs TIP: the crosshairs may be slightly off from the cursor. //Enjoy //P.S. takes 20minutes < if you do it right Posted by: joeyman | website http://www.ultimatecreatures.com |
// 2 in 1 hex color mixer in percent, returns one hex value // 2006 by www.advance-media.com colors_2in1 = function (hex1, hex2, percent) { var hex3, hex_ret, i; // to decimal value hex1 = parseInt(hex1, 16); hex2 = parseInt(hex2, 16); // loop rgb for (i=2; i>=0; i--) { // shifting bits AND extracting the rgb color canal value hex3 = hex1 >> 8*i & 255; // adding the percentage of the difference hex3 += ((hex2 >> 8*i & 255)-hex3)/100*percent; // zero fill if (hex3<16) { hex_ret += "0"; } // to a hex color string hex_ret += hex3.toString(16); } return hex_ret; }; // trace(colors_2in1("0080ff", "ffff00", 50)); // value range of percent is 0-100 to fade from color 1 to color 2 // // ************************************************** // here showcasing a TextField list color fade effect // ************************************************** // // number of TextFields, zero is a number txt_num = 23; // to Format the output txt_f1 = new TextFormat(); txt_f1.size = 18; txt_f1.font = "Verdana"; txt_f1.bold = true; // loop to create the colorful list for (i=0; i<=txt_num; i++) { // create textFields with y offset this.createTextField("txt_output"+i, i, 0, i*20, 0, 0); with (this["txt_output"+i]) { selectable = false; autoSize = true; // setting the color according to the percentage ratio, NaN check textColor = "0x"+colors_2in1("0080ff", "00ff80", txt_num == 0 ? 0 : 100/txt_num*i); text = "www.ADVANCE-MEDIA.com"; setTextFormat(txt_f1); } } // clear all memory, go! delete colors_2in1; delete txt_f1; delete txt_num; delete i; Posted by: Folko Langner | website http://www.advance-media.com |
// simple and resource saving 3 color text navigation by www.advance-media.com, stop(); // caption text nav_caption = new Array("Crusader", "Inquisition", "Autodafé", "Coerced Conversion", "Flat Earth", "Letter of Indulgence"); // defining the 3 colors of the rollOver, roll- and dragOut and onClick state outcol = 0x666666; rollcol = 0x999999; oncol = 0xcccccc; // Text format of the caption txt_f = new TextFormat(); txt_f.size = 18; txt_f.font = "Verdana"; txt_f.bold = true; // loop to create the navigation for (i=0; i<nav_caption.length; i++) { // create an MC for each button this.createEmptyMovieClip("nav"+i, i); this["nav"+i].stop(); // initializing the buttons this["nav"+i].meIs = i; // functions of each buttons this["nav"+i].onRelease = function() { setNav(this.meIs); }; this["nav"+i].onRollOver = function() { rOver(this.meIs); }; this["nav"+i].onDragOut = function() { rOff(this.meIs); }; this["nav"+i].onRollOut = function() { rOff(this.meIs); }; // create caption textFields with x offset this["nav"+i].createTextField("caption", 1, xPos, 0, 0, 0); with (this["nav"+i].caption) { selectable = false; autoSize = true; textColor = outcol; text = nav_caption[i]; setTextFormat(txt_f); // calculate the x offset xPos += textWidth+33; } } // clear all memory delete nav_caption; delete i; delete txt_f; delete xPos; // defining the functions of the navigation rOver = function (index) { if (indexOn != index) { col = new Color(this["nav"+index]); col.setRGB(rollcol); this["nav"+index].useHandCursor = true; } else { this["nav"+index].useHandCursor = false; } }; rOff = function (index) { if (indexOn != index) { col = new Color(this["nav"+index]); col.setRGB(outcol); } }; setNav = function (index) { if (indexOn != index) { col = new Color(this["nav"+index]); col.setRGB(oncol); this["nav"+index].useHandCursor = false; col = new Color(this["nav"+indexOn]); col.setRGB(outcol); indexOn = index; // here U may like to continue with this.subPageHolder.gotoAndStop(indexOn); or getURL(myLinkArr[indexOn], "subPageFrame"); } }; // initializing the navigation setNav(0); Posted by: Folko Langner | website http://www.advance-media.com |
/* Created by [email protected] Place this sile in your class library. Usage Example: var myCart:cart = new cart("CartName"); var CartItem = new Object(); //define an item object CartItem["sku"] = "ABCD"; //add any property you would like to store in the cart CartItem["QTY"] = 12; CartItem["name"] = "the name"; myCart.Add("ABCD",CartItem); //this will add the item to the cart. to get the items in the cart: var cartItems = myCart.getCartObject(); for (var i in cartItems){ trace("id:" + i + " = " + cartItems[i]) for (var subItem in cartItems[i]) trace("\tprop:" + subItem + " = " + cartItems[i][subItem]) } */ class cart { var cartObj; var myCart; var cartName : String; function cart (strCartName : String) { cartName = strCartName; myCart = SharedObject.getLocal (this.cartName); if (myCart.data [this.cartName] == undefined) { myCart.data [this.cartName] = new Object (); } if (myCart.data [this.cartName].id == undefined) { myCart.data [this.cartName].id = new Object (); } _global.trace ("init cart " + myCart.data [this.cartName]); } function getCart () { var retVal = ""; _global.trace (this.cartName); for (var o in myCart.data [this.cartName].id) { retVal += o + ": " + myCart.data [this.cartName].id [o] + "\n"; for (var oo in myCart.data [this.cartName].id [o]) { retVal += "\t" + oo + ": " + myCart.data [this.cartName].id [o][oo] + "\n"; } } return retVal; } function Exist (id) { if (myCart.data [this.cartName].id [id] == undefined) return false; else return true; } function Add (id, obj) { _global.trace ("Add to cart:" + id); if ( ! this.Exist (id)) { myCart.data [this.cartName].id [id] = new Object (); myCart.data [this.cartName].id [id] = obj; } else { //update if found this.Update (id, obj); } myCart.flush (); } function Update (id, obj) { _global.trace ("Update cart:" + id); if (this.Exist (id)) { myCart.data [this.cartName].id [id] = obj; myCart.flush (); } } function Remove (id) { delete myCart.data [this.cartName].id [id] //delete myCart.data[this.cartName][id]; _global.trace ("delete from cart:" + id); } function getCartCount () { var i = 0; for (var o in myCart.data [this.cartName].id) { i ++; } return i; } function getCartObject () { return myCart.data [this.cartName].id; } } Posted by: Isaac Levy | website http://www.actionscript.org |

