TotalFrames of dynamically loaded swf

I've been trying for 2 days now to find the total number of frames of a dynamically loaded .swf.
Here's an example code:
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 truly puzzled.
Any help would be greatly appreciated.

I think this might be complicated by loading an AS2 movie into an AS3 document.
The error message is telling you that there is no totalFrames property and in fact AS2 movies would have a _totalframes property.
So you could try that.
Also I'm not sure if event.currentTarget.content returns a MovieClip or a DisplayObject. If it is a DisplayObject (which is most likely) then it too wouldn't have  totalFrames property. So you might need to cast it as a MovieClip. Something like this:
MovieClip(event.currentTarget.content).totalFrames
And or it could be some combination of these two above issues? I don't know really, I'm just grasping at straws. But I don't see any way to know when a clip is done playing other than to compare its currentFrame to totalFrames.

Similar Messages

  • Can't target main stage from dynamically loaded swf...

    A part of the Flash app. I'm working on right now does the following -
    Main stage loads 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 externally loaded swf loads another external swf into 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 from the quizWindow.assetLoader.addChild(targetLoader) level, I want to send a message/fill in a dynamic text box on the Main Stage. I have been "parenting" my brains out and I'm not sure how to communicate with that level.
    can anyone show me the proper path or method based off the above, or have a suggestion?
    Cheers,
    ~Chipleh

    Andrei1,
    Thanks again for your help. I was finally able to get the solution you posted below to work for me.
    Much appreciation,
    ~Chipleh
    "In your loaded movie write:
    function traceMyself(e:MouseEvent):void{
         dispatchEvent(new Event("I_WANT_TEXT"));
    function writeText(text:String):void {
         xmlFileName1.text = text;
    In the top movie that loads external swfs something like that:
    loadedSwf.addEventListener("I_WANT_TEXT", onTextRequest, true);
    function onTextRequest(e:Event):void {
         Object(e.target).writeText(tQuizXmlFile1.theQuizXmlFile.text);
    This way these two entities are independent and, most importantly, don't care who is the parent or grandparent."

  • Dynamically loaded .swf missing it's mark

    I have had a website that has been up and successfully running for about a year now. Admittedly, it's a little buggy here and there, however - I have not had too many issues with it to date.
    Recently, however, I updated the main / root .swf slightly - just changed some copy, and added a slide or two throughout. When visiting the site, this main .swf dynamically loads any content .swfs required - the html, and these .swfs were not touched.
    Upon uploading the new main .swf only - everything works fun, until it loads one of the content .swfs - this always loads in the top left of the browser, rather than the center top of the browser.
    Does anyone have an idea what could be causing this - it just seems odd as I touched no code at all.
    Thanks in advance!

    Nope - the main .fla / .swf is in the correct position. The html calls it to be top / centered.
    When "that" file dynamically loads an additional .swf - they are all going up and left - off center from the site entirely. Seems odd, I've checked the placement as3 - everything seems to be in order. Any ideas? Could this just be a small bug somewhere changing something enough to do this?

  • Dynamically loaded swf to communicate with MovieClip on the stage

    I have a heck of time here with an issue. I have an xml document that when a certain button on the stage is clicked it loads it's corresponding external swf into an empty movieclip on the stage. This empty movie clip is a holder for all external swfs.
    So what I'm trying to do is when an external swf is loaded that has buttons on it, I need those buttons to communicate with the main timeline and remove a mc that is on the Stage. I need the currently loaded swf(s) to be able to do this. So whatever the currently loaded external swf is that's loaded, I need it to talk to the main timeline. (I have quite a few external swfs that need to do this) So I imagine I need to somehow target the currently loaded external swf to get it to talk to the main timeline.
    The code below in summary doesn't work but it doesn't give errors either. I don't pretend to know what I'm doing and I haven't been successful in searching for a solution to this particular issue. If someone could give me guidance or direct me to a solution. I'd so much appreciate it.
    // main timeline object
    var index:Object=this;
    function loadComplete (e:Event) {
            TweenMax.to(index.mcholder,1, {alpha: .5});
    // add the current module to the mcholder movieclip by using 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 firstLoad to false
            index.firstLoad = false;
        function loadError (e:Event) {
            trace("error");

    You can use the event dispatcher to communicate between external swfs and a main timeline,
    like so:
    //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 basic idea anyways, I use it all the time.
    hope that helps,
    ~chipleh

  • IE Active Content + Dynamically Loaded Swfs...any help?

    Hi,
    I've recently become aware of the whole IE active content
    problem and I followed the tutorial at
    http://activecontent.blogspot.com/
    to adjust my html files accordingly. However I have one site
    located at:
    http://www.mrdodson.com/SavannahSucks/SavannahSucks.html
    which loads several swfs dynamically. However in IE none of the
    swfs will start loading until you click on one of the markers
    which, unfortunately locks the user into a zoomed in view with no
    way of exiting until the external file finishes loading. Can anyone
    provide any suggestion on how I can get around this? Should I load
    the clips in a different fashion or can it be resolved by adding
    something to the HTML? I'm a recent grad trying to finish up my
    portfolio and this is really holding me back. Many thanks for any
    suggestions.
    -Rob

    please if anyone knows anything i would really appreciate it.
    i can't send my portfolio out until i fix this one thing so pretty
    much my life is on hold until i can resolve this.

  • How to name a dynamically loaded swf

    heres my prblem i have a set of button buried inside a mc
    when they are clicked i need them to call upon a external mc. ive
    tried some different code but nothing works.
    _level0.contholder_mc.contractor_mc.gotoAndPlay() works but
    only one time. if i click on another button and then go back to the
    external mc i gives it another instance name. how do i stop it from
    giving dynamic instances names.
    thanks for the help

    General Flash procedure is to always code you movies separate
    from one another. If the movie is external, all its methods,
    actions and symbols should be embedded inside that movie.
    Basically, get the buttons working in the smaller movie first. Once
    they are doing what you want them to there, move over to the main
    movie and test playback from there. Often times, there will be
    minor changes necessary to an object or button to insure proper
    playback in the main movie but they are more manageable if they are
    resident to the loaded clip. So start by getting your buttons
    working within the loaded movie's fla file then move over. That
    should help you tremendously.

  • Get content of dynamically loaded movieclip

    Hey,
    After trying to no avail to get the totalframes of a dynamically loaded .swf in AS3 I've regressed to AS2.
    Now I can add the clip and get the totalframes of the content, no problem.
    THe problem is I cannot resize the content at all.
    I have no idea how to target the loaded content.
    Here's the code I'm using:
    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 both for the main holder_mc as well as for the menu elements.

    Thank you for the response.
    Unfortunately that didn't work.
    Even if I try to trace either target._width or holder_mc._width where you suggested I get 0 values.
    The only values I did manage to get was when I put the trace in the load() function but they were out of sync with the images being loaded.
    I even tried it on a simpler model:
    var myXML:XML = new XML();
    var path:String;
    var mcl:MovieClipLoader = new MovieClipLoader();
    var mclL:Object = new Object();
    var frames:Number;
    var i:Number = 0;
    var tFiles:Number;
    myXML.ignoreWhite=true;
    myXML.load("content.xml");
    myXML.onLoad = function(xmlLoaded){
    path = myXML.firstChild.childNodes[i].childNodes[1].childNodes[0].nodeValue;
    tFiles = myXML.firstChild.childNodes.length;
    loader();
    loader = function() {
         mcl.loadClip(path, holder_mc);
         mcl.addListener(mclL);
    mclL.onLoadComplete = function(target:MovieClip) {
         trace(target._width);
         trace(holder_mc._height);
    ..and I still get 0 values.

  • Load swf into mc frame by frame

    Hi, I have a movieclip to dynamically load swf's. Some of my
    swf's are slideshows and contain jpgs that are quite large.
    Therefore I do not want to wait till the end of a complete load to
    show the swf. Say, if i want to show picture 3 (at frame 3), i'd
    like to show it as soon as the frame is loaded. However, I also
    need to rezie the swf to fit my mc's fixed size. Resize only works
    after all bytes of the swf are loaded I believe.
    How do I solve this problem?
    Ted

    Can you be more specific? I read at the MCLoader apis, but
    still have no clue how to solve this problem.

  • Dynamic Text in Externally Loaded swf

    hi. i have a dynamic text field in an externally loaded swf. Its a digital clock so i want the numbers to update in the dynamic text field.
    this is not my exact code but it is very similar. i show below that i add the loader.swf, and once its loading is complete, i can work on its movieclips and add event listeners to its buttons, etc. but i cannot change the dynamic text field (its "classic text" set to "dynamic text"). after running this, the text just stays empty as it is in the external swf).
    here is the sample code:
    var loader:Loader = new Loader();
    loader.load(new URLRequest("loader.swf"));
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaded);
    function loaded(event:Event):void{
         addChild(loader);
         var loader_mc:MovieClip = (loader.content as MovieClip)
         loader_mc.myMovieClip.gotoAndStop(2);//***this works
         loader_mc.myButton_btn.addEventListener(MouseEvent.CLICK, clickMe);//***this works
         loader_mc.myText_txt.text = "12";//***this doesn't work******
    please help. thanks!

    Did you embed the font in the textfield--it needs to be done in the loaded swf when you create it? One other thing to check is that the color for the textfield is not the same as the background it sits on.

  • Compiling a CSS into SWF without merged SDK and dynamically loading

    I have a flex application that is built with the SDK merged in (for my own good reasons). This application dynamically loads a style SWF that was built without the SDK merged. Unfortunately, it seems that the loaded SWF fails to resolve its references with the SDK and gives me a 1014 run-time error.
    If I merge the SDK into the CSS SWF then it works. If I set both my application and the CSS SWF to use the SDK as an RSL then it works. In short the matrix is:
    CSS SWF, SDK merged?
    Application, SDK merged?
    Works?
    Yes
    Yes
    Yes
    Yes
    No
    Yes
    No
    Yes
    No
    No
    No
    Yes
    I do not want a big CSS SWF to dynamically load with all the SDK in it when I already have the SDK loaded with my application. Any help much appreciated.

    Hi,
    In you rsl project properties, go to Flex Library Build Path and go to library path tab. Here you can edit your imported library. There's no need in RSL to import the libraries merge into code but external(even the Adobe libraries should be loaded as external) cause you load it already from your application project (as rsl or merge into code).
    Bye!

  • How to access dynamic movie clips in a loaded swf

    Hello,
    I have a main movie file that loads a swf through loadclip.
    There are several dynamic movie clips in the library of the
    loaded swf (all set to export in first frame).
    I'm trying to create a popup window (using the Window
    component) by using code in the main movie to popup content that is
    in a dynamic movie clip within the swf loaded by loadclip.
    So far, I can create the popup without any problem as long as
    the contentPath refers to a linkage identifier of a library item in
    the main movie, but it won't work for a library item in the loaded
    movie. Is there a way to make this work? Is there a special way to
    reference library items in loaded movies?
    Here's my code to create the window:
    myWin = mx.managers.PopUpManager.createPopUp(this,
    mx.containers.Window, true, {title:mytitle, contentPath:myref,
    closeButton:true});
    where myref is a string containing the linkage identifier for
    the library item within the loaded swf.
    Thanks in advance for any assistance,
    Julia

    I have found out that I can access a dynamic mc from the
    loaded library (using attachMovie), but cannot use that same
    dynamic mc as the contentpath for a popup window.
    Any ideas why?

  • How do I dynamically load a SWF that was compiled from an Fla with a linked external class file

    I am dynamically loading external SWFs in a Main Fla in response to clicks on a menu.
    The loading code is standard and works fine for all of the SWFs except one. When I try to load it I get the following error:
    Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.
    I am certain that the URL to the problem SWF is correct. The SWF itself doesn't load any other SWFs or images.
    The problem SWF is linked to an external class file and compiled with it.
    i.e. in the properties panel of the main timeline of the problem SWF's Fla I have entered the path to the external class.
    1. there is no problem compiling this SWF with the class (it works fine by itself)
    2. if I remove the external class from the properties panel and don't use it the resulting SWF imports without a problem into the Main Fla mentioned before
    So the problem seems to be the fact that the external class is linked in the properties panel. Is this a path problem?
    Would appreciate any suggestions,
    Thanks!

    despite what you say, that loaded swf most likely is loading something and that's the cause of the error.
    you could test that by putting the main swf's embedding html file in the same directory with problematic swf.  if the problem is as explained above, you'll have no problem when the main html is in the same directory with the loaded swf.

  • Dynamic load of images in to established Timeline effect

    Is it possible to dynamicly load images in to an already
    established timeline effect?
    Steps I've done.
    Stuffed a JPG in to the library by draging and dropping it in
    to the SWFs library.
    Dropped the JPG on to the main stage
    Right clicked the image then going down to Timeline effects
    and choosing an effect.
    Completing any changes in effects dialogue box and then
    clicking OK.
    Play the movie, and pat myself on the back that it worked.
    So then, how can I get Actionscript to load an image
    dynamically in to that same Timeline effect and have it do the
    effect to that instead of the one found in the library?
    I'm using Flash MX Professional 2004.

    hii
    Can u mention the error message getting while the status become RED??
    As what I understand, this may be the issue of invalid characteristics inPSA Data Records or also there may be records that does not support the lower case or upper case data.
    So just check the data in PSA Level
    Thanks
    Neha

  • Loading swf into SWFLoader before it is added to a container

    I want to dynamically load a SWF file, before a particular view is created in a Flex 4.5 mobile app. Is it possible to load a SWF file into a SWFLoader before the SWFLoader is added to a container? I tried this but it didn't work.
    I tried doing this using the AS3 Loader class and movieclips, but when I compile for iOS this method does not work for me. Is there a way to do what I want?

    Hello,
    Firstly, why do you want to do this?
    Secondly, you cannot run runtime-loaded SWF files on iOS devices.
    By that I mean you can probably only use static SWF files like assets, but code inside them will not work.
    If you still want to load it, try inside the initialize event handler.

  • Using Loader.loadBytes - specify SecurityDomain for loaded swf?

    Hi i have a problem.
    I use Loader.loadBytes to dynamically load a swf into my app (i use this method to load modules into the app). My trouble is that when I want to use ExternalInterface.addCallback to allow js calls on my app. When those functions get called a SecurityError gets thrown because I'm not in the right Security Domain. Trying to set the SecurityDomain of the loaded content via LoaderContext results in another error telling me that SecurityDomain can't be other than null. Is there a way to actually get my modules accessible from JS?
    *Note:
    I have set in my main ap (the one that instantiates the module controller that loads the modules) the following:
    Security.allowDomain("*");
    Security.allowInsecureDomain("*");
    the loading code:
    var _contextLoader : LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
    _contextLoader.allowCodeImport = true;
    _moduleLoader.loadBytes(moduleBytes, _contextLoader);
    The error:
    SecurityDomain 'null' tried to access incompatible context ...

    The loaded swf is at loader.content, but you can only access
    it once the loading has completed and the loader has been added to
    the display list. For example, CODE 1 will not work, but CODE 2
    will.
    //CODE 1
    var myLoader:Loader = new Loader();
    addChild(myLoader);
    myLoader.load(new URLRequest("movie.swf"));
    var loadedSwf:MovieClip = MovieClip(loader.content); //ERROR
    //CODE 2
    var myLoader:Loader = new Loader();
    addChild(myLoader);
    myLoader.load(new URLRequest("movie.swf"));
    myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,
    loadCompleted);
    var loadedSwf:MovieClip;
    function loadCompleted(ev:Event):void {
    loadedSwf = MovieClip(loader.content);
    trace(loadedSwf);
    PS. I recommend using the Tweener library for tweening in
    ActionScript. It is much better than the Adobe functions and there
    is a tutorial at:
    http://gotoandlearn.com/player.php?id=45

Maybe you are looking for

  • Safari 4.0.1 keeps on crashing

    howdy yep safari 4.0.1 keeps crashing but after a couple of reloads it remains stable here is one of the many reports: Process: Safari [197] Path: /Applications/Safari.app/Contents/MacOS/Safari Identifier: com.apple.Safari Version: 4.0.1 (5530.18) Bu

  • Message transfer from Oracle to SAP R/3

    Hi all, I have scenario in which i have to transfer data from ORACLE table to a SAP R/3 IDoc. Can anyone suggest a weblog/link illustrating this scenario. Thanks in advance Regards Neetu

  • XML Document Format for JDBC Receiver(Between operation)

    Hello everybody, is there a way to use a BETWEEN operation for the key in a SELECT XML document format????????, I need to filter in the Where for different Statements in teh strcuture as BETWEEN, thanks in advance. Regards, Julio

  • Convert_otf in unicode system

    Hello, we have switched a CRM4.0 system from non-unicode to unicode. In this context we became two problems with the result of the function module 'CONVERT_OTF'. We call the function Module following:   call function 'CONVERT_OTF'    exporting      f

  • CS6 keeps dropping audio on my Mac

    Using a Canon AVCHD camera, every single clip I ingest results in dropped audio. It doesn't matter if I close the program and reopen it, it is always gone. Is there any fix for this? Thanks.