totalFrames of dynamically loaded swf

I tried for 2 days now to find the total number of images to a .swf dynamically loaded.

Here is a code example:

var loader:Loader = new Loader;
loader.load(new URLRequest("mop.swf"))
master_mc.addChild(loader);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, xmlLoadedF);
function xmlLoadedF(event:Event):void
{
    trace(loader.content.totalFrames);
}

I am really puzzled.

Any help would be greatly appreciated.

I know it's old, but I found via google and thought I would correct the error.

You can reference properties avm1 (and methods) swf using localconnection to communicate between SWFs avm1 and avm2, SWF SWF communication when two SWF files uses actionscript 3.0

Tags: Adobe Animate

Similar Questions

  • Cannot target the main stage of dynamically loaded swf...

    A part of the Flash application. I'm working on right now is the following-

    Main stage load an external swf using the following function:

    function loadAsset(evt:String):void{
     var assetName:String = evt;
     if (assetName != null){
      var assetLdr:Loader = new Loader();  
      var assetURL:String = assetName;  
      var assetURLReq:URLRequest = new URLRequest(assetURL);  
      assetLdr.load(assetURLReq);  
      assetLdr.contentLoaderInfo.addEventListener( Event.INIT , loaded)  
      assetLdr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, displayAssetLoaderProgress);   
      function loaded(event:Event):void {  
       var targetLoader:Loader = Loader(event.target.loader);  
       assetWindow.addChild(targetLoader);
      }
     }
    }
    

    The external swf file loaded, load another external swf to itself using the following function:

    function loadQuiz(evt:String):void{    
     var quizName:String = evt; 
     if (quizName != null){ 
      var quizLdr:Loader = new Loader(); 
      var quizURL:String = quizName; 
      var quizURLReq:URLRequest = new URLRequest(quizURL); 
      quizLdr.load(quizURLReq); 
      quizLdr.contentLoaderInfo.addEventListener( Event.INIT , loaded)        
      quizLdr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, displayQuizLoaderProgress);  
      function loaded(event:Event):void { 
       var targetLoader:Loader = Loader(event.target.loader); 
       quizWindow.assetLoader.addChild(targetLoader);      
      }
     }
    }


    Everything loads fine, but at the level of quizWindow.assetLoader.addChild (targetLoader), I want to send a message/fill in an area of dynamic text on the main stage. I've been 'parenting' my brain and I'm not sure of how to communicate with that level.

    can anyone show me the correct path or the method based on the above, or have a suggestion?


    See you soon,.
    ~ Chipleh

    You make me feel nostalgic...

  • A3.0 dynamic loading .swf file learn slower and slower after two or three lines.

    IAM 3 SWFs for loop running.

    Problem is after that the compilation of the flash swf file file is getting more slower after two or three loops and stop with content finally.

    I don't know why it's happening that my guess is "because memory increases resulting in a flash file to slower"

    Please can someone help me on this...

    Hi This is the code below I got from the AS3.0 tutorial.

    {com package
    import flash.display.Sprite;
    import flash.display.Loader;
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.display.Graphics;
    import flash.events.Event;
    import flash.display.StageScaleMode;
    import flash.utils. *;
    Import fl.transitions.Tween;
    Fl.transitions.easing import. *;

    SerializableAttribute public class MyMovie extends Sprite {}
    declare variables...
    private var myXml:XML;
    private var myXMLURL:URLRequest;
    private var myLoader:URLLoader;
    private var imageList:XMLList;
    private var loader: Loader;
    private var number: number = 0;
    private var currentImage:Loader;
    private var interval: uint = 0;

    definition cunstructor...
    public void MyMovie() {}
    Super();
    var g:Graphics = this.graphics;
    g.Clear ();
    g.beginFill (0 x 000000, 1);
    g.drawRect (0, 0, 768, 1360);
    g.endFill ();

    }
    public void LoadXml(xmlPath:String_=_null):void {}
    var XML_URL:String;
    If (xmlPath == null) {}
    XML_URL = "data.xml".
    } else {}
    XML_URL = xmlPath;
    }
    myXMLURL = new URLRequest (XML_URL);
    myLoader = new URLLoader (myXMLURL);
    myLoader.addEventListener ("complete", xmlLoaded);
    }
    private void xmlLoaded(event:Event):void {}
    myXml = new XML();
    myXml = XML (myLoader.data);
    imageList = new XMLList();
    imageList = myXml.children ();
    loadImage();
    trace (ImageList [No.]. Child ("path"));
    }
    private void loadImage (): void {}
    clearInterval (interval);
    var imagePath:String is imageList [No.] .child ("path");.
    var imageRequest:URLRequest = new URLRequest (imagePath);
    loader = new Loader();
    loader.contentLoaderInfo.addEventListener (Event.COMPLETE, completeHandler);
    Loader.Load (feeder);
    currentImage = loader;
    addChild (loader);
    }
    private void completeHandler(evt:Event):void {}
    clearInterval (interval);
    If (currentImage! = null) {}
    removeChild (currentImage);
    }
    currentImage = loader;
    currentImage.x = (768/2)-(currentImage.width/2);
    currentImage.y = (1360/2)-(currentImage.height/2);
    var myTween:Tween = new Tween (Regular.easeOut, 0, 1, 0.5, currentImage, "alpha", true);
    var myTween1:Tween = new Tween (currentImage, "x", Strong.easeOut, 0, 0, 1, true);
    var myTween:Tween = new Tween (currentImage, "x", Strong.easeOut, 0, 768, 1, true);
    myTween.addEventListener ("motionFinish", TweenFinishedHandler);
    }
    private void TweenFinishedHandler(evt:Event):void {}
    no = no < imageList.length () - 1? No + 1:0;
    range = setInterval (loadImage, 4000);
    }
    }
    }

    Publish the flash by targeting the flash player 10.1.

  • Dynamically loaded swf to communicate with the MovieClip on the stage

    I have a devil of a time here with a problem. I've got an xml document when it is clicked on a certain button on the stage, it loads its corresponding external swf into an empty movieclip on the stage. This empty clip is support for all external SWF.

    So what I'm trying to do, is when an external swf is loaded that has buttons on it, I need these buttons to communicate with the main timeline and delete an mc who is on the stage. I need the swf (s) currently loaded to be able to do. So whatever the currently loaded external swf is loaded, I need to talk to the main timeline. (I have external SWF files a certain need to do this) So I guess I have to somehow target the external swf currently loaded so he could talk to the main timeline.

    The code below in summary does not, but it gives no errors either. I don't pretend to know what I'm doing, and I did not find a solution to this particular problem. If someone could give me advice or direct me to a solution. I would be so happy.

    scenario focus

    var object: index = this;

    function loadComplete (e: Event) {}

    TweenMax.to (index.mcholder, 1, {alpha:. 5});

    Add the current module to the mcholder movieclip according to addChild

    index.mcholder.addChild (e.currentTarget.content);

    (e.currentTarget.content as MovieClip) .addEventListener ("eventTriggered", startListener);

    function startListener(e:Event):void {}

    var ext_swf:MovieClip;

    ext_swf = e.currentTarget.content as MovieClip;

    trace ("external swf");

    ext_swf. Button1.addEventListener (MouseEvent.CLICK, talktomainswf);

    function talktomainswf (): void {}

    TweenMax.to (index.mc_thatsonthestage, 1, {x: 1000});

    }

    }

    Now we have the first load we set to false firstLoad

    index.firstLoad = false;

    }

    function loadError (e: Event) {}

    trace ("Error");

    }

    }

    You can use the event to communicate with external SWF Dispatcher and a main timeline

    as follows:

    //in an external swf
    
    //Once loaded
    function onLoadComplete(event:Event):void
    {
         //dispatch an event in the form of a string
         dispatchEvent(new Event("Talk to Main Timeline"));
    }
    
    //On the Main timeline
    
    //listen for "Talk to Main Timeline"
    stage.addEventListener("Talk to Main Timeline", listenForCallsFromExternalFiles, true); 
    
    //if the event is heard, do this:
    function listenForCallsFromExternalFiles(e:Event):void
    {
         trace("I heard ya, now do stuff...");
    }
    

    That's the idea anyway, I use it all the time.

    hope that helps,

    ~ chipleh

  • put in pause/play dynamically loaded swf

    Hello world

    I have a movie called box.swf that I load into controller.swf.  I have two buttons on the scene called pause_btn and play_btn I want to use to control the timeline of box.swf.  I am at a loss on how to do it, but I don't know that it's simple.  Here is the code I have so far:

    var myLoader = new Loader();
    var myURL:URLRequest = new URLRequest ("box.swf");
    myLoader.load (myURL);
    addChild (myLoader);

    pause_btn.addEventListener (MouseEvent.CLICK, pauseMe);
    play_btn.addEventListener (MouseEvent.CLICK, regarderME);

    function pauseMe(evt:MouseEvent):void {}

    }
    function playMe(evt:MouseEvent):void {}

    }

    Any help would be appreciated!

    Thank you

    -Dave

    var mc:MovieClip;

    var myLoader = new Loader();
    var myURL:URLRequest = new URLRequest ("box.swf");

    myLoader.contentLoadInfo (Event.COMPLETE, loadCompleteF);
    myLoader.load (myURL);
    addChild (myLoader);

    function loadCompleteF(e:Event) {}

    MC = MovieClip (myLoader.Content);

    }

    pause_btn.addEventListener (MouseEvent.CLICK, pauseMe);
    play_btn.addEventListener (MouseEvent.CLICK, regarderME);

    function pauseMe(evt:MouseEvent):void {}
      MC. Stop();
    }
    function playMe(evt:MouseEvent):void {}

    MC. Play();

    }

    -Dave

  • raise the event click to a dynamically loaded swf

    I have a swf of converted from powerpoint, version is in flash 8, and I want to launch an event click on the swf to advance the slides, how do I do this?

    btn.onRelease = function () {/ / where btn is the button you click on}
    mc.onRelease ();  where mc is the load of target movieclip
    }

  • dynamically loading the sounds she draws to a .swf

    Is this possible in Actionscript 3 to have a bunch of sounds in the library of your .swf you can dynamically load? The sound.load() seems to be something external to the url. I would like to ask you a whole collections of sounds in the libarary a fund sovereign and then dynamically chosen one I want to play when running.

    :

  • Get the dynamically loaded movieclip content

    Hey,.

    After trying without success to get the totalframes to a .swf dynamically loaded in AS3, I regressed to AS2.

    Now, I can add the clip and get the totalframes of content, no problem.

    The problem is that I can't resize the content at all.
    I have no idea how to target the loaded content.

    Here is the code I use:

    var myXML:XML = new XML();
    var path:String;
    var mcl:MovieClipLoader = new MovieClipLoader();
    var mclm:MovieClipLoader = new MovieClipLoader();
    var mclL:Object = new Object();
    var frames:Number;
    var i:Number = 0;
    var mc:MovieClip = new MovieClip
    myXML.ignoreWhite=true;
    myXML.load("content.xml");
    
    holder_mc._alpha = 0;
    
    myXML.onLoad = function(xmlLoaded){
    menu();
    load();
    }
    
    
    
    mclL.onLoadComplete = function() {
              frames = (MovieClip(holder_mc)._totalframes);
              if (frames == 1) {
                   image();
              }
              else if (frames > 1) {
                   clip();
              }
         }
    
    load = function(){
         clearInterval(timer);
         path = myXML.firstChild.childNodes[i].childNodes[1].childNodes[0].nodeValue;
         mcl.loadClip(path, holder_mc);
         var tFiles:Number = myXML.firstChild.childNodes.length;
         if (i < tFiles){
              i++;
         }
         else if (i == (tFiles)){
              i=0;
              load();
         }
         mcl.addListener(mclL);     
    }
    
    image = function() {     
         seconds=1000;
         holder_mc._alpha = 100;
         timer = setInterval(load, seconds);
    }
    
    clip = function() {     
         holder_mc._alpha = 100;
         ftimer = setInterval(checkFrames, 100);
    }
    
    checkFrames = function() {
              frame = (MovieClip(holder_mc)._currentframe);
              if (frame==(frames-1)){
                   clearInterval(ftimer);
                   load();
              }
         }
         
    menu = function(){
         
         var tFiles:Number = myXML.firstChild.childNodes.length;
         for (me=0; me < tFiles; me++){
         path = myXML.firstChild.childNodes[i].childNodes[1].childNodes[0].nodeValue;
         i++;
         _root.attachMovie("circle", "circle"+me, me, {_x:(me*30), _y:330});
         mclm.loadClip(path, ("circle"+me));     
         }
         
    }
    

    I need to resize the content as well for the main holder_mc, as well as for menu items.

    Use onLoadInit():

    mclL.onLoadInit = function(target:MovieClip) {          frames = target._totalframes;          if (frames == 1) {               image();          }          else if (frames > 1) {               clip();          }// size target here     }
    
    
    
  • How can I dynamically load swc files using as3? (without relying on the Flash IDE).

    How can I dynamically load swc files using as3? (without relying on the Flash IDE).

    The SWF file can be used in the same way as the CFC, which means that you don't need to "visually show" anything when it is loaded. Your code can use the classes and assets incorporated into the SWF, just as a SWC file. So if someone just to load the SWF file to see what was in it that they see nothing. They could however access programmatically to what anyone on the inside just like you, if they went to that level. But it is not as easy as just racing as SWF to see what is inside.

    I hope that all packaging several separate sovereigns will allow you to load and unload only what you need to keep the RAM usage as low as possible with a minimum load SWF.

    If you are ready, please mark all useful/correct so we can filter without response. You're welcome and good luck!

  • Dynamically loaded fonts

    Hello world

    A simple question because I think I already know the answer, but would be happy if someone corrects me.

    I know how to incorporate and use a font with the Embed in AS3, similar to what uses Flex.

    My question is: if I dynamically created by code textfield and want to give him a police. Is there a way I can assign police dynamically, i.e. in teling the police will this textfield via XML?

    No doubt, I have to prepare the police to use in a specific folder. But imagine that you have several options of fonts in this folder. Can assign you one of them to this textfield with code, depending on what the XML?

    ... Or just load several fonts and choose one of them what the XML?

    Thank you

    leoserra wrote:

    My question is: if I dynamically created by code textfield and want to give him a police. Is it possible that I can assign dynamically, the police

    Yes

    say by teling what the police are going to this textfield via XML?

    There is more to do.  If you want to load only necessary fonts, you will need to incorporate fonts plus one in different SWF and load SWFs.

  • change a dynamically loaded MC

    I have a TargeMC that I load another .swf file in. is it possible to have a button inside the loaded .swf that modifies the SWF TargetMC.

    presence, it is loaded dynamically I don't know how referance it film loaded inside.

    It will work any reference to the main timeline of the loaded swf file.  for example, the timeline main 'that' works and a child movieclip, will work this ._parent.

    p.s., this assumes that you are using as2 and have posted in the wrong forum as as2 is the only context in which it wise to load a swf file into a target clip.  You can't do that with as3.

  • Scale and dynamic load

    I'm working on a mini project.

    Here was my original goal: "to produce a parent .swf which loads dynamically an image has a preloader for this external image, to show how much has loaded and finally and above all for this position, to be able to put this image when the size of the scene is changed"

    That's what I come up with so far:

    DYNAMIC LOADER

    var homeimageLoader:Loader = new Loader();

    var homeimage:URLRequest = new URLRequest ("image.jpg");

    homeimageLoader.load (homeimage);

    PRELOADER

    homeimageLoader.addEventListener (Event.ENTER_FRAME, homephotoLoading);

    function homephotoLoading(e:Event):void {}

    var total: Number = homeimageLoader.contentLoaderInfo.bytesTotal;

    var loaded: number = homeimageLoader.contentLoaderInfo.bytesLoaded;

    loadBar.scaleX = loading/total;

    if (total == load) {}

    addChild (homeimageLoader);

    homeimageLoader.x = 0;

    homeimageLoader.y = 0;

    SCALING OF THE IMAGE

    homeimageLoader.width = Math.round((stage.stageWidth/2)+(stage.stageWidth/3));

    homeimageLoader.height = Math.round((stage.stageHeight/2)+(stage.stageHeight/3));

    (homeimageLoader.scaleX < homeimageLoader.scaleY)? homeimageLoader.scaleY = homeimageLoader.scaleX: homeimageLoader.scaleX = homeimageLoader.scaleY;

    this.removeEventListener (Event.ENTER_FRAME, loading);

    }}

    It actually works very well...

    My problem is the scaling section.

    Because the image will load dynamically, it's pretty glitchy on a scale comparable to that of a picture that has been placed, for example, in the library or is placed on the floor.

    If anyone knows how I can change my code so far, and from scratch to produce the same leaders, so that the scale is smooth, I would really appreciate it!

    Thank you much, long in advance.

    use:

    DYNAMIC LOADER

    var homeimageLoader:Loader = new Loader();

    var homeimage:URLRequest = new URLRequest ("image.jpg");

    homeimageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,homephotoLoading);homeimageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,completeF);
    

    homeimageLoader.load (homeimage);

    PRELOADER

    function homephotoLoading(e:Event):void {}

    var total: Number = homeimageLoader.contentLoaderInfo.bytesTotal;

    var loaded: number = homeimageLoader.contentLoaderInfo.bytesLoaded;

    loadBar.scaleX = loading/total;

    If (total == load) {}

    Remove your preloader display

    addChild (homeimageLoader);

    homeimageLoader.x = 0;

    homeimageLoader.y = 0;

    }

    }

    SCALING OF THE IMAGE

    function completeF(e:Event):void {}

    homeimageLoader.width = Math.round((stage.stageWidth/2)+(stage.stageWidth/3));

    homeimageLoader.height = Math.round((stage.stageHeight/2)+(stage.stageHeight/3));

    (homeimageLoader.scaleX< homeimageloader.scaley="" )="" homeimageloader.scaley="homeimageLoader.scaleX" :="" homeimageloader.scalex="">

    }

  • prevent the loaded swf to loopback

    Hello world

    I am loading a swf file into a swf of controller, and thanks to the help I received on this forum, I am able to control the swf loaded with play and pause buttons.  I have another question, and this is how to prevent the loaded swf file looping.  I wish that the swf loaded to play its last picture and stop.  I have the following code and it works with an error.  I'm assuming that the error is coming because the service runs before the swf file is loaded.

    var myLoader = new Loader();
    var myURL:URLRequest = new URLRequest ("box.swf");
    myLoader.load (myURL);
    addChild (myLoader);

    pause_btn.addEventListener (MouseEvent.MOUSE_UP, onClickPause);
    play_btn.addEventListener (MouseEvent.MOUSE_UP, onClickPlay);

    function onClickPause(evt:MouseEvent):void {}
    MovieClip (myLoader.content) .stop ();
    }
    function onClickPlay(evt:MouseEvent):void {}
    MovieClip (myLoader.content) .play ();
    }

    the following works with a guy

    stage.addEventListener (Event.ENTER_FRAME, stopPlay);

    function stopPlay(e:Event):void {}
    If (MovieClip (myLoader.content) .currentFrame is {MovieClip (myLoader.content) .totalFrames)}
    MovieClip (myLoader.content) .stop ();
    trace ("End");
    }
    }

    The error reads as follows:

    TypeError: Error #1009: cannot access a property or method of a null object reference.
    at controller_fla::MainTimeline/stopPlay()
    TypeError: Error #1009: cannot access a property or method of a null object reference.
    at controller_fla::MainTimeline/stopPlay()

    Once again, any help would be greatly appreciated.

    Thank you!

    -Dave

    Use COMPLETE earphone that kGlad offered to wait to assign the ENTER_FRAME listener.

    var myLoader = new Loader();
    var myURL:URLRequest = new URLRequest ("box.swf");
    myLoader.load (myURL);

    myLoader.contentLoadInfo (Event.COMPLETE, loadCompleteF);

    function loadCompleteF(e:Event) {}

    stage.addEventListener (Event.ENTER_FRAME, stopPlay);

    }

    addChild (myLoader);

    pause_btn.addEventListener (MouseEvent.MOUSE_UP, onClickPause);
    play_btn.addEventListener (MouseEvent.MOUSE_UP, onClickPlay);

    function onClickPause(evt:MouseEvent):void {}
    MovieClip (myLoader.content) .stop ();
    }

    function onClickPlay(evt:MouseEvent):void {}
    MovieClip (myLoader.content) .play ();
    }

    function stopPlay(e:Event):void {}
    If (MovieClip (myLoader.content) .currentFrame is {MovieClip (myLoader.content) .totalFrames)}
    MovieClip (myLoader.content) .stop ();
    trace ("End");
    }
    }

    You can also use a stop(); command at the end of the timeline of the swf file that is loaded instead.

  • Duplicate a loaded SWF, no Actionscript?

    Then... by writing a Flash based game, I have the main SWF file and its associated classes at one time, loading a single SWF file that represents a sprite in the game. I want to use this sprite repeatedly in the game, then I've duplicate after loading and expect that it would work. Unfortunately, after duplicate the loaded SWF file, it seems to be ignoring the actionscript timeline such as gotoAndPlay() calls.

    Here is the configuration:

    The loaded SWF that contains the animated sprite has a single layer on the timeline and basically has a number of labeled images dedicated to each animation - that is to say, there is a "walk_east" image, which traverses a character walking East, and at the end of this animation, has a command of gotoAndPlay ("walk_east") on one of the frames that it returns at the beginning of this particular animation to repeat the whole ordeal. The image after this one could be "walk_west" and contain West animation walk, etc. The very first frame of the SWF has a simple "stop()" call in there, so nothing no anime until the main SWF file tells the SWF loaded to do it (via a gotoAndPlay() call). This SWF has a base known as "Actor" document class

    The main SWF load this SWF using a typical loader. Then, to duplicate the loaded SWF file, I opted to do something like that, where the "clip" is a reference to the loaded SWF loader:

    var swfClass: Class = clip.contentLoaderInfo.applicationDomain.getDefinition("Actor");
    var clone = new swfClass();

    I can create any duplicates, I want, no problem. However, as soon as I start playing a (i.e., "clone.gotoAndPlay ("walk_east"), he comes will travel the entire chronology of the loaded sprite / duplicated SWF - ignoring the various actionscript code on the bases that SHOULD it be repetition of the cycle of specific animation I want... and despite the fact that when played, the same SWF does not display this behavior.")

    As well as her duplicate movieclip causes duplicated SWF to lose his actionscript on the timeline?

    Someone at - it ideas? This is expected behavior? I can't imagine this is how it should be - I want to only load the SWF sprite just once, to save bandwidth and then reproduce them as many times I want to in the game. This had to be done before... I can't imagine the developers simply reload the SWF even several times if necessary the same SWF to be used several times - that is to say, several enemies of the same type.

    Or I just do it more difficult that there must be? Help, please!

    RE: "the reason why I use the charger and not simply add the SWF file at the library of the FLA is because the sprites to load are dynamic based on a number of variables and a configuration XML file-driven." The only app knows which fund sovereigns to load at runtime based on things like what level the player entered... »

    OK, so? You shouldn't need a charger for the sprites just because they are built dynamically.
    You can keep all the config in the XML files, but keep the logic in separate classes that are all referenced in the same FLA file. You say "...". sprites to load are dynamic based on a number of variables... "OK, you can not create these sprites for parts that are in your library dynamically by using the operator"new "? Try a different approach, do not get stuck on the technical problem which is most likely a bug in the VM... If it doesn't, just leave it. Try a different approach.

  • Using a preloader on a dynamically loaded movie

    I am dynamically loading a swf file called picture1.swf in a white mc called photo with the following code:

    loadMovie ("picture1.swf", "image");

    In picture1.swf, I use the following script to my preloader:

    totalBytes = Math.round (getBytesTotal () / 1024);
    loadedBytes = Math.round (getBytesLoaded () / 1024);
    percentDone = Math.round ((loadedBytes / totalBytes) * 100);
    If (_root._framesloaded > = _root._totalframes)
    {
    gotoAndPlay ("start");
    }

    When I test the preloader in picture1.swf, it works fine. However when picture1.swf is loaded dynamically into my main swf preloader stops working. Any ideas?

    done _root refers to a different timeframe when picture1.swf is tested without loading and loading in another swf. to remedy this, you can add the following to picture1.swf:

Maybe you are looking for