Load var swf - half working...

In previous thread we created the random script.
Now i want to switch it, to able to load swf's.
showing 10 random numbers in the 10 textfield worked fine.
Currently after the modification, it only display the last movie number for all the 10 clips. (dooh).
I tried to add +String(i+1) for the variable newSWFRequest (ofcourse it didnt work)
I have searched and read post on forums. but couldnt trace the problem. (it could also be that ac3 doesnt support this???)
So is there a way to enable this? or was it something simple that i overlooked again? 
var randNums:Array = new Array();
myButton_btn.addEventListener(MouseEvent.CLICK, showRandomSWF);
function showRandomSWF(event:MouseEvent):void{
for (var i:int = 0; i<10; i++) {
     var randNum:int = Math.floor(Math.random()*100)+1;
     if(randNums.indexOf(randNum) == -1){
            randNums.push(randNum);
             //this was the previous script that works fine
            //this["myNumber"+String(i+1)+"_txt"].text = String(randNum);
// now i want to add this...
var swfName:String = "movies/movie" + String(randNum) + ".swf";
var newSWFRequest:URLRequest = new URLRequest (swfName);
} else {
            i--;
     } // end if
loader.load(newSWFRequest);
loader.x = Xpos;
loader.y = Ypos;
addChild(loader);
loader2.load(newSWFRequest);
loader2.x = Xpos+100;
loader2.y = Ypos;
addChild(loader2);
//etcetera
} //end of for i
} // end of function showRandomSWF

i am getting a runtime error 1502 for the loop when press to many time on the button.
searched through the forums and tried to add the break; command for the loop
(have tried almost every single place i can think off)
but doesnt seemes to work.
what i want is:
when click on button - the script runs and displays what i want. when the loop finishes the count at 10 - should stop looping..
and when i hit the button again - script should refreshes and start loop and displaying the objects.
where should i use break; in the loop?  or is there other command to fix this bug?

Similar Messages

  • Problem when load more swf files work with xml files into my movie

    hi ;
    I have one flash file & more of swf files which work with xml files .
    when I load one swf file into my flash file  and remove it and load anther one on the same movieclip in my flash file it load the old swf file.
    when i load one on movieclip and remove it and load anther swf  on anther movieclip the file doesn`t work  and stoped.
    when test my flash file to load and remove swf files without xml file it work fine but when repleaced the swf files with other work with xml files the problem hapend.
    thanks;

    YOu should trace the names of the files that are being targeted for loading to see if they agree with what you expect.  If you want help with the coding you will need to show the code that is relevant to your problem (not all of it)

  • Loading multiple SWFs and storing them (code not working under Firefox 23 and Chrome)

    Hey guys,
    Anyone has any idea why this code suddenly don't work anymore? (It works under internet explorer but not firefox and chrome
    The code under is placed on my main swf to preload all my external swfs and store them for not having to wait too long to access them.
    Thx guys.
    I took the code from here btw: http://www.beautifycode.com/the-finer-art-of-loading-2-handling-multiple-swfs#snippet
    I'm running flash player 11.8.800.94... It used to work under Firefox and Chrome
    var _swfLoader:Loader;
    var _swfRequest:URLRequest;
    var _swfPathArr:Array = new Array("00.swf", "01.swf", "02.swf");
    var _swfClipsArr:Array = new Array();
    var _swfTempClip:MovieClip;
    var _loadedSWFs:int;
    startLoading(_swfPathArr);
    function startLoading(pathArr:Array):void {
    _swfLoader = new Loader();
    _swfRequest = new URLRequest();
    loadSWF(pathArr[1]);
    function loadSWF(path:String):void {
    setupListeners(_swfLoader.contentLoaderInfo);
    _swfRequest.url = path;
    _swfLoader.load(_swfRequest);
    function setupListeners(dispatcher:IEventDispatcher):void {
    dispatcher.addEventListener(Event.COMPLETE, onSwfComplete);
    function onSwfComplete(event:Event):void {
    event.target.removeEventListener(Event.COMPLETE, onSwfComplete);
    _swfTempClip = event.target.content;
    _swfTempClip.customID = _loadedSWFs;
    _swfClipsArr.push(_swfTempClip);
    if(_loadedSWFs <_swfPathArr.length - 1) {
    _loadedSWFs++;
    loadSWF(_swfPathArr[_loadedSWFs]);
    } else {

    Hi kglad,
    The problem was coming from my server.
    I recently played with some settings  from a "cache control tool" offered by my hosting but i thought i had it back at default. Turns out i must've missed something. Now i have the .html caching on and everything works good on all browser.
    I have another question tho...
    I'd like to know if there's a way to cache an html file without having to ask my hoster to cache all of my htmls...
    I'm using this code now but maybe there's a way to add something that will cache this page specifically?
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>title</title>
    <script language="javascript">AC_FL_RunContent = 0;</script>
    <script src="fluid_site.js" language="javascript"></script>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
    <link href="style.css" rel="stylesheet" type="text/css" media="screen"/>
    </head>
    <!--url's used in the movie-->
    <!--text used in the movie-->
    <!-- saved from url=(0013)about:internet -->
    <script>
        if (AC_FL_RunContent == 0) {
            alert("This page requires fluid_site.js.");
        } else {
            AC_FL_RunContent(
                'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
                'width', '100%',
                'height', '100%',
                'src', 'index',
                'quality', 'medium',
                'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
                'align', 'middle',
                'play', 'true',
                'loop', 'true',
                'scale', 'showall',
                'devicefont', 'false',
                'wmode', 'window',
                'id', 'index',
                'name', 'index',
                'menu', 'false',
                'allowFullScreen', 'false',
                'allowScriptAccess','sameDomain',
                'movie', 'index',
                'salign', ''
                ); //end AC code
    </script>
    <body>
    <noscript>
        <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="100%" height="100%" id="index" align="middle">
        <param name="allowScriptAccess" value="sameDomain" />
        <param name="allowFullScreen" value="false" />
        <param name="MENU" value="false">
        <param name=wmode value=window>
        <param name="movie" value="index.swf" /><param name="quality" value="medium" /><embed src="index.swf" quality="medium" width="100%" height="100%" wmode="direct" name="fluid_site" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
        </object>
    </noscript>
    </body>
    </html>
    Thanks

  • Design/gallery website - loading external SWF asset on splash page

    Hello all,
    This forum has been such a help with my website, i've found the answers to hundereds of questions but I've hit a bit of a brick wall and I wonder if anyone can help me.
    I have recently built a website http://www.intivision.co.uk/ using illustrator/flash/flash catalyst. It's still a work in progress and I'm happy with the gallery pages and general functionality but I'm having major issues with my splash/load screen and a few other niggles.
    The animation on the front page is a looping photo gallery i created in flash (as a .SWF) and imported into Catalyst. It is designed to play (and loop) indefinately after 2seconds of loading the title page. Half the time I access the site the animation does not load at all and just shows a blank screen and my logo. It will appear once the page is refreshed. A very bad first impression.
    I have a feeling this is because the SWF is externally loading the asset (which is only 350kb). Is there a solution or a way to imbed this animation so the entire project won't 'play' until this intro is loaded?
    Thanks - Tom
    ps Any other comments would be greatly appreciated

    Thanks for taking your time! Much appreciated.
    I like not complicated :-)  So it is now loading from the start - stretching over the whole timeline. How do I controll the visibility during the "HOME" = that is invisible?
    This is the code I use to load the external swf:
    var Xpos:Number=0;
    var Ypos:Number=0;
    var swf:MovieClip;
    var loader:Loader=new Loader();
    var defaultSWF:URLRequest=new URLRequest("main_movie_241x700.swf");
    loader.load(defaultSWF);
    loader.x=Xpos;
    loader.x=Ypos;
    addChild(loader);

  • Can I combine two methods of code to load various SWF files into the same location

    I presently have a set up where a large SWF file brought on the stage by clicking small icons from the scrollable thumbnail menu on the bottom of the stage. All of it happens at the same frame with .xml loading file.
    Here is the code for constructing the ImageLoader(for thumbnails) and SWFLoader for (bigger SWF files)
    [CODE]
       function _xmlCompleteHandler(event:LoaderEvent):void {
       _slides = [];
       var xml:XML = event.target.content; //the XMLLoader's "content" is the XML that was loaded.
       var imageList:XMLList = xml.image; //In the XML, we have <image /> nodes with all the info we need.
       //loop through each <image /> node and create a Slide object for each.
       for each (var image:XML in imageList) {
        _slides.push( new Slide(image.@name,
              image.@description,
              new ImageLoader("loadingAssets/appThumbnails/slideshow_image scroller greenSock_mine/assets/thumbnails/appThmb_imgs/" + image.@name + ".jpg",
                   name:image.@name + "Thumb",
                   width:_THUMB_WIDTH,
                   height:_THUMB_HEIGHT,
                   //centerRegistration:true,//messes up the code as places SWFLoader in the upper left corner which is 0,0 coordinates
                   //x:260, y:320,//doesn't work here but works in line 69
                   scaleMode:"proportionalInside",
                   bgColor:0x000000,
                   estimatedBytes:13000,
                   onFail:_imageFailHandler}),
              new SWFLoader("loadingAssets/appThumbnails/slideshow_image scroller greenSock_mine/assets/images/" + image.@name + ".swf",
                    name:image.@name + "Image",
                    width:_IMAGE_WIDTH,
                    height:_IMAGE_HEIGHT,
                    //centerRegistration:true,//messes up the code as places SWFLoader in the upper left corner which is 0,0 coordinates
                    x:0, y:144,
                    scaleMode:"proportionalInside",
                    bgColor:0x000000,
                    estimatedBytes:820000,
                    onFail:_imageFailHandler})
    [/CODE]
    Here is what I would like to resolve. I have another section on the site with an image collage. Every image is a button. I want to script this each image on click to go to the label with ImageLoader and SWFLoader AND TO OPEN A UNIQUE SWF (ASSOCIATED WITH AN IMAGE CLICKED) ON THAT PAGE
    Previously this is what I did to achieve it. I would specify a String:
    [CODE]
    var sourceVar_ProductsPopUps:String;
    [/CODE]
    and then all my buttons will have their unique SWF assigned for them which opens at another labeled section ("prdctsPopUps" in this example):
    [CODE]
    function onClickSumix1PopUp(event:MouseEvent):void {
      sourceVar_ProductsPopUps="prdcts_popups/sumix1-popup_tl.swf";
      gotoAndPlay("prdctsPopUps");
    [/CODE]
    Then in the "prdctsPopUps" section I would specify that var string to bring up SWF files. The value of sourceVar_ProductsPopUps allows to load mulitple SWFs from the previous page.
    [CODE]
    loaderProductPopUps = new SWFLoader(sourceVar_ProductsPopUps,
    [/CODE]
    But I need both of them to be working at the same time. First there is a sectionA from where a user can navigate to specifically targeted SWF to section B's SWFLoader. Then in the section B a user has an option to bring up other SWF files into SWFLoader from the scrollable thumbs menu. Is there a way to combine these two lines into one:
    [CODE]
              new SWFLoader("loadingAssets/appThumbnails/slideshow_image scroller greenSock_mine/assets/images/" + image.@name + ".swf",
    [/CODE]
    and
    [CODE]
    new SWFLoader(sourceVar_ProductsPopUps,
    [/CODE]

    Thanks for looking into my issue.
    Unfortunatelly I am not so advanced in AS and do not complitely understand the logic of the problem. I will try to decribe my set up more precise.
    So, my main flash file is broken into labeled sections on the main time line.
    One of the sections is "Applications" It has an animated collage of images. Each image acts as a button and once clicked brings a user to a section called "ApplicationsPopUps".
    "ApplicationsPopUps" section has small image thumbnails scroll menu at the bottom of the screen and a large SWFLoader in the middle of the screen. User can click on an image in the thumbnails scroll menu and a corresponding SWF file will load in the middle of the screen in SWFLoader. User can click on left/right navigation buttons and preceeding/following SWF file will load in SWFLoader.
    Everything works fine (with your previous help)
    Here is the working code for the ImageLoader and SWFLoader (please let me know if you need additional code on the page):
    function _xmlCompleteHandler(event:LoaderEvent):void {        _slides = [];       var xml:XML = event.target.content; //the XMLLoader's "content" is the XML that was loaded.        var imageList:XMLList = xml.image; //In the XML, we have  nodes with all the info we need.        //loop through each  node and create a Slide object for each.       for each (var image:XML in imageList) {         _slides.push( new Slide(image.@name,               image.@description,               new ImageLoader("loadingAssets/appThumbnails/slideshow_image scroller greenSock_mine/assets/thumbnails/appThmb_imgs/" + image.@name + ".jpg",               {                    name:image.@name + "Thumb",                    width:_THUMB_WIDTH,                    height:_THUMB_HEIGHT,                    //centerRegistration:true,//messes up the code as places SWFLoader in the upper left corner which is 0,0 coordinates                    //x:260, y:320,//doesn't work here but works in line 69                   scaleMode:"proportionalInside",                    bgColor:0x000000,                    estimatedBytes:13000,                    onFail:_imageFailHandler}),                 new SWFLoader("loadingAssets/appThumbnails/slideshow_image scroller greenSock_mine/assets/images/" + image.@name + ".swf",                   {                     name:image.@name + "Image",                     width:_IMAGE_WIDTH,                     height:_IMAGE_HEIGHT,                     //centerRegistration:true,//messes up the code as places SWFLoader in the upper left corner which is 0,0 coordinates                   x:0, y:144,                     scaleMode:"proportionalInside",                     bgColor:0x000000,                     estimatedBytes:820000,                     onFail:_imageFailHandler}) 
    Thumbnails in the section "ApplicationsPopUps" and images in the image collage in the section "Applications" represent the same photographs. So when a user clicks on one of the images in "Applications" section it would be natural that that image will load in the "ApplicationsPopUps" section. However "ApplicationsPopUps" section presently has a working code (as sampled above) It looks too complex for me and I do not know hot to implement this feature. I do want to keep the functionality of the thumbs image scroller in section "ApplicationsPopUps" as it is now. But I want to add that when a user click on an image from section"Applications" then that particular SWF file will load in SWFLoader in section "ApplicationsPopUps" and then the present functionality can as well be exectuted. Presently it just opens on a first image in xml order.
    P.S. I see that you had a download link in your answer. How did you do it? I could also upload a small sample file with my problem. This way you could see all the set up right away.

  • Loading multiple swfs using air 3.6 for ios

    Adobe, can you please provide us with the code to load multiple swf files for ios. Please provide examples. The code below loads multiple swfs, but the swfs stall, so this does not seem to be a solution.
    Code description: A flash file made up of 4 frames with forward and back buttons that navigate from frame to frame. The code loads three different swf files in frames 2, 3 and 4.
    Frame 1:
    var myLoader:Loader;
    var loaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
    if(myLoader == null){myLoader = new Loader(); addChild(myLoader); }
    else {myLoader.unload();}
    Frame 2:
    myLoader.unload();
    myLoader.load(new URLRequest("file1.swf"),loaderContext);
    Frame 3:
    myLoader.unload();
    myLoader.load(new URLRequest("file2.swf"),loaderContext);
    Frame 4:
    myLoader.unload();
    myLoader.load(new URLRequest("file3.swf"),loaderContext);

    I've just tried loading, unloading and then loading again same SWF with 2 library objects linked for AS3 export. It worked both on simulator and on device in debug mode. When I look inside swf it does contain AS3 code.
    So is my swf a pure asset SWF? Or Intellij Idea 12 that I'm using does stripping automatically?
    And then I've read your comment at http://forums.adobe.com/message/5217325#5217325 and run 'swfdump' utility on my .swf file. Looks like there's no ABC2 code, that's why app was able to load, unload and load again the same swf.
    public dynamic class net.games.bg extends flash.display.MovieClip
      native public function bg():*;
      native public var one:flash.display.MovieClip;
      native public var three:flash.display.MovieClip;
      native public var two:flash.display.MovieClip;
    public dynamic class net.games.z1 extends flash.display.MovieClip
      native public function z1():*;
    I can access objects as instances through root  or as objects through getDefinition.
    private var aLoader : Loader;
    private function init():void
                load1();
            private function load1():void
                aLoader   = new Loader();
                var url:URLRequest = new URLRequest("levels/expirementlevel1.swf");
                var loaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
                aLoader.load(url, loaderContext); // load the SWF file
                aLoader.contentLoaderInfo.addEventListener(flash.events.Event.COMPLETE, handleSWFLoadComplete1, false, 0, true);
            private function handleSWFLoadComplete1(e:flash.events.Event):void {
                var levelObjectsMC:flash.display.MovieClip = e.target.loader.content;
                for (var i:uint = 0; i < levelObjectsMC.numChildren; i++){
                    trace ('\t|\t ' +i+'.\t name:' + levelObjectsMC.getChildAt(i).name + '\t type:' + typeof (levelObjectsMC.getChildAt(i))+ '\t' + levelObjectsMC.getChildAt(i).x);
                var LibraryClass:Class = e.target.applicationDomain.getDefinition("net.games.z1") as Class;
                var myLibraryObject:flash.display.MovieClip = new LibraryClass as flash.display.MovieClip;
                trace(' load 1 ' + myLibraryObject);
                aLoader.unload();
                load2();
                //addChild(levelObjectsMC);
            private function load2():void
                aLoader   = new Loader();
                var url:URLRequest = new URLRequest("levels/expirementlevel1.swf");
                var loaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
                aLoader.load(url, loaderContext); // load the SWF file
                aLoader.contentLoaderInfo.addEventListener(flash.events.Event.COMPLETE, handleSWFLoadComplete2, false, 0, true);
            private function handleSWFLoadComplete2(e:flash.events.Event):void {
                var levelObjectsMC:flash.display.MovieClip = e.target.loader.content;
                for (var i:uint = 0; i < levelObjectsMC.numChildren; i++){
                    trace ('\t|\t ' +i+'.\t name:' + levelObjectsMC.getChildAt(i).name + '\t type:' + typeof (levelObjectsMC.getChildAt(i))+ '\t' + levelObjectsMC.getChildAt(i).x);
                var LibraryClass:Class = e.target.applicationDomain.getDefinition("net.games.z1") as Class;
                var myLibraryObject:flash.display.MovieClip = new LibraryClass as flash.display.MovieClip;
                trace('load 2 x ' + myLibraryObject.x);
                aLoader.unload();

  • Loading external swfs extending from classes in the same shared codebase

    Hey there!
    I'm currently developing a game in flash and want to be able to divide up my .fla assets in a way that means artists can work on a game menu .fla in isolation from the game.fla and rest of the game code.
    If I could briefly explain how I've approached this so far, I would be extremely if people could shout in my general direction and tell me I am stupid, or even better still, give me helpful advice as to where I am going wrong and how I can correct it!
    My project is setup like this:
    HighScoreMenu.fla -> document class HighScoreMenu extending GameMenu class.
    game.fla ->document class game.as
    game.as class loads the published HighScoreMenu.swf and manipulates the menu i.e. animates on and off screen via inherited functions in the GameMenu class.
    Now this seemed to work to begin with, until my code evolved and upon going to publish my HighScoreMenu.fla flash started complaining about symbols being used in Game.as that were in Game.fla...  If I'm only publishing the HighScoreMenu which extends from GameMenu then why is it even looking to compile Game.as?
    Can you spot the problem in the way I am doing this, or is there a better approach I should try?
    Any advice greatly appreciated!
    Stevie.

    No it doesn't seem to, however though they both have a reference to the HighScoreManager so there is some overlap there between menu and game code, but the menu classes don't reference any symbols on the game.fla...
    Just to clarify, I have an fla HighScoreMenu.fla, which has a child symbol HighScoreMenu which uses the following class.
    public dynamic class HighScoreMenu extends GameMenu
         //convenient storage for competition Manager object
         private var _highScoreManager:HighScoreManager;
    The game then loads this class as follows:
    I load the swf "HighScoreMenu.swf" and once its loaded I obtain the menu class like so:
    var cls:Class = Class( applicationDomain.getDefinition("Menus.HighScoreMenu") );
    var object:* = new cls();
    ...and create a new instance of the menu.
    Is there anything fundamentally wrong with approaching it in this way?

  • Problem in loading secondary swf

    Hi,
    I am trying load a font as swf for IOS application.i tried load to it from both application directory and application storage directory.but it always throws the following error.
    Fast debuging mode everything works fine.
    Air Sdk 3.8
    Flash Builder 4.7
    swf version 20
    Error 3747: Multiple application domains are not supported on the operating system.
    Code i used to load the swf.
    var context:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain,null);
    var loader:Loader = new Loader();
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, fontLoadComplete);
    loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
    var strPath:String = "assets/fonts/font.swf"
    var urlReq: URLRequest = new URLRequest();
    urlReq = strPath;
    loader.load(urlReq, context);
    please correct me if i am doing any thing wrong in loading swf with as3 code.
    Regards,
    Saravanan

    Hi Nimit,
    Sorry for late reply.
    Actually problem is in my side.I am loading two swfs one with code in side another without code.
    I used loader content for only swf containing code inside but both the swfs requires to specify the loader content to same application domain.
    Its working fine after set the loader content to both swfs.
    sorry for trouble and thanks for the response.
    Regards,
    Saravanan.G

  • How do i stop loading a swf file which is still in progress.

    //I have three buttons on the stage (btn1, btn2, btn3)
    when i click the first button swf starts loading
    while the swf is loading if i press the 2nd button
    the first swf wont stop loading and both the swfs start playing
    but if the first swf is fully loaded then every thing workes fine.
    so please let me know how do i stop loading a file which is still in progress.
    var _contentSWF:ContentSWF
    var _content
    btn1.addEventListener(MouseEvent.CLICK, handleClick)
    btn2.addEventListener(MouseEvent.CLICK, handleClick)
    btn3.addEventListener(MouseEvent.CLICK, handleClick)
    function handleClick(){
        if(_content!=undefined){
            _contentSWF.removeContent()
            removeChild(_contentSWF);
            _contentSWF =null;
        _contentSWF = new ContentSWF()
        _content = addChild(contentSWF);
        _contentSWF.init(some path.swf)
    //ContentSWF.as
    private var _path:String
    private var swfLoader:Loader
    private var _content
    public class ContentSWF extends Sprite{
        public function init(path){
            if(_content!=null){
                _content.content.removeEventListener(Event.COMPLETE, completeHandler)
                _content.removeChild(mymc)
                _content=null
            swfLoader=new Loader();
            _path = path
            swfLoader.load(new URLRequest(path));
            swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoaded);
        public function removeContent(){
            swfLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, swfLoaded);
            swfLoader.unloadAndStop()
        private function swfLoaded(e:Event){
            _content = addChild(mymc)

    Thanks Kglad, it all worked fine but can you help me in this.
    I have 4 movieclips (_a,_b,_c,_d) when i click each of the movieclip they load a SWF(my_mc)
    now when the swf file loades it starts loading a Sound(mp3)
    Now when i press another button  (_b) while this mp3 is loading
    all the methords like  Loader.close and loader.unloadAndStop() workes fine  but i dont know how dose the MP3 loades and start playing
    I also used the below script in  my_mc.swf , but it wont work
    this.addEventListener(Event.unload, myfun)
    function myfun(e:Event){
    \     if(_sound.bytesLoaded<_sound.bytesTotal){
              _sound.close()
         if (_chanel){
              _chanel.stop()

  • Loading external swf  not complete

    Hi, I'm trying to load external swf (with more than one frame and actionscript 3 on every frame - I used there "timeline" coding) from my main swf.
    code for loading external swf into main swf:
    var loader01:Loader;
    function openGame1(evt:Event):void
    loader01 = new Loader();
    var requestSWF01:URLRequest = new URLRequest("game01.swf");
    loader01.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, processHandler);
    loader01.contentLoaderInfo.addEventListener(Event.INIT, initHandler);
    loader01.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
    loader01.load(requestSWF01);
    addChild(loader01);
    function processHandler(evt:ProgressEvent):void
    var loaded:Number=evt.target.bytesLoaded;
    var total:Number=evt.target.bytesTotal;
    var stav:Number=loaded/total;
    loaded_txt.text=(Math.round(stav*100))+" %";
    function initHandler(evt:Event):void{
    loaded_txt.text="";
    function errorHandler(evt:IOErrorEvent):void
         trace ("Error: " + evt.text);
    I found out that this works only for loading swf, which has only one frame (and all actionscript on that frame)... It seems that if there are more frames, than it will not load complete swf (hmm maybe it is caused, because not all objects on frames are export in first frame). Preloading starts but after for example 20 % the event.INIT is fired and the external swf starts to play (and crashes..).
    You can see this here http://bvyborcik.xf.cz/  If you click on the blue building on the left with blinking text "Start hry" you will see what happens - preloading is not completed and after clicking on first floor btn, the swf crashes...
    Please is there a solution for this kind of problem?  Any help or pointing is welcome.
    regards Boris

    just curious, is the file you want to load the swf into set up exactly the same way with the same stage size, fps, and layers?

  • How to load External swf file in AIR

    I try this code its working in computer but when I publish this file in .apk or .ipa , my external swf file is not opening
    (I include my external file as well)
    places_btn.addEventListener(MouseEvent.MOUSE_DOWN, newvid);
    function newvid(event:MouseEvent) {
         trace("you clicked me");
         var loadit = new Loader();
         addChild(loadit);
         loadit.load(new URLRequest("scene02.swf"));

    thx boss its working great
    I have 3 scenes; load scene code is working great
    1. How can I unload the scene?
    2. Can I unload all scenes or one by one?
    can I unload some think like this
    Load scene 2 , unload scene 1 and scene 3
    Load scene 3, unload other all scene
    i try this
    load2.addEventListener(MouseEvent.MOUSE_DOWN, newvid);
    function newvid(event:MouseEvent) {
              trace("you clicked me");
              var loadit = new Loader();
              addChild(loadit);
        var _lc:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
        loadit.load(new URLRequest("scene02.swf"), _lc);
              loadit.unload();
    load3.addEventListener(MouseEvent.MOUSE_DOWN, newvid1);
    function newvid1(event:MouseEvent) {
              trace("you clicked me");
              var loadit = new Loader();
              addChild(loadit);
        var _lc:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
        loadit.load(new URLRequest("scene03.swf"), _lc);
              loadit.unload("scene01.swf scene02.swf");

  • Unloading a loaded external SWF with a close button on the external SWF to unload

    I have found some discussion on this topic but I am still having trouble getting it to work and was hoping to get some help here.
    Here I have a file: http://www.dril-quip.com/test/main.swf
    I have: main.swf (a menu) and I have module.swf (content)
    If you navigate to Subsea Wellhead Systems/SS-15 BigBore II and click on that I have it load an external swf which covers most of the parent.
    So far so good. My problem is unloading the loaded 'Child' swf with the button provided on the loaded 'Child' swf.
    below is the code I used to load the file but I cant, for the life of me, find a way to unload it.
    var bigboreLoader:Loader = new Loader();
    btnbb2.addEventListener(MouseEvent.MOUSE_UP, bigborecontent);
    function bigborecontent(event:MouseEvent):void{
    var bigboreRequest:URLRequest = new URLRequest("moduletemplate.swf");
    bigboreLoader.load(bigboreRequest);
    stage.addChild(bigboreLoader);
    I am certain it requires the Child to communicate with the parent somehow but I am at a loss. If I could get a bit of advice or a link to something deal with this, it would be a big help. I just need to have my links load my modules and the remove them when the close buttong is hit on the loaded swf. I promise I have done searches and I admit I have found asnwers but still they are not working. I found the code below:
    Main FLA:
    function removeF() {
    removeChild(bigboreLoader);
    var bigboreLoader:Loader = new Loader();
    btnbb2.addEventListener(MouseEvent.MOUSE_UP, bigborecontent);
    function bigborecontent(event:MouseEvent):void{
    var bigboreRequest:URLRequest = new URLRequest("moduletemplate.swf");
    bigboreLoader.load(bigboreRequest);
    stage.addChild(bigboreLoader);
    EXTERNAL FLA:
    btnClose2.addEventListener(MouseEvent.CLICK, bigborecontent);
    function bigborecontent(myevent:MouseEvent):void {
    MovieClip(parent.parent).removeF();
    I think I have a misunderstanding of the code. Thanks for any help you might be able to provide.

    This was the original code I got:
    Main FLA: (on AS layer inside DropDownButton Movie Object)
    function removeF() {
    removeChild(myLoader);
    var myLoader:Loader=new Loader ();
    page1_mc.addEventListener(MouseEvent.CLICK, page1content);
    function page1content(myevent:MouseEvent):void {
    var myURL:URLRequest=new URLRequest("page1.swf");
    myLoader.load(myURL);
    addChild(myLoader);
    EXTERNAL FLA: (on main time line of this file)
    close_mc.addEventListener(MouseEvent.CLICK, closeMC);
    function closeMC(myevent:MouseEvent):void {
    MovieClip(parent.parent).removeF();
    Main.FLA
    myLoader=bigboreLoader (my new loader)
    page1_mc=btnbb2 (the button who event will call external swf)
    page1content = bigborecontent (name given to SWF being loaded???)
    myURL=bigboreRequest (my new URLrequest for bigbore)
    page1.swf=moduletemplate.swf (actual address of what I am loading)
    External.FLA
    close_mc=button that will close external swf
    closeMC=movie clip to close?

  • Tracing loaded external SWF bytes

    I have a file that loads 13 external Swfs into a shell. When
    they are all loaded, the shell plays the files in succession. That
    works fine, but I a trying to show the progress of the loading
    process, but the flash pretty much freezes until all of the files
    are loaded then jumps my progress bar all the way to the end.
    Basically, nothing is allowed to happen until the scenes are all
    loaded completely. I can't even put a revolving animation on the
    main timeline to display until the files are loaded. The animation
    just sits on frame one until all the files are loaded, then starts
    to play, which defeats the purpose. Is there anyway to pause the
    code until the first movie is loaded, hten move on to then next
    movie load or a way to concurrently display bytes loaded while the
    file is being loaded.
    var courseArray:Array= Array("Scene1.swf", "Scene2.swf",
    "Scene3.swf", "Scene4.swf", "Scene5.swf", "Scene6.swf",
    "Scene7.swf", "Scene8.swf", "Scene9.swf", "Scene10.swf",
    "Scene11.swf", "Scene12.swf", "Scene13.swf");
    startup = function() {
    this.createEmptyMovieClip("scene"+(i+1), (i+1));
    this["scene"+(i+1)].loadMovie(courseArray
    for (i=0; i<13; i++) {
    startup();
    //****Jumps progress bar 1/13th of the way each time the
    loading code happens****
    this.progressBar.gotoAndStop(_root.progressBar._currentframe+(int(100/13)));
    The code all seems to happen immediately because the
    progressBar jumps all the way to the end right away, but the flash
    freezes until the files are completely loaded. Can I pause this
    code until each individual file is finished loaded, then run the
    next loop?

    That is what I am asking. What would be the code? I already
    had code that counted the .getBytesLoaded(), and would move the
    progressBar based on what percent of the .getBytesTotal(). Like I
    said before. The progressBar would just sit at 0%, then jump to
    100% when the movie finished loading. The flash would just hang up,
    then jump all the way past when done loading. In the code I have
    below, it is supposed to jump the Progressbar 1/13th of the way
    (because I have 13 files being loaded) each time through the loop,
    but that doesn't work either. It just sits on 1 then jumps to 100
    when the files finish loading even though it should do it in
    progression through the loop.

  • AIR 3.9 for android, how to load file in primordial worker

    when i use AIR 3.9 for android version of my game, i can not load file in primordial worker swf.
    I use the code below:
    var loader : URLLoader = new URLLoader();
    loader.dataFormat = URLLoaderDataFormat.BINARY;
    loader.addEventListener(IOErrorEvent.IO_ERROR,
         function (evt : IOErrorEvent) : void
              trace("load file error: " + evt);
    loader.addEventListener(Event.COMPLETE,
         function (evt : Event) : void
              trace("load file completed: " + evt);
    loader.load(new URLRequest("./music/bgm/bgm_title.mp3"));
    and already set the second parameter of "WorkerDomain.current.createWorker(swf:ByteArray, giveAppPrivileges:Boolean = false):Worker" giveAppPrivileges to be true.
    this code can work on desktop AIR, but failed in android AIR, it tells a IOErrorEvent, and report "Stream Error".
    So, is it a bug of AIR 3.9 for android, or is there somthing i missed?
    Thank you very much for any help.

    Hi,
    The bug 3643406 is fixed now and fix is avaialable in AIR 4.0 beta build. You can download the build from http://labs.adobe.com/downloads/air.html .
    Please share your feedback with us.
    Thanks,
    Nimisha

  • Loading AS2 swf in AS3 fails - sort of

    I have an AS 3.0 file that loads a 2.0 swf. That 2.0 swf
    loads other 2.0 swf.
    When running in the AS 3.0 shell, the file is loaded, but the
    onLoadComplete() function is not called. The clip is loading, but
    no mclListener events are raised. (ie: mclListener.onLoadError ,
    mclListener.onLoadProgress, etc.) If I load the same chain with an
    AS 2.0 parent, the events are raised.
    Any ideas why, or what to do about it???
    Thanks -
    This is the AS 3.0 code:
    //Load the editor.
    var loader:Loader = new Loader();
    var request:URLRequest = new URLRequest("BDAS_Editor.swf");
    loader.load(request);
    addChild(loader);
    This is the AS 2.0 code in the BDAS_Editor.swf:
    var my_mcl:MovieClipLoader = new MovieClipLoader();
    var mclListener:Object = new Object();
    my_mcl.addListener(mclListener);
    my_mcl.loadClip(myPath,Template_mc);
    mclListener.onLoadComplete = function(target_mc:MovieClip,
    status:Number):Void {
    trace("onLoadComplete " + target_mc);

    Ok I found it out (somewhere else).
    The reason was, that you can't use levels when you load content in AS3.
    That Version works:
    var my_mcl:MovieClipLoader = new MovieClipLoader();
    var mc:MovieClip;
    var myListener:Object = {
        onLoadInit: function(target_mc:MovieClip) {
           trace("*********First my_mcl instance*********");
           trace("Movie clip = "+target_mc+" is now initialized");
           target_mc.play();
           fertig();
        onLoadError: function(target_mc:MovieClip, errorCode:String) {
           trace("ERROR CODE = "+errorCode);
           trace("Your load failed on movie clip = "+target_mc+"\n");
    my_mcl.addListener(myListener);
    function load_swf(url:String) {
        mc.removeMovieClip();
        mc = createEmptyMovieClip("mc", getNextHighestDepth());
        my_mcl.loadClip(url, mc);
    var testurl:String = "any_swf_in_as2.swf";
    load_swf(testurl);

Maybe you are looking for