Preloader to protect swf?

Hi All,
Newbee question, I have a games website and I want a preloader to protect my flash games from being downloaded easily.
I have found heaps of preloaders that work on the time line of game but offer no protection. Does anyone know where I can get a sample code for this or where I can buy a preloader from so that it loads before the game and if someone tries to save the page they get the preloader instead of the SWF?
A  flash designer I know said its possible but hasn't got time to create one. He gave me this code in a FLA but when I embedd the swf in to the site it doesn't load anything just displays the preloader. Im sorry this is a really novice question, been working on this project for a year + now so your advice would be really helpful to me :-).
This is the code he used on the preloader he made previously
function setProgress(num)
    _root.percentDone = int(num);
} // End of the function
var methodName = "setProgress";
var instance = null;
var method = setProgress;
var wasSuccessful = flash.external.ExternalInterface.addCallback(methodName, instance, method);
this.attachMovie("root", "obj", 1);
obj.progress.bar._xscale = 0;
obj._y = 0;
obj.onEnterFrame = function ()
    if (_root.percentDone != undefined)
        var _loc3 = Math.round(_root.percentDone);
        this.progress.bar._xscale = _loc3;
        if (_loc3 == 100)
            removeMovieClip (this);
            delete this.onEnterFrame;
        } // end if
    } // end if
stop ();

Since you will be loading AS3 files, you will need an AS3 preloader, otherwise, an AS2 preloader such as what you showed will fail in trying to an AS3 file, which is probably what you encountered in trying it.
Here's a link to an AS3 preloader tutorial which I believe does what you want... loads the file separately...
AS3 Preloader
http://www.gotoandlearn.com/play.php?id=85
but just so you aren't fooled by it all... When someone is playing your game, they have already downloaded your game.  So your protection is really only protecting your files against those who are either too lazy or lack the knowledge of how to get the file from their cache.  But some protection is often better than none.

Similar Messages

  • How to protect swf from hackers!!!

    Hi, I have made many games is it any way that I can protect my swf from flash developers who want hack my game???..
    First I was tried way load game swf's into preloader swf and call it by Iframe most flash developers just get only my preloader.swf unable to get game..
    but now few did this... now i am searching way that to protect swf from flash dicompilors???

    Flash runs on the 'client side', which makes it vulnerable. There are several ways to hack a Flash game - intercepting and modifying/faking communications with the server (ie, sending fake values to your 'highscores.php' or whatever, say using an app like Fiddler2), decompiling the .swf to see how it communicates with the server (and any encryption or obfuscation it might be using to try and protect communications), or even directly editing the memory being used by the game (ie, using CheatEngine to change your score directly, the speed of the game, etc). It's pretty hard to protect against all these, and usually takes more time and effort than the game is worth.
    So the best rule is, expect your game to be hacked. Don't use it as a basis for giving away an expensive prize, for example (or at least, don't let it be obvious that the winner hacked the game or other players will get pissed off), unless all the logic happens on the server side.
    But if you still want to try...
    Let's say your game consists of three types of processes - Input (from the user), Logic (the app deciding what to do with the input), and Output (the result of the logic). Input and Output have to happen on the client side, or the user won't be able to interact with the game or see the results of their interactions - so these parts can never be fully secured, only validated as acceptable or not. However, the Logic (all or part) could be done on the server, where the user can't see it or modify it. The Flash game takes the user's input (maybe makes sure it's valid), and sends it to the server. The server checks that the input is valid, and if so performs the game logic, and sends the output back to the Flash game. If the input is NOT valid, perhaps silently keep that user (account ID or their IP address, for awhile) from adding to the high score list, or interacting with other players. Or boot them for 5 minutes, or something.
    The main problem with this is (depending upon the type of game) lag in communicating with the server, and server load. If every little input/output has to go to the server, be processed, and then be sent back to the user, the game could run very slowly for the player; or if many people are playing at once, the server could crash. So you probably have to find ways to optimise this, and decide what should happen on the server, and what can safely happen on the client side (and be fairly well validated), etc.
    Gambling-type and turn-based games are fairly easy to secure this way, though, since lag won't affect gameplay too much and there's not a lot of information going back and forth with the server. Say in a card game, the server tells the flash what cards to display for the user. The user can only choose which card to play - this choice is sent back to the server. The server calculates the results of the play, and the other players' moves, and then tells the flash what new cards/scores to display.
    A real-time shooter, on the other hand? Even a game of Pong can be tricky. In those types of games, you could potentially send some data (user's x and y position, current health, ammo, score, framerate, etc) every now and then (maybe obfuscated, checksummed, compressed, via socket, etc) and the server can see if they should be 'possible' and decide whether to keep accepting input from the user, but that gets pretty tricky really quickly, and you'll probably get far more false-positives than catch actual hackers.

  • Protecting swf files from being decompiled

    At the end of the day, our flex apps are deployed as swf
    files which have the potential to be decomplied and thereby our
    intellectual properties lost. There are tools in the market which
    claim to secure the swf files from being decompiled. Are these
    tools live up to their claims? Is it worthwhile to spend money on
    these tools? Would the protected swf become harder to deployed? Any
    good products already available in this line? Please point out
    some. Thx.

    Most of the tools I have seen are geared towards extracting
    resources from swf's. I use one myself (eltima.com) for
    "harvesting" manufacturers content for my motorcycle dealers. They
    are authorized to use this content, but finding someone at Yamaha
    of Kawasaki or any of the majors who even knows where to find these
    resources is next to impossible. I have also used it to learn from
    by viewing scripts, but as you say, at the end of the day, I think
    the concepts and best practices are about the only thing worth
    taking away from others efforts, not the code.
    Unlocking a protected file can be done as well and I remember
    using a product over a year ago to get at the scripts within an swf
    (I wanted the URL's that pointed to media - it was legal for me to
    do this). It ran from the command line and output the scripts.
    There aren't too many of these types of programs to be found, but
    they exist.
    My personal opinion is that it's not worth the effort. My
    java classes can be decompiled and if someone wants to go to that
    trouble, more power to them. To my knowledge, there isn't anything
    out there yet that is perfect for backwards engineering an swf into
    an MXML file, but a competitor of FLASH Decompiler says that they
    can decompile Adobe 9 PLAYER swf's. For what it's worth, I plan on
    posting the majority of my code on my flexdev.org site once I get
    it established.
    For people who make components for sale, this could be an
    issue of stolen revenue if the decompilers get sophisticated enough
    to reverse engineer the swc into a usable MXML file. I would be
    against anyone who stole code for this purpose, for sure.

  • Protecting SWF files.

    Hi,
         Can i know whether there is any way to protect swf files from being decompiling. I have seen that some tools are available for decompiling the swf files. Can anybody help me by providing a tutorial for the same or any ideas.
    Thank and Regards,
             Sreelash

    Yes, as mantissao states, the best you can do for a SWF is to run it through an Obfuscator.
    Google: Actionscrip Obfuscation and you will find some products to do this.
    What it does is change the Actionscript in the SWF to make it "unreadable" by decompilers.  In practice, what happens is this: Decompilers update constantly to work around any problems arising from new obfuscation techniques, and then new obfuscation techniques are created to stop the new decompilers.  In the end, a decompiled SWF that was obfuscated becomes difficult to parse through, as all variable names are random strings of text, but not impossible.
    Otherwise, the only method you can use is a streaming server (Adobe FMS, Red5, Wowza, etc) and offload all important Actionscript to the server.  This would be reliable in protecting that Actionscript, but may not be worth the time and effort of setting it up.  Plus, this is overkill if the only goal is to protect some "proprietary" code.

  • Basic preloader for multiple swfs?

    I've looked at 100+ discussions around the web, not one good answer.
    I want some AS3 script equivalent to the following script (which I've made-up):
    loadallthefollowingswfs.intocache("home.swf", "products.swf", "contact.swf");
    I want a bunch of different swfs, all of which are in the same directory, to be loaded into the cache prior to viewing any of the swfs.
    I would like to put this script into the first frame of an index.swf
    Upon loading ALL of the swfs into the cache, it will move on to frame 2 of the index.swf and continue forward.
    All of the other discussions around the web state to either "have each swf load once it is opened" (I don't want that, I want them all preloaded into the cache prior to viewing any one of the swfs), or the discussions say "you should combine all of the flas into a single fla and just preload that one swf file (I don't want that either, I want seperate fla/swf files).
    Anyone have any suggestions on how to load multiple swfs into the cache when accessing one frame of an swf?
    Thank you.

    Greetings,
    Actually I just want to ask you guys about  how will I be able to use these snippet? I tried to insert a trace inside the else area of the if statement, but, didn't showed up any results in the output window...
    BTW: I just paste this snippet inside a new layer new flash file and saved it along with the two .swf files.
    var swfA:Array=["home.swf","works.swf"];
    var index:Number = 0;
    var targetMC:MovieClip=this.createEmptyMovieClip("targetMC",this.getNextHighestDepth());
    targetMC._alpha = 0;
    var mcl:MovieClipLoader=new MovieClipLoader();
    var lo:Object = {};
    lo.onLoadInit = function(target:MovieClip)
    index++;
    if(index<swfA.length)
    loadF();
    else
    // all are  loaded.  do whatever
    trace("Load Ok...");
    loadF();
    function loadF()
    mcl.loadClip(swfA[index],targetMC);
    here's my code
    var swfA:Array=["home.swf","works.swf"];
    var index:Number = 0;
    var targetMC:MovieClip=this.createEmptyMovieClip("targetMC",this.getNextHighestDepth());
    targetMC._alpha = 0;
    var mcl:MovieClipLoader=new MovieClipLoader();
    var lo:Object = {};
    lo.onLoadInit = function(target:MovieClip)
    index++;
    if(index<swfA.length)
    loadF();
    else
    // all are  loaded.  do whatever
    trace("Load Ok...");
    loadF();
    function loadF()
    mcl.loadClip(swfA[index],targetMC);

  • Attaching preloader to InDesign swf

    I exported an interactive swf from InDesign (content.swf). It is 7MB. I would like to add a preloader. I found a site that offered a recipe but the swf plays through the frames without stoping on the first frame.
    Further research indicated I was using AS2 and that the InDesign swf needs to be address in AS3. I am unable to find how to do this using AS3.
    Any help/recipies would be appreciated.
    Tina
    Here is they structure of the file with the preloader.
    Scene 1
    Layer 1: frame 2: actionscript
    loadMovieNum("content.swf", 10);
    _level10.gotoAndStop(1);
    Layer 2: frame 1: placed movie clip named: preloader
    preloader structure:
    Layer 1 has three frames
    frame 1:
    parent.stop();
    frame 2:
    kBytesLoaded = _parent.getBytesLoaded()/7045928;   
    kBytesTotal = _parent.getBytesTotal()/7045928;   
    kBytesRemaining - kBytesTotal - kBytesLoaded;   
    percentLoaded = 100 * kBytesLoaded / kBytesTotal;   
    percentRemaining = 100 - percentLoaded;   
    progress = percentRemaining;
    loadBar._xScale = percentLoaded;
    frame 3:
    if (percentLoaded < 99){ 
    gotoAndPlay(2);
    } else {
    _parent.play(); 
    stop(); 
    layer 2 has the progress text (progress) and the progress bar (loadBar)

    Since you will be loading AS3 files, you will need an AS3 preloader, otherwise, an AS2 preloader such as what you showed will fail in trying to an AS3 file, which is probably what you encountered in trying it.
    Here's a link to an AS3 preloader tutorial which I believe does what you want... loads the file separately...
    AS3 Preloader
    http://www.gotoandlearn.com/play.php?id=85
    but just so you aren't fooled by it all... When someone is playing your game, they have already downloaded your game.  So your protection is really only protecting your files against those who are either too lazy or lack the knowledge of how to get the file from their cache.  But some protection is often better than none.

  • Preloader problem with swf in different domains, not working online

    Hello
    I've an swf (loader.swf) hosted in dominioA.com, that justs loads a swf (movie.swf) hosted in dominioB.com.
    loader.swf has a preloader. When I execute the movie in flash, it works perfect, but when I upload the swf, the preloader doesn't works. I see 0% and after starts movie.swf normally.
    Here is the code of loader.swf
    Security.allowDomain("www.dominioB.com");
    Security.allowDomain("www.dominioA.com");
    var contexto:LoaderContext = new LoaderContext();
    contexto.applicationDomain = ApplicationDomain.currentDomain;
    var _preloader:MovieClip=preloader
    _preloader.barra.width=0;
    var _DOM:String="http://www.dominioB.com/movie.swf?anticache="+Math.random();
    var myLoader:Loader=new Loader;
    addChild(myLoader)
    myLoader.contentLoaderInfo.addEventListener(Event.INIT, initHandler);
    myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onLoadPogress);
    myLoader.contentLoaderInfo.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
    myLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
    myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,onDataLoad);
    var carga=new URLRequest(_DOM);
    myLoader.load(carga, contexto);
    function onDataLoad(evt:Event) {     
              //inicializar datos
    function onLoadPogress(event:ProgressEvent){
         var cargado:int = event.bytesLoaded;
        var total:int = event.bytesTotal;
        var porcentaje:int = cargado/total*100;
        _preloader.txt.text = "Cargado: "+String(porcentaje)+"%";
        _preloader.barra.width = porcentaje*2;
    function httpStatusHandler(event:HTTPStatusEvent):void {
           if(event.status==404){                    
    function ioErrorHandler(e:IOErrorEvent):void {
    function initHandler(e:Event):void {
    Any idea??
    Regards

    movie.swf load perfect, and everything works. It doesn't seem to be a cross-domain issue.
    In loader.swf, all the actionscript is in the timeline, not in a class.
    Thanks.

  • Preloader in external swf not working

    I have several external SWFs that are loaded into my site and
    each one has a preloader. When I run them by themselves the
    preloader works fine, but when it is embeded into the main SWF the
    preloaders do not work. Any ideas?
    here is my actionscript -
    lBytes = _root.getBytesLoaded();
    tBytes = _root.getBytesTotal();
    percentLoaded = Math.floor((lBytes/tBytes)*100);
    loader.bar._xscale = percentLoaded;
    loader.percent.text = percentLoaded + "% of " +
    Math.floor(tBytes/1024) + "K loaded.";
    if (lBytes>=tBytes && tBytes>0) {
    if (count>=12) {
    gotoAndPlay("enter");
    } else {
    count++;
    gotoAndPlay("preload");
    } else {
    gotoAndPlay("preload");
    }

    I am experiencing the exact same problem on my site -
    www.expansiondesign.com
    It works in flash player but not when live (tested safari and
    firefox)
    I don't know if you are using the same script as I am paul.
    I execute the following when each image button is pressed:
    button1.onRelease = function () {
    startLoading("image1.jpg");
    which runs this:
    function startLoading(whichImage) {
    loadMovie(whichImage, "_root.image_holder");
    _root.onEnterFrame = function() {
    infoLoaded = _root.image_holder.getBytesLoaded();
    infoTotal = _root.image_holder.getBytesTotal();
    percentage = (infoLoaded/infoTotal*100);
    _root.loader._yscale = percentage;
    _root.loader._visible = true;
    if (percentage>=100) {
    delete this.onEnterFrame;
    _root.loader._visible = false;
    Thanks,
    Barton

  • Need a way to protect SWF from decompilers (as they can extract the SWF from Android's APK)

    I'm working on an Android app that will be used in competitions, so protection from cheating is very important. I've noticed that Flash places the SWF file inside the APK file, which can be extracted as APK is just a ZIP file.
    Is there any way to protect the SWF from decompilers?

    What you mean under 'cheating'? Increase game money or scores? Or stole game?
    You can't protect if above is yes because if you can protect from decompilers - you can't protect from dissassemblers. I wokring on security in flash and I can hack any flash and I know that I'm saying.
    Let me know from what you want protect exactly?

  • Preloading in the swf itself AS3

    Hello guys ;]
    I need some help in AS3.
    My problem is that I can't preload the content in the swf
    movie itself.. I mean movie clips and images that are inside the
    swf not external and so on.
    In AS2 All I needed to do is this :
    this.onEnterFrame = function() {
    loadingAmount =
    this.getBytesLoaded()/this.getBytesTotal()*60;
    if (loadingAmount == 60 and sVars.loaded == true and
    this.bigPicWidthsScript_mc.wVars.loaded == true) {
    this.gotoAndStop(3);
    delete this.onEnterFrame;
    This is juat an example what used to work.. I copied this
    part from a code I wrote time ago in AS2.
    So all u had to do is put this code on frame 1 along with
    some preloading graphics (small size), move all your movie clips u
    want loaded before they actually show up and start your animation
    to frame 2 as keyframe, and Put the ones who show up at the start
    in your movie at frame 3 where you actually go when preloading is
    finished.
    So I want to do the same thing in AS3.. I've found tutorials
    about preloading swfs images and so on but I don't need that.. I
    need this one here.. so does anyone have any idea how to do that ?
    I will be very grateful !
    Waiting for replies,
    Filip Nedyalkov
    Also u had to set Export frame for classes = 2 (in the
    publish settings),

    The reason you need it is because you are using the .text
    property on a member of the _root object. (I'm guessing but it
    wouldn't surprise me).
    About the import statement
    This is a personal philosophy and I'm open to valid
    suggestion here but the Flash Player looks at your code and builds
    a list of all the different classes that will be required at
    run-time and need to included in the compressed swf. If you an
    import like this....
    import flash.display.*;
    you are in theory including all of the classes inside of the
    flash display package. This is not actually the case. Even if you
    include the entire package in your code, all you are actually doing
    is telling Flash that this path/package is available for searching
    for the classes you are using in your document. Flash is only going
    to include a list of "necessary" classes when it runs its compile
    for your swf so keep that it mind. It is actually better to include
    the entire package set in my opinion thus playing it safe.
    It is a known bug and issue with preloading code inside
    IE6(7?) that prevents any kind of update being pulled from the
    browser concerning a files download. I've only had this issue in
    IE7 myself but this doesn't affect me or work since I typically
    only use the top level of a swf as a container for individual swfs
    which I load in using the Loader class. You can read more about the
    problem here (leads off to Actionscript.org forums with related
    post on topic)...
    http://pixelfumes.blogspot.com/2007/07/ie6-as3-preloader-events-failing.html

  • Password protecting swf file

    I'm creating a html page with price guides which are in flash
    swf files. I have the web pages password protected but anyone that
    is somewhat computer savy can get around that by finding the price
    guide swf files. Is there a way to password protect them from
    opening the swf files?

    You can zip it with a password (encrypt it). Unfortunately that option, even though it comes as
    standard equipment, is available only from the command line (terminal.app).
    http://opensoul.org/2007/4/9/creating-encrypted-zip-archives-with-os-x
    You may create an encrypted sparse image on your desktop and store your files
    in it. It's portable too,
    just copy the encrypted image to a flash drive and take it with you.
    http://support.apple.com/kb/HT1578
    There is "Meo" (a free file encryption utility):
    http://www.nchsoftware.com/encrypt/index.html
    There is openssl (comes with OS X), a command line tool (terminal):
    http://osxdaily.com/2007/05/02/quickly-encrypt-a-file-with-openssl/
    True Crypt (one of the most powerful solutions out there - and its free):
    http://www.truecrypt.org/
    Cryptor (a simple easy solution):
    http://www.limiter-inc.com/cryptor.html
    Kj ♘
    There are tons more of them out there, but I recommend these, because the price is right
    and they will get the job done.

  • Preloader for external swf

    first try, changed somethings from previous post, tried to
    make different changes, instead of using if else tried to set an
    onload handler both before and after the loadmovie sentence (not at
    the same time of course), copy paste of what goes on each frame
    (actionscript 1):
    frame 1:
    setProperty("", _focusrect, false);
    Stage.showMenu = false;
    fscommand("showmenu", "false");
    fscommand("allowscale", "true");
    var mensaje = "0 %";
    this.createEmptyMovieClip("pantalla", 0);
    pantalla._x = 0;
    pantalla._y = 0;
    loadMovie("centrino2x.swf", "pantalla");
    frame 2
    mensaje =
    (pantalla.getBytesLoaded()/pantalla.getBytesTotal())*100;
    mensaje = Math.round(mensaje)+" %";
    play();
    frame 3
    if (pantalla.getBytesLoaded()==pantalla.getBytesTotal()) {
    nextFrame();
    } else {
    prevFrame();
    frame 4:
    pantalla.swapDepths(0);
    pantalla.play();
    stop();
    the result: the if else goes right by to next frame, so it
    jumps as if the movie was whole loaded, remaining in last frame as
    a blank screen till the movie loads. the message appears as 100% in
    the half a sec it gets on screen. according to trace, bytes loaded
    and bytes total = 0
    version 2, i nearly copied it from a tutorial linked from
    another post, most of the preloader stuff is nearly exact from the
    tutorial, uses movieloader class (actionscript 2)
    frame 1:
    setProperty("", _focusrect, false);
    Stage.showMenu = false;
    fscommand("showmenu", "false");
    fscommand("allowscale", "true");
    var mensaje = "0 %";
    this.createEmptyMovieClip("pantalla", 0);
    pantalla._x = 0;
    pantalla._y = 0;
    var cargador:MovieClipLoader = new MovieClipLoader();
    var control:Object = new Objetc();
    control.onLoadProgress = function(target, loaded, total) {
    aviso.text = Math.round((loaded/total)*100)+" %";
    control.onLoadInit = function () {
    nextFrame();
    cargador.addListener(control);
    cargador.loadClip("centrino2x.swf", pantalla);
    stop();
    frame 2:
    pantalla.swapDepths(0);
    pantalla.play();
    stop();
    the result: it never changes frame (as if it never finishes
    loading), message giving percentage loaded never appears, and
    traces on event handlers for listener never come out
    i have no idea what %$#"&#" is wrong, i have spend quite
    a time on this, which at first seemed like the easiest part, any
    pointers?

    when first executed pantalla.getBytesLoaded is probably 0 as
    is pantalla.getBytesTotal() causing your problem.
    to remedy, check that pantalla.getBytesLoaded()>0 and that
    pantalla.getBytesLoaded()==pantalla.getBytesTotal().

  • Preloader ignores external swf's actionscript

    Hey guys
    I have an External.swf file that is a video. The swf is 1135 frames long and running just fine by itself, stopping as I want when the actionscript says stop(); on the first frame and looping the end of the clip with gotoAndPlay(837).
    The preloader SwfLoader.swf linked to the External.swf shows the percentage of bytes loaded as it should. However, it runs the video (sound playing in the background) while the preloader shows the loading progress I think it's because it doesn't load the first frame first.
    Once the external swf is loaded, it plays the video again, still ignoring the first actionscript frame that says stop(); and the last frame gotoAndPlay(837).
    Thank you.
    Here is the preloader's actionscript on the first and only frame:
    import flash.geom.*
    import flash.display.*
    var loadurl:String = "External.swf";
    var nDepth:Number = 0;
    var nWidth:Number = 200;
    var nHeight:Number = 20;
    var nPadding:Number = 3;
    var cLoader:MovieClipLoader = new MovieClipLoader();
    var oListener:Object = {onLoadInit:onContentLoaded};
    var mcLoader:MovieClip = this.createEmptyMovieClip("Loader_MC", 0);
    var mcContent:MovieClip = this.createEmptyMovieClip("Content_MC", 1);
    var mcLoadBarBg:MovieClip = mcLoader.createEmptyMovieClip("LoadBarBg_MC", nDepth++);
    var mcLoadBar:MovieClip = null; //Duplicated later with mcLoadBarBg
    var txtPercLoad:TextField = null; //Create after duplication
    var cMatrix:Matrix = new Matrix();
    mcLoader._alpha = 0;
    cMatrix.createGradientBox(nWidth, nHeight, 0, nPadding, nPadding);
    cLoader.addListener(oListener);
    mcLoader.lineStyle(1, 0x000066, 100);
    DrawRect(mcLoader, 0, 0, nWidth, nHeight);
    mcLoadBarBg.lineStyle(1, 0x0000FF, 0);
    mcLoadBarBg.beginGradientFill("linear", [0x006699, 0x0066FF], [100,100], [0, 255], cMatrix, SpreadMethod.PAD);
    DrawRect(mcLoadBarBg, 0, 0, nWidth - nPadding*2, nHeight - nPadding*2);
    mcLoadBarBg.endFill();
    mcLoadBar = mcLoadBarBg.duplicateMovieClip("LoadBar_MC", nDepth++);
    txtPercLoad = mcLoader.createTextField("PercLoad_TXT", nDepth++, 0, 0, nWidth, nHeight);
    mcLoadBar._alpha = 80;
    mcLoadBarBg._alpha = 30;
    Translate(mcTextMask, nPadding, nPadding);
    Translate(mcLoadBarBg, nPadding, nPadding);
    Translate(mcLoadBar, nPadding, nPadding);
    mcLoadBar._xscale = 0;
    mcContent._alpha = 0;
    mcContent._lockroot = true;
    mcLoader._x = Stage.width/2 - mcLoader._width/2;
    mcLoader._y = Stage.height/2 - mcLoader._height/2;
    txtPercLoad._x = mcLoader._width/2 - txtPercLoad._width/2;
    txtPercLoad._y = mcLoader._height/2 - txtPercLoad._height/2;
    SetTextFormat(txtPercLoad, "0%");
    mcLoader._alpha = 100;
    cLoader.loadClip(loadurl, mcContent);
    _root.onEnterFrame = function()
       var nBytesLoaded:Number = mcContent.getBytesLoaded();
       var nBytesTotal:Number = mcContent.getBytesTotal();
       var nPercLoaded:Number = Math.round(nBytesLoaded / nBytesTotal * 100);
       if(nPercLoaded > 0)
          SetTextFormat(txtPercLoad, nPercLoaded.toString() + "%");
                mcLoadBar._xscale = nPercLoaded;
    function onContentLoaded(Void):Void
       //trace(_root + "::onContentLoaded");
       SetTextFormat(txtPercLoad, "100%");
       cLoader.removeListener(oListener);
       delete _root.onEnterFrame;
       delete oListener;
       delete cLoader;
       _root.onEnterFrame = function()
          //trace(_root + "::onContentLoaded::_root.onEnterFrame");
                var nInc:Number = 5;
                mcLoader._alpha -= nInc;
                mcContent._alpha += nInc;
                if(mcLoader._alpha <= 0) startLoadedContent();
    function startLoadedContent(Void):Void
       delete _root.onEnterFrame;
       mcLoader.removeMovieClip();
       mcContent._alpha = 100;
       mcContent.play();
    function DrawRect(mc:MovieClip, nX:Number, nY:Number, nW:Number, nH:Number, nR:Number)
       trace("DrawRect in: " + mc);
       if(nR == undefined) nR = 6;
       mc.moveTo(nX+nR,nY);
       mc.lineTo(nX+nW-nR,nY);
       mc.curveTo(nX+nW,nY,nX+nW,nY+nR);
       mc.lineTo(nX+nW,nY+nH-nR);
       mc.curveTo(nX+nW,nY+nH,nX+nW-nR,nY+nH);
       mc.lineTo(nX+nR,nY+nH);
       mc.curveTo(nX,nY+nH,nX,nY+nH-nR);
       mc.lineTo(nX,nY+nR);
       mc.curveTo(nX,nY,nX+nR,nY);
    function SetTextFormat(txtField:TextField, sText:String)
       var txtFmt:TextFormat = new TextFormat();
       sText = "Loading... " + sText;
       txtFmt.font = "Verdana";
       txtFmt.align = "center";
       txtFmt.size = 11;
       txtFmt.color = 0x000066;
       txtFmt.bold = true;
       txtField.selectable = false;
       txtField.text = sText;
       txtField.setTextFormat(txtFmt);
       txtFmt = null;
    function Translate(mc:MovieClip, nX:Number, nY:Number):Void
       mc._x = nX;
       mc._y = nY;

    Hi kglad,
    The external swf is a movieclip (flv embedded with an AS3 layer to control the timeline) exported as an swf file .
    The first frame of the external swf is just stop();
    I didn't know the proloader code was AS2 though
    The preloader works fine with the external swf locally, but the problem happens when I run them from my server.
    The external swf itself and its code works fine from the server, both combined don't, so I guess the problem comes from the preloader. Probably because of the AS being 2 insted of 3.

  • Firefox wont load hotlink protected SWFs

    When I have hotlink protection (via htaccess or cpanel) firefox returns forbidden on files that use SWF's. For example my SWF file uses a .txt to gather the data needed but on firefox this returns forbidden. I want this forbidden to stop hot-linking but firefox doesn't allow this. I have a test of this at habplus.com/betaclient.php and I am hotlink protecting furnidata but it returns forbidden on firefox. This works for all other browsers.

    See:
    *[https://bugzilla.mozilla.org/show_bug.cgi?id=410904 bug 410904] - http_referer request not being sent with embedded flash

  • Including external swf file with preloader in main swf file

    I'm creating a flash 3d website for a company. The idea is
    that there is one overall swf file - this holds the navigation and
    design. Once the user clicks on a button, it goes to frame 10, I
    have included the following script to load a swf file
    loadMovie("deepbartesting.swf", maincontent);
    this.onEnterFrame=function(){
    if(movieClipName._currentframe==5){
    movieClipName.stop();
    delete this.onEnterFrame;
    my problem is that this file is around 3mb. I created a
    preloader with it, with the code
    onClipEvent (load) {
    total = _root.getBytesTotal();
    } onClipEvent (enterFrame) {
    loaded = _root.getBytesLoaded();
    percent = int(loaded/total*100);
    percen101 = ""+percent+"%";
    gotoAndStop(percent);
    if (loaded == total) {
    _root.gotoAndPlay(2);
    the preloader works, but instead of going to frame 2 of that
    swf file, it goes to frame 2 of the overall swf that holds the
    navigation. Does anyone know how to get around this so that it goes
    to frame 2 in the same swf file as the preloader?
    Thanks for your help

    instead of _root, use this._parent (if your preloader is on
    its main timeline).

Maybe you are looking for