# External swf is playing when preloader does not complete

**URL:** <https://forum.kirupa.com/t/external-swf-is-playing-when-preloader-does-not-complete/327725>\
**Category:** Uncategorized\
**Created:** [March 23, 2012, 9:10am UTC](https://forum.kirupa.com/t/external-swf-is-playing-when-preloader-does-not-complete/327725 "2012-03-23T09:10:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![zooferic](https://avatars.discourse-cdn.com/v4/letter/z/dbc845/32.png) [@zooferic](https://forum.kirupa.com/u/zooferic)\
**Post date:** [March 23, 2012, 9:10am UTC](https://forum.kirupa.com/t/external-swf-is-playing-when-preloader-does-not-complete/327725/1 "2012-03-23T09:10:34Z")

</div>

[LEFT][COLOR=#000000][FONT=Arial]External swf is playing when preloader does not complete.I can not access external swf.My codes;

[/FONT][/COLOR][/LEFT]  
[COLOR=#00008B]package[/COLOR] com  
{  
[COLOR=#00008B]public[/COLOR] [COLOR=#00008B]class[/COLOR] [COLOR=#2B91AF]MainClass[/COLOR] [COLOR=#00008B]extends[/COLOR] [COLOR=#2B91AF]Sprite[/COLOR]  
{  
[COLOR=#00008B]private[/COLOR] [COLOR=#00008B]static[/COLOR] [COLOR=#00008B]var[/COLOR] file:[COLOR=#2B91AF]String[/COLOR] = [COLOR=#800000]“Movie.swf”[/COLOR];  
[COLOR=#00008B]private[/COLOR] [COLOR=#00008B]var[/COLOR] loader:[COLOR=#2B91AF]Loader[/COLOR];

```
    [COLOR=#00008B]static[/COLOR] [COLOR=#00008B]var[/COLOR] txt:[COLOR=#2B91AF]TextField[/COLOR] = [COLOR=#00008B]new[/COLOR] [COLOR=#2B91AF]TextField[/COLOR] ;
    [COLOR=#00008B]static[/COLOR] [COLOR=#00008B]var[/COLOR] format:[COLOR=#2B91AF]TextFormat[/COLOR] = [COLOR=#00008B]new[/COLOR] [COLOR=#2B91AF]TextFormat[/COLOR] ;
    format.color = [COLOR=#800000]"0X003333"[/COLOR];
    format.font = [COLOR=#800000]"Arial"[/COLOR];
    format.size = [COLOR=#800000]"38"[/COLOR];
    txt.defaultTextFormat = format;

    [COLOR=#00008B]public[/COLOR] [COLOR=#00008B]function[/COLOR] [COLOR=#2B91AF]MainClass[/COLOR]()
    {
        loader = [COLOR=#00008B]new[/COLOR] [COLOR=#2B91AF]Loader[/COLOR] ;
        loader.load([COLOR=#00008B]new[/COLOR] [COLOR=#2B91AF]URLRequest[/COLOR](file));
        loader.contentLoaderInfo.addEventListener([COLOR=#2B91AF]ProgressEvent[/COLOR].PROGRESS,preLoad);
        loader.contentLoaderInfo.addEventListener([COLOR=#2B91AF]Event[/COLOR].COMPLETE,showContent);
    }

    [COLOR=#00008B]private[/COLOR] [COLOR=#00008B]function[/COLOR] preLoad(e:[COLOR=#2B91AF]ProgressEvent[/COLOR]):[COLOR=#00008B]void[/COLOR]
    {
        [COLOR=#00008B]var[/COLOR] perc = e.bytesLoaded / e.bytesTotal;
        txt.text = [COLOR=#2B91AF]Math[/COLOR].ceil(perc * [COLOR=#800000]100[/COLOR]).toString();
        txt.x = stage.stageWidth / [COLOR=#800000]2[/COLOR];
        txt.y = stage.stageHeight / [COLOR=#800000]2[/COLOR];
        mc.addChild(txt);
    }

    [COLOR=#00008B]private[/COLOR] [COLOR=#00008B]function[/COLOR] showContent(e:[COLOR=#2B91AF]Event[/COLOR]):[COLOR=#00008B]void[/COLOR]
    {
        mc.removeChild(txt);
        mc.addChild(loader);
        mc.x = stage.stageWidth / [COLOR=#800000]1[/COLOR] - mc.width / [COLOR=#800000]1[/COLOR];
        mc.y = stage.stageHeight / [COLOR=#800000]1.5[/COLOR] - mc.height / [COLOR=#800000]1.5[/COLOR];
    }
}

```

}
