In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

Domain locking

lock your SWF file
Get Adobe Flash player
by komapeb 17 Sep 2011
/**
 * Copyright komapeb ( http://wonderfl.net/user/komapeb )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/wpKA
 */

package
{
    import flash.display.*;
    import flash.net.*;
    import flash.text.*;
    
    public class FlashTest extends Sprite
    {
        private var _message:TextField;
        private var _currentDomain:String = new LocalConnection().domain;
        private var _trustedDomains:Vector.<String>;
        
        public function FlashTest()
        {
            stage.align = StageAlign.TOP_LEFT;
            stage.scaleMode = StageScaleMode.NO_SCALE;
            
            _trustedDomains = new <String>[];
            //add your domains to this list
            //_trustedDomains.push('swf.wonderfl.net');
            
            if (_trustedDomains.indexOf(_currentDomain.toLowerCase()) == -1) {
                _message = new TextField();
                _message.autoSize = TextFieldAutoSize.LEFT;
                _message.defaultTextFormat = new TextFormat('_sans', 16, null, true);
                _message.text = 'You\'re not authorized to run this content!';
                _message.x = (stage.stageWidth - _message.width) / 2 | 0;
                _message.y = (stage.stageHeight - _message.height) / 2 | 0;
                addChild(_message);
                return;
            }
        }
    }
}