Category: code snips
-
How to use flashvars in as3
I use flashvars heavily to create customizable swfs. After some time I got tired of copy pasting my code and found this: [as3] function getFlashVars():Object { return Object(LoaderInfo(this.loaderInfo).parameters); } [/as3] I only need to call this method (which returns an object) and chain it with the flashvar I want. This only works on timeline code […]
-
How to use dynamic fonts on html using AS3
Challenge: Most designers find themselves worrying about cross-browser compatibility. Most of the time, they have to work with a limited choice of fonts. What if you want to do something flashy, like this: http://us.blizzard.com/en-us/company/ Notice the gradient and the drop shadow in the “Company” header. It’s done in flash. And since it’s Blizzard, I assume it […]
-
How to embed fonts properly in AS3
Best practice for embedding fonts in AS3. Fonts can be embedded using the Flex metadata “Embed”. For example, if you want to embed the font named Arial (this should be the system font located in FontBook or the Fonts folder) [as3] [Embed(systemFont="Arial", fontName="Arial", mimeType="application/x-font", unicodeRange="U+0041-U+0054")] var arial:Class; Font.registerFont(arial); [/as3] systemFont: looks for the current system […]
-
How to add a favicon
1. Create an icon file. 16×16 is the normal size although 36×36 icons will be resized by the browser. A .gif can also be used. 2. Add this code inside the “head” : <link rel=”icon” href=”image/favicon.ico” type=”image/ico”/> 3. The href should specify which directory the icon is located
-
Get an XML in jquery
$.ajax({ type:”GET”, url:”story.xml”, dataType: “xml”, success:function(xml){ $(xml).find(‘line’).each(function(){ var id_text = $(this).attr(‘id’) var name_text = $(this).find(‘name’).text() storyArray[$(this).attr(‘id’)] = $(this).text(); […]
-
Open a file and output numbers
#include #include void accessFile(); int main() { accessFile(); return 0; } void accessFile() { FILE *fp; int n = 0; int z = 0; fp = fopen(“count.txt”,”a+”); if(fp == NULL) printf(“Error opening file”); else { while(!feof(fp)) […]
-
A More Complicated Preloader
Steps for complicated pre-loading: 1. The actual movie starts on the 3rd frame. The 1st frame is for the preloader. The 2nd frame is for loading the codes and stuff 2. To set the 2nd frame as the part to load the bulks, set Publish Settings>Flash>Settings>Export Frame for Classes, set it to 2. 3. Set […]
-
How to disable people from forward-ing in flash movies
var myMenu:ContextMenu = new ContextMenu();myMenu.hideBuiltInItems(); Turns out that thing that pops up when you right click a movie is called a ContextMenu. So an easy way to disable it is to hide them by using hideBuiltInItems(); An item in the ContextMenu is called a ContextMenuItem. var useless:ContextMenuItem = new ContextMenuItem(“Useless Me”, deadClick); The 1st parameter […]
-
A linked list
/*#include headers here */ struct list_el { int val; struct list_el * next;}; typedef struct list_el Item; Item *list, *tail; //references to the linked list int main() { int i; Item *curr; int array[] = {1, 24,3,412,125,6,74,228,9, 10}; /*initialize the list*/ list = (struct Item*)malloc(sizeof(Item)); list->next=NULL; // this is important to list->val = 0; // […]