IMPORTANT!

Snipt is going open source. We've toyed with this idea for quite a while, and have finally decided it's the right way to move forward.

A few things:
  • The entire Snipt source code will be released on GitHub under the 3-clause BSD License on Friday, September 10th.
  • While we'd like to think we're perfect, we realize we're only human. By open sourcing the software that runs this website, certain bugs or security flaws may be discovered that could compromise the privacy of your snipts.
  • Only the Lion Burger team will be able to push commits to the Snipt.net site. Contributors should send a pull request to add new features or submit patches.
  • By using this site, you agree not to be too angry or take any legal action against Lion Burger should this whole thing go up in flames some day.
  • Follow us on Twitter for updates.
I agree, close this message
Sign up to create your own snipts, or login.

Latest 100 public snipts » flash The latest public flash snipts.

showing 1-20 of 99 snipts for flash
  • JW Player tips
    <?php
    
    // jw player tips
    //
    // http://www.longtailvideo.com/support/jw-player-setup-wizard
    //
    // http://www.longtailvideo.com/support/jw-player/jw-player-for-flash-v5/12536/configuration-options
    
    
    // build flashvars in case the user doesn't have js enabled
    $flash_vars = "&autostart=true&dock=false&file=".urlencode('blah.flv')."&image=".urlencode('blah.jpg')."&plugins=captions-1&captions.file=".urlencode('blah.xml');
            
    ?>
        <h3></h3>
        <p id='preview'>
        <embed src='http://www.blah.com/video/player.swf' height='360' width='640' allowscriptaccess='always' allowfullscreen='true' flashvars='<?php echo $flash_vars; ?>'/>
        </p>
    
        <script type='text/javascript' src='/video/swfobject.js'></script>
        <script type='text/javascript'>
            var s1 = new SWFObject('/video/player.swf','player','640','360','9');
            s1.addParam('allowfullscreen','true');
            s1.addParam('allowscriptaccess','always');
            s1.addVariable('file', 'blah.flv');
            s1.addVariable('autostart','true');
            s1.addVariable('dock','false');
            s1.addVariable('image','blah.jpg');
            s1.addVariable('captions.file', 'blah.xml');
            s1.addVariable('author','Me');
            s1.addVariable('description','Video of Me');
            s1.addVariable('title','Title');
            s1.addVariable('plugins','viral-2d,captions-1');
            s1.write('preview');
        </script>
    

    copy | embed

    0 comments - tagged in  posted by robertbanh on Sep 01, 2010 at 10:31 a.m. EDT
  • html embed flash
    <embed id="other_br" src="__TMPL__images/1.swf" quality="high" 
    flashVars="bcastr_flie=__TMPL__images/banner01.gif%7C__TMPL__images/banner01.gif%7C__TMPL__images/banner01.gif%7C&amp;bcastr_link=http://www.google.com%7Chttp://www.google.com%7Chttp://www.baidu.com%7C&amp;duration_color=0xff0000&amp;dur_time=2" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" height="282" width="451" ></embed>
    
    ie6,ie8,chrome6.0.427,firefox3.6.3 pass
    
    
    ----- objcet ?????
    <object height="282" width="451" data="__TMPL__images/1.swf" type="application/x-shockwave-flash" id="mozilla_br">
      <param value="high" name="quality"><param value="always" name="allowScriptAccess">
      <param value="transparent" name="wMode">
      <param value="true" name="swLiveConnect">
      <param value="2" name="dur_time">
      // fix z-index problem
      <param name="wmode" value="Opaque" />
      <param value="http://www.google.com%7Chttp://www.google.com%7Chttp://www.baidu.com" name="bcastr_link">
    <param value="__TMPL__images/banner01.gif%7C__TMPL__images/banner01.gif%7C__TMPL__images/banner01.gif" name="bcastr_flie">	
    </object>
    

    copy | embed

    0 comments - tagged in  posted by paranoid on Jun 13, 2010 at 3:25 a.m. EDT
  • (Very) basic skeleton for visual classes
    package com.kor.classes
    {
    	import flash.display.MovieClip;
    
    	public class Class extends MovieClip
    	{
    		public function Class()
    		{
    			init();
    			createChildren();
    			addListeners();
    			draw();
    		}
    		
    		private function init():void
    		{
    			
    		}
    		
    		private function createChildren():void
    		{
    			
    		}
    		
    		private function addListeners():void
    		{
    			
    		}
    		
    		public function draw():void
    		{
    			
    		}
    	}
    }
    

    copy | embed

    0 comments - tagged in  posted by kor on May 03, 2010 at 2:09 p.m. EDT
  • Making Alpha Work on AS3 Dynamic Text Fields
    var myTextField:TextField = new TextField();
    var myTextFormat:TextFormat = new TextFormat();
    myTextFormat.font = "Arial";
    myTextField.blendMode = BlendMode.LAYER;
    myTextField.text = "It works!";
    myTextField.setTextFormat(myTextFormat);
    addChild(myTextField);
    myTextField.alpha = .5;
    

    copy | embed

    0 comments - tagged in  posted by xtechcr on Apr 20, 2010 at 6:28 p.m. EDT
  • Filtering XML Data
    package{
      import flash.display.Sprite;
      
      public class Main extends Sprite{
        public function Main(){
    
            var staff:XML = <STAFF>
              <EMPLOYEE ID="501" HIRED="109">
                <NAME>M</NAME>
                <MANAGER>J</MANAGER>
                <SALARY>25000</SALARY>
                <POSITION>Designer</POSITION>
              </EMPLOYEE>
            
              <EMPLOYEE ID="238" HIRED="101">
                <NAME>J</NAME>
                <MANAGER>D</MANAGER>
                <SALARY>55000</SALARY>
                <POSITION>Manager</POSITION>
              </EMPLOYEE>
            </STAFF>
            
            var allEmployees:XMLList = staff.*;
            
            var employeesUnderJames:XMLList = allEmployees.(MANAGER == "James Porter");
            
            trace(employeesUnderJames);
        }
      }
    }
    

    copy | embed

    0 comments - tagged in  posted by xtechcr on Apr 16, 2010 at 1:30 p.m. EDT
  • Add Process Listener to URLStream
    package
    {
        import flash.net.URLStream;
        import flash.net.URLRequest;
        import flash.events.Event;
        import flash.events.ProgressEvent;
        public class Main
        {
            private var streamer:URLStream= new URLStream(new URLRequest("http://example.com/binary_data.bin"));
    
            public function Main()
            {
                streamer.addEventListener(ProgressEvent.PROGRESS, progressListener);
            }
    
            private function progressListener(event:Event):void
            {
                if(streamer.bytesAvailable != 0)
                {
                    trace(streamer.readByte());
                }
            }
        }
    }
    

    copy | embed

    0 comments - tagged in  posted by xtechcr on Apr 16, 2010 at 1:28 p.m. EDT
  • Accessing Data Being Downloaded
    package {
      import flash.display.*;
      import flash.events.*
      import flash.net.*;
      
      public class Main extends Sprite {
      
        public function Main(  ) {
          var streamer:URLStream = new URLStream(  );
          
          streamer.addEventListener( ProgressEvent.PROGRESS, handleProgress );
                           
          streamer.load( new URLRequest( "example.txt" ) );
        }
        
        private function handleProgress( event:ProgressEvent ):void {
          var streamer:URLStream = URLStream( event.target );
          
          while ( streamer.bytesAvailable > 0 ) {
            trace( "Read byte: " + streamer.readByte(  ) );    
          }
        }
      }
    }
    

    copy | embed

    0 comments - tagged in  posted by xtechcr on Apr 16, 2010 at 1:27 p.m. EDT
  • Use XML socket Connect event and Data event
    package {
      import flash.display.Sprite;
      import flash.events.Event;
      import flash.events.DataEvent;
      import flash.net.XMLSocket;
    
      public class SocketExample extends Sprite {
      
        private var xmlSocket:XMLSocket;
      
        public function SocketExample(  ) {
          xmlSocket = new XMLSocket(  );
          
          xmlSocket.addEventListener( Event.CONNECT, onConnect );
          
          xmlSocket.addEventListener( DataEvent.DATA, onData );
    
          xmlSocket.connect( "localhost", 2900 );
        }
        
        private function onConnect( event:Event ):void {
          xmlSocket.send( "<test/>" );  
        }
    
        private function onData( event:DataEvent ):void {
          trace( event.data );
          
          var response:XML = new XML( event.data );
          
          trace( response.test.@success );
        }
      }
    }
    

    copy | embed

    0 comments - tagged in  posted by xtechcr on Apr 16, 2010 at 1:26 p.m. EDT
  • Convert a Regular String to Camel Case
    function toCamelCase(TEXT:String):String{
    	TEXT = TEXT.toLowerCase()
    	var words = TEXT.split(" ")
    	for(var i=1;i<words.length; i++){
    		words[i] = words[i].charAt(0).toUpperCase() + words[i].substring(1)
    	}
    	TEXT = words.join("")
    	return TEXT
    }
     
    trace(toCamelCase("word"))
    trace(toCamelCase("two words"))
    trace(toCamelCase("the quick brown fox"))
     
    
    Gets you:
    word
    twoWords
    theQuickBrownFox
    

    copy | embed

    0 comments - tagged in  posted by xtechcr on Apr 16, 2010 at 1:21 p.m. EDT
  • Loading Variables from an External Text File
    var vars:URLLoader = new URLLoader();
    vars.dataFormat=URLLoaderDataFormat.VARIABLES;
    vars.addEventListener(Event.COMPLETE, onComplete, false, 0, true);
    vars.load(new URLRequest("vars.txt"));
    function onComplete(evt:Event):void {
    	var urlVars:URLVariables=evt.target.data;
    	for (var prop in urlVars) {
    		trace("urlVars." + prop + " = " + urlVars[prop]);
    	}
    }
    

    copy | embed

    0 comments - tagged in  posted by xtechcr on Apr 16, 2010 at 1:19 p.m. EDT
  • Loading and Using an External CSS File
    package {
    	import flash.display.Sprite;
    	import flash.events.Event;
    	import flash.net.URLLoader;
    	import flash.net.URLRequest;
    	import flash.text.StyleSheet;
    	import flash.text.TextField;
    	import flash.text.TextFieldAutoSize;
    
    	public class CSSFormattingExample extends Sprite {
    		var loader:URLLoader;
    		var field:TextField;
    		var exampleText:String = "<h1>This is a headline</h1>" +
    		"<p>This is a line of text. <span class='bluetext'>" +
    		"This line of text is colored blue.</span></p>";
    
    		public function CSSFormattingExample():void {
    			field = new TextField();
    			field.width=300;
    			field.autoSize=TextFieldAutoSize.LEFT;
    			field.wordWrap=true;
    			addChild(field);
    
    			var req:URLRequest=new URLRequest("example.css");
    
    			loader = new URLLoader();
    			loader.addEventListener(Event.COMPLETE, onCSSFileLoaded);
    			loader.load(req);
    		}
    
    		public function onCSSFileLoaded(event:Event):void {
    			var sheet:StyleSheet = new StyleSheet();
    			sheet.parseCSS(loader.data);
    			field.styleSheet=sheet;
    			field.htmlText=exampleText;
    		}
    	}
    }
    
    
    // THE 'example.css' FILE SHOULD LOOK LIKE THIS ...
    //p {
    //	font-family: Times New Roman, Times, _serif;
    //	font-size: 14;
    //}
    //
    //h1 {
    //	font-family: Arial, Helvetica, _sans;
    //	font-size: 20;
    //	font-weight: bold;
    //}
    //
    //.bluetext {
    //	color: #0000CC;
    //}
    

    copy | embed

    0 comments - tagged in  posted by xtechcr on Apr 16, 2010 at 1:18 p.m. EDT
  • xml vs. cache
    var myDate:Date = new Date();
    var timestamp:Number = myDate.getTime();
    var XMLLoader:URLLoader = new URLLoader();
    XMLLoader.addEventListener(Event.COMPLETE, xmlLoaded);
    XMLLoader.load(new URLRequest("yourxml.xml?" + timestamp));
     
    function xmlLoaded(evt:Event):void
    {
    	xml = XML(evt.target.data);
    	trace(xml) //your current xml data
    }
    

    copy | embed

    0 comments - tagged in  posted by xtechcr on Apr 16, 2010 at 1:16 p.m. EDT
  • Position objects in a custom grid
    //numbers of squares
    var numSquares:uint = 9;
    //numbers of cols
    var cols:uint = 3;
    //the offset between each row
    var rowOffset:Number = 20;
    var square:Sprite;
     
    for(var i:uint = 0; i < numSquares; ++i)
    {
    	//create a new sprite with a black rectangle
    	square = new Sprite();
    	square.graphics.beginFill(0x000000);
    	square.graphics.drawRect(0, 0, 20, 20);
    	square.graphics.endFill();
     
    	//set each 4.th square in a new row
    	if(i % cols == 0 && i != 0)
    	{
    		rowOffset += 40;
    	}
    	//position each square on the x-axis and y-axis
    	square.x = 20 + 40 * (i % cols);
    	square.y = rowOffset;
    	this.addChild(square);
    }
    

    copy | embed

    0 comments - tagged in  posted by xtechcr on Apr 16, 2010 at 1:15 p.m. EDT
  • randRange - random number within a given range
    private function randRange(start:Number, end:Number):Number{
        return Math.floor(start +(Math.random() * (end - start)));
    }
    

    copy | embed

    0 comments - tagged in  posted by bromanji on Apr 07, 2010 at 12:51 p.m. EDT
  • Detect if mouse pointer is over/out of the stage area
    [AS3 SNIPPET] Detect if mouse pointer is over/out of the stage area
    
    Posted by Riccardo on July 7, 2009 04:27 am under Actionscript 3, Snippets
    
    
    stage.addEventListener (Event.MOUSE_LEAVE, leaveHandler);
    stage.addEventListener (MouseEvent.MOUSE_MOVE, returnHandler);
    
    function leaveHandler(event:Event):void
    {
    trace("leaveHandler");
    
    stage.addEventListener (MouseEvent.MOUSE_MOVE, returnHandler);
    }
    
    function returnHandler(event:Event):void
    {
    trace("returnHandler");
    
    stage.removeEventListener(MouseEvent.MOUSE_MOVE, returnHandler);
    }
    
    Event.MOUSE_LEAVE: dispatched by the Stage object when the mouse pointer moves out of the stage area.
    MouseEvent.MOUSE_MOVE: Dispatched when a user moves the pointing device while it is over an InteractiveObject.
    

    copy | embed

    1 comment - tagged in  posted by xtechcr on Apr 06, 2010 at 6:28 p.m. EDT
  • Legal age verification
    var legalAge:int = 18;
    
    var userDOB:Date = new Date(year, month - 1, day);
    var today : Date = new Date();
    
    var diff:Date = new Date();
    diff.setTime(today.getTime() - userDOB.getTime());
    
    var userAge:int = diff.getFullYear() - 1970;
    
    if(userAge >= legalAge)
    {
    trace("lets get pissed!");
    }
    else
    {
    trace("go away!");
    }
    

    copy | embed

    0 comments - tagged in  posted by xtechcr on Apr 06, 2010 at 6:28 p.m. EDT
  • Find Min/Max Of Array Of Integers
    var min:Number;
    var max:Number;
    
    var numbers:Array =  new Array(3, 5, 2, 1, 4);
    
    function findMin(array:Array):Number {
     min = array[0];
     for (var i = 0; i < array.length; i++) {
      if (array[i] < min) {
       min = array[i];
      }
     }
     return min;
    }
    
    
    function findMax(array:Array):Number {
     max = array[0];
     for (var i = 0; i < array.length; i++) {
      if (array[i] > max) {
       max = array[i];
      }
     }
     return max;
    }
    

    copy | embed

    0 comments - tagged in  posted by xtechcr on Apr 06, 2010 at 6:24 p.m. EDT
  • Count All Occurrences of a Character In a String
    var str:String = "programmer";
    var char:String = "m";
    
    function countOccurences(str:String, char:String):Number {
     var count:Number = 0;
     
     for(var i=0; i < str.length; i++) {
      if (str.charAt(i) == char) {
       count++;
      }
     }
     return count;
    }
    
    trace(countOccurences(str, char)); //Outputs 2
    

    copy | embed

    0 comments - tagged in  posted by xtechcr on Apr 06, 2010 at 6:23 p.m. EDT
  • Create Dynamic TextField
    var exampleTextField:TextField = new TextField();
    exampleTextField.text = "your text goes here";
    exampleTextField.width = 200;
    addChild(exampleTextField);
    exampleTextField.autoSize = TextFieldAutoSize.LEFT;  
       
    var format:TextFormat = new TextFormat();  
    format.color = 0x990000;   
    format.size = 20;      
    exampleTextField.setTextFormat(format);
    

    copy | embed

    0 comments - tagged in  posted by xtechcr on Apr 06, 2010 at 6:23 p.m. EDT
  • Convert Degrees To Radians And Radians To Degrees
    var degrees = 90;
    
    var radians = degreesToRadians(degrees); 
    degrees = radiansToDegrees(radians);
    
    trace(radians); //Outputs 1.57
    trace(degrees); //Outputs 90
    
    function degreesToRadians(degrees:Number):Number {
     return degrees * Math.PI / 180;
    }
    
    function radiansToDegrees(radians:Number):Number{
     return radians * 180 / Math.PI;
    }
    

    copy | embed

    0 comments - tagged in  posted by xtechcr on Apr 06, 2010 at 6:22 p.m. EDT
Sign up to create your own snipts, or login.