Acessing loaded swf movieclip sctructure on as3

Hi, I'm using external swf files to add skins to an
application. Currenlty,I'm loading isolated elements successfully
by the use of the Loader class. However, now I want to load a more
complex skin structure that will have some movieclips already
placed on the loaded swf stage. The question is: when I load an swf
that athe edit time, I placed some elements on stage and gave them
instance names, how can I access this external swf movieclip
structure? It's something like this:
1. First, I create the external file by placing some elements
on its stage, naming these elements instances, like "console_bar"
and "console_button".
2. Then, I load this swf using the Loader class (into a
loader called "playerConsole", for example) and, whe it finishes
loading I try to access the elements placed on stage:
this.addChild(playerConsole);
playerConsole.console_bar.x = 0; // won't work - how can I
access this instance?

This code generates an error when I try to compile:
1119: Access of possibly undefined property console_bar
through a reference with static type
flash.display:DisplayObject.

Similar Messages

  • Last and greatest: conditional statements for click referring to loaded swf

    Hey forum,
    I am so close to being done with this site update it is exciting! I will be sure to throw it up here for you to see, since without this forum I would have been hurting!
    The last big hurdle I have, is the following, and I hope someone can just throw me a bit of guidance on this.
    I am looking for a way to write a function, that on click of my "next" button in the main timeline, will refer to my loaded swf MovieClip(imageLoader.content) telling it to go to the next frame label, so really a compound if/then situation – just referring to the loaded file throws me.
    So, my next button is "pNext," and what I am looking for is something along the lines of:
    if (loaded movie) is on frames 12-144, then go here (on click),
    if (loaded movie) is on frames 144-155, then go here (on click)
    etc. and so forth.
    Thanks so much! Below is my code that works on one next click, so you can see the instances etc.
    b
    pNext.addEventListener (MouseEvent.CLICK, nextClick);
    function nextClick (e:MouseEvent):void{
        MovieClip(imageLoader.content).gotoAndPlay ("aboutS1");

    If I'm reading your request right, what you can try is to create an array of the frame labels in the order they appear and use the currentLabel property to determine where you are and indicate where to go...
    var labels:Array = new Array("one","two","three","four","five"...etc...);
    pNext.addEventListener (MouseEvent.CLICK, nextClick);
    function nextClick (e:MouseEvent):void{
        var mc:MovieClip = MovieClip(imageLoader.content);
        var nextLabel:String = labels[labels.indexOf(String(mc.currentLabel))+1];
        mc.gotoAndPlay (nextLabel);

  • Load SWF into empty movieClip?

    Hello,
    Could anyone please point me in the right direction to find
    out how to load an external SWF into an already existing movieClip
    instance that is already placed on the stage? This is the way I've
    always worked in AS2, but I can't find how to do it in AS3. Can
    anyone point me to an example where URLRequest works with a
    specified movieClip instance?
    Thank you!

    I understand why you might think I was ignoring your advice,
    but this isn't the case. You're expertise is much valued and
    respected.
    My purpose for continuing to experiment with loading into a
    movieClip was an attempt to find an easy way to layer the SWF
    behind other elements, but as you know, although it works for this
    purpose, it doesn't allow control of the loaded SWF from the main
    timeline. For others struggling to learn as I am, here's a link
    where I found the answer to my question above:
    http://www.hostingforum.ca/776586-as3-controlling-loaded-swf.html
    The transition to AS3 is not as easy for some as for others,
    and there are new concepts to understand.
    Don't know what "nvm" means... curious, but might be better
    off not knowing ;) Thanks again for all the help you offer to all
    of us who are struggling.

  • Can't Access MovieClips and Functions in Loaded SWF

    Hi everybody,
    I'm trying to simply access anything inside this loaded SWF and all I get is 'null'.
    I have code in the parent SWF that needs to tell the child SWF movieclip what to do but nothing works. This was a piee of cake in AS2 and I can't seem to get anything to crossover in AS3.
    Here's my code:
    import com.greensock.TweenMax;
    import flash.display.MovieClip;
    var myLoader:Loader = new Loader();
    var url:URLRequest = new URLRequest("SWCS_S3_500x250_exp_panel_2.swf"); // in this case both SWFs are in the same folder
    myLoader.load(url);  // load the SWF file
    panel2.addChild(myLoader);   // add that instance to the display list, adding it to the Stage at 0,0
    panel2 = myLoader.content as MovieClip;
    photo_about.alpha = 0;
    photo_downloads.alpha = 0;
    //panel2.content_about.alpha = 0;
    //panel2.content_downloads.alpha = 0;
    function closeSection():void
              panel2.controlsMC.forcePause();
              TweenMax.to(photo_about, .5, {alpha:0});
              TweenMax.to(photo_downloads, .5, {alpha:0});
              TweenMax.to(photo_home, .5, {alpha:0});
              TweenMax.to(panel2.content_about, .5, {alpha:0});
              TweenMax.to(panel2.content_downloads, .5, {alpha:0});
              TweenMax.to(panel2.controlsMC, .5, {autoAlpha:0});
              TweenMax.to(panel2.content_home, .5, {alpha:0});
    panel2 traces null and all the clips loaded within pull up undefined property errors.
    Can somebody please tell me what I'm doing wrong? I'd be stoked to know what I'm missing and feel like this should be a piece of cake.
    Thanks for any help!

    You are not adding the content to the stage at 0,0, you are adding it to panel2 at 0,0.  THen you take panel2 and assign it to be something that likely doesn't exist by the time you assign it.  You need to wait until the loader completes loading before you attempt to do anything with its content, otherwise it has no content (null).  Similarly, you cannot control anything in the loaded swf until it has finished loading.  So assign an event listener to the contentLoaderInfo property of the Loader to determine when loading is complete, and have the event handler function deal with starting the interaction with it.
    var myLoader:Loader = new Loader();
    var url:URLRequest = new URLRequest("SWCS_S3_500x250_exp_panel_2.swf");
    myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, processLoadedSWF);
    myLoader.load(url);
    function processLoadedSWF(evt:Event):void {
        // deal with the loaded swf here
        // but you don't want to be assigning it to the panel2 object that contains the loader
    As far as controlling anything inside the swf you load, is it an AS1/2 or an AS3 swf?

  • AS3: embeded audio in loaded SWF

    i'm trying to update an AS2 swf/audio player to AS3 and
    running into trouble. i'm exporting an embedded mp3 as a Sound
    object, then loading that SWF into a player engine that is
    skinnable... is there anyway to treat the SWF as a streaming sound?
    Having to wait until the Loader INIT event fires isn't really gonna
    work...
    i had attempted encoding the audio as FLV, which was working
    great with FLVPlayback - until you do anything to the browser
    window (like resizing) which causes erratic sound playback. not
    cool...
    thanks!!!!!

    to stop all movieclips use:
    var imageReq:URLRequest = new URLRequest("square.swf");
    var imageLoader:Loader = new Loader();
    imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadHandler);
    imageLoader.load(imageReq);
    function loadHandler (event:Event)
        var myClip:MovieClip = event.currentTarget.loader.content
        addChild(myClip);
        stopAllF(myClip);
    function stopAllF(mc:MovieClip):void{
    mc.stop();
    for(var i:int=0;i<mc.numChildren;i++){
    if(mc.getChildAt(i) is MovieClip){
    MovieClip(mc.getChildAt(i));

  • Load swf into movieclip // play pause buttons

    I am going out of my mind trying to get this to work. I can do it in AS2 without a hitch - but not AS3.
    I just need to load an external swf file into an empty movieclip. Then I have 2 buttons play and pause that need to be on the top layer of the new movie and they need to play and pause the loaded swf file.
    I have tried a number of things and nothing is working. Please help.
    Thank you in advance.
    Shawna

    you can use:
    var ldr:Loader=new Loader();
    addChild(ldr);
    ldr.load(new URLRequest("yourswfthatyouwanttoload.swf"));
    addChild(yourplaybtn);
    addChild(yourpausebtn);
    yourplaybtn.addEventListener(MouseEvent.CLICK,playF);
    yourpausebtn.addEventListener(MouseEvent.CLICK.pauseF);
    function playF(e:Event){
    MovieClip(ldr.content).play();
    function pauseF(e:Event){
    MovieClip(ldr.content).stop();

  • Loading external swf movie to website - AS3

    Hi, once again I am stuck because of AS3, it was sooo easy to load external swf in as2.
    I have a very simple website where HOME does not want the external swf to show but all other pages should have the swf running as a main banner on left hand side.
    My site is built with labels - if you click on any other page except "HOME" the swf should load and stay loaded while navigating on the "following pages",  and when you navigate back to "HOME"the banner should unload.
    Should be easy right? I browse the Internet for 2 days and find millions of code, but nothing that works.
    Do I need a Loader placed on the following pages or an empty movie clip (with an instance name?)
    I tried the below, but it only loads if you click on button "l'ambition" first, since this is the frame where the code is placed, and it is of course not unloading on "HOME. I have a keyframe on label "ambition" where I have a Loader box and the code (both running all over the following pages.
    var request:URLRequest = new URLRequest("main_movie_241x700.swf");
    var loader:Loader = new Loader()
    loader.load(request);
    addChild(loader);
    Do I need an EventListener?
    Anyone...? Please hand me complete code since that will help me a lot. You can see the test site here: http://www.gattadesign.fr/CSD/index.html
    Thanks in avance!
    Anna Gatta

    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);

  • How to Load an external swf using loadmovie in AS3

    I need to create a button with script, on rollover load an external swf into movieclip in AS3.  This was able to create this in AS2, but I need to create this in AS3

    Thanks again Ned.
    Kenneth Russell
    graphic artist, Sr.
    Lockheed Martin - MS2
    2323 Eastern Blvd., Baltimore, MD 21220
    Phone 410.682.0554    Fax 410.682.0543
    From: Ned Murphy <[email protected]>
    Reply-To: [email protected]
    Date: Thu, 23 Jul 2009 19:08:25 -0600
    To: kenneth russell <[email protected]>
    Subject: How to Load an external swf using loadmovie in AS3
    In AS3 you use the Loader class to load external swf's and image files.  You
    should be able to find examples both in the Flash help files and these forums
    if you search.  If you aren't aware of how to code buttons in AS3, that can be
    found as well.  In AS3, just about any kind of interction involves the use of
    event listeners in combination event handler functions... in the case of a
    button rollover an example would be...
    btnName.addEventListener(MouseEvent.ROLL_OVER, overHandler);
    function overHandler(evt:MouseEvent):void {
         // your loading code or whatever
    >

  • Trying to get a movieclip to display on top of an externally loaded swf

    I am trying to ensure that a movieclip named "Incorrect"
    displays on top of a swf file that loads with the following:
    loadMovieNum("map.swf",1);
    I'm sure it's pretty simple, but I couldn't find any good
    reference to a movieclip loading on top of an external swf. I tried
    loading the map.swf into a placeholder movieclip and doing a
    swapDepth, but then the code within the map.swf would no longer
    function properly.
    thanks.

    you must load that movieclip into a _level greater than 1.
    there is no work-around if you load map.swf into _level1.
    you could load map.swf into a target movieclip and then use
    the swapDepths() method of movieclips to control the apparent depth
    of map.swf and your movieclip.

  • Loading swf into movieclip object

    I am trying to load a swf file into a movieclip object on the
    stage. The movieclip object is sized smaller than the screen, and
    placed in the middle. I have defined a loader with:
    var myMovieClipLoader:MovieClipLoader = new
    MovieClipLoader();
    then use it like this:
    _level0.myMovieClipLoader.loadClip("moviename.swf",
    _level5.movieclipinstancename);
    (the movieclip object is used in a swf loaded in level5)
    When I load the swf like this, the swf loads at the correct
    location according to where I have placed the movieclip object,
    however it "blows up" to fill the screen from that point down and
    across, ignoring the size of the movie clip object (the loading swf
    actually expands beyond it's created size to fill the screen,
    making all the graphics and text much larger than intended). The
    actual pixel size of the swf I'm trying to load matches the size of
    the movieclip object (1024x350 in a 1280x1024 screen).
    What is the magic setting or property that will tell the
    loading swf to honor the size of the movieclip object I'm loading
    into?
    Thanks for your help!
    Barb

    Something I've been working on:
    Place the following code in a new file <your project
    folder>\as\MovieContainer.as
    Then open the properties for the symbol you want to be your
    movie container
    Set the AS 2.0 Class to as.MovieContainer and give it a name
    (I named mine 'loader').
    To load the movie, simply call:
    loader.queueSWF('my.swf');
    Hope that makes sense. Basically, it's just a self contained
    class for loading into an object on the scene. It draws a simple
    progress bar on the center of the symbol when it's loading and it
    resizes the loaded object on init to conform to the size of the
    object on the stage. Why queueSWF? Well, if it's currently loading
    a SWF, it will wait till it's finished and load a new one. The
    biggest problem right now is the progress bar, but it's fairly easy
    to remove if you don't like it. Hopefully it helps.
    If anyone else is reading this. I'm trying to figure out if I
    can load these movies into an array of movieclips. So far I've had
    no luck. If you know of a way, feel free to drop some input.

  • Color external loaded swf in AS3 Help Urgent!

    Hi i have loaded swf from an external path using the following command.
    var cviewer:Loader=new Loader();
    var curlRequest:URLRequest=new URLRequest("clipArts/"+evt.target.name);
    So this is the scenario.
    Suppose say i load Movie1.swf
    I have three movie clips inside Movie1.swf called step0, step1, step2
    I need to change the color of step0, step1 and step 2 from the parent flash file which loads movie1. All the inner movie clips color may be different from each other.
    I am able to change the color of the whole movie clip by using
    var colorInfo:ColorTransform = cviewer.transform.colorTransform;
    colorInfo.color=evt.target.selectedColor;
    cviewer.transform.colorTransform=colorInfo;
    But not of individual ones. I even tried cviewer.step0.transform.colortransform and other stuff to see if it would work. But nothing worked. Help at fastest would be deeply appreciated.
    Regards and thanks in advance.

    try:
    var colorInfo:ColorTransform = MovieClip(cviewer.content).step0.transform.colorTransform;
    colorInfo.color=evt.target.selectedColor;
    MovieClip(cviewer.content).step0.transform.colorTransform=colorInfo;

  • (AS3) Controlling Loaded SWF

    I am trying to control a loaded .swf with the parent .swf. I
    do not know how to call the loaded .swf. I know how to control the
    parent with the child, but not the other way around. any
    suggestions would be great. thanks!

    call on the Loader object where the movie is being held.
    You'll need to typecast like this....
    MovieClip(Loader.contentLoaderInfo.content). My recommendation is
    to store that path to a variable
    var myLoadedMovie:MovieClip = MovieClip(
    varNameOfMyLoader.contentLoaderInfo.content);
    change out the varNameOfMyLoader with the proper variable
    name and you should be able to target the movieclip as you would
    have done in AS2.

  • 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

  • Tween Max AS3 Not Working on Root of loaded SWF

         I have a project where I'm loading a SWF into another Shell SWF and I've run into a strange bug.  Tween Max works in the compiled clip everywhere, but on the root of the loaded SWF.  It's not erroring out, it's just not tweening anything?
    Here's the code for the loader in the Shell...
    stop();
    //Import the required assets
    import flash.display.*;
    //Stop the playhead while loading occurs
    var ldr:Loader = new Loader();
    var url:String = "12com2682-value.swf";
    var urlReq:URLRequest = new URLRequest(url);
    ldr.load(urlReq);
    //Create a listener to call the loading function as the movie loads
    ldr.contentLoaderInfo.addEventListener (ProgressEvent.PROGRESS, PL_LOADING2);
    function PL_LOADING2(event:ProgressEvent):void {
    loader_txt.visible = true;
    var pcent:Number=event.bytesLoaded/event.bytesTotal*100;
    //Display the % loaded in textfield
    loader_txt.text="loading:"+int(pcent)+"%";
    //If the movie is fully loaded, kick to the next frame on the main timeline
    //You may wish to change the gotoAndStop(2) to a gotoAndPlay(2)
    if(pcent==100){
              mc_loadscene.addChild(ldr);
              loader_txt.visible = false;
    this.loaderInfo.removeEventListener (ProgressEvent.PROGRESS, PL_LOADING);
    then in the loaded SWF, I have:
    stop();
    import com.greensock.TweenMax;
    import com.greensock.plugins.*;
    TweenPlugin.activate([AutoAlphaPlugin]);
    import fl.transitions.easing.*;
    //////mc_host is a movieclip holding a video
    TweenMax.to(mc_host, 1, {scaleY:1, scaleX:1, delay: 2.5, ease:Back.easeOut });
    //////mc_sidert is another movieclip
    TweenMax.from(mc_sidert, 2, {y:"-600"});
    Anybody else running into this error? 

    you must be doing something wrong because that code works as expected for me:  http://www.kglad.com/Files/forums/test2.html and http://www.kglad.com/Files/forums/test2.fla
    p.s. please mark helpful/correct responses.

  • AS3 Access a Loaded SWF By Name

    Hello All,
    In AS3, when an swf is loaded via the Loader class, how do I
    access the loaded swf by name? Here is my code:
    stop();
    var loader:Loader = new Loader();
    var whichMovie:String = "main.swf";
    addChild(loader);
    function wakeLoadBar():void{
    loadBar.gotoAndPlay("fadeIn");
    function loadTheMovie(theMovie:String):void{
    trace("LOADTHEMOVIE");
    loader.contentLoaderInfo.addEventListener(Event.OPEN,
    onLoaderOpen);
    loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,
    onLoaderProgress);
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE,
    onLoaderComplete);
    loader.load(new URLRequest(theMovie));
    function onLoaderOpen(event:Event):void{
    trace("OPEN");
    function onLoaderProgress(event:ProgressEvent):void{
    var percent:Number = Math.floor(event.bytesLoaded /
    event.bytesTotal * 100) + 10;
    loadBar.gotoAndStop(percent);
    trace("Progress " + percent);
    function onLoaderComplete(event:ProgressEvent):void{
    trace("Progress Complete");
    wakeLoadBar();
    function loadTheMovie is called after the loader "fadesIn"
    and the movie begins to load.
    Let's say that after the movie loads, I want to change its x
    and y, how do I go about doing that?
    laodedMovieName.x = 50;
    laodedMovieName.y = 150;

    KGlad,
    LOL... You rock!
    Thanks,
    V

Maybe you are looking for