Controlling a Movie Clip on the Main Timeline from a loaded SWF?

Is it possible to control a MovieClip on the main timelne from another loaded clip?
I see posts that control loaded clips, but most are all from the loader in the main timeline.  I have a moviclip on the main timeline that I want to make visible or invisible depending on what keyframe is playing in another loaded swf.
If I try to call the movieClip from the loaded SWF I get "error #1119.  Access of possibly undefined property...." because it doesn't exist in the loaded SWF, just the main timeline. 
The old AS2 way just used "_root".  Since "_root" doesn't exist any more, how do you control items on the main TimeLine from a loaded SWF?

I am not clear what you mean because you are saying you are trying to target a movieclip that does not exist where you are trying to target it.
Try using a trace to see what you are targeting when you you target the MovieClip(parent.parent)....
trace(MovieClip(parent.parent));
The other approach I mentioned earlier is the more OOP-correct approach if you would rather try that way.  Here's a rough outline of it...
AS3 - Dispatch Event
http://forums.adobe.com/thread/470135?tstart=120
Example:
Add something to trigger the event in the child (your loaded swf):
dispatchEvent(new Event("eventTriggered")); (
if dispatchEvent problem, see: http://www.kirupa.com/forum/showthread.php?p=1899603#post1899603)
In your loading/parent swf, listen for the complete event on the Loader.contentLoaderInfo.  In the complete event handler, add a listener for the event on the loaded swf.
// event handler triggered when external swf is loaded
function loaderCompleteHandler(event:Event) {
    MovieClip(event.currentTarget.content).addEventListener("eventTriggered", eventHandler);
function eventHandler(event:Event):void {
    trace("event dispatched in loaded swf");
   // this is where your main file can set the visible property of your movieclip

Similar Messages

  • How do I recerence Movie Clips on the Main Timeline from inside a class?

    Hey everyone, this might be a stupid question but I thought
    I'd ask cause it's making me nuts. I'm all of 2 days into AS3
    (coming from not using Flash at all in YEARS) so feel free to
    consider me ignorant. I do have plenty of application development
    experience in other areas though.
    I can't seem to create a class that can reference an instance
    of a movie clip on my main timeline. I'd post code of what I've
    tried but I've gone through so many desperate edits & wild
    guesses that it was just garbled junk before I deleted it all.
    Basically here's how I figured Flash could work, though maybe
    it doesn't work this way at all.
    I'm assuming that with AS 3 being so big on being a true
    object oriented environment, I wouldn't need to mix my code and
    interface together. Preferably I'd be using the Flash authoring
    tools just to design my interface. Create a button... place it
    somewhere... give it an instance name. Roughly the equivilant of
    Apple's InterfaceBuilder for those of you that might be familiar
    with Cocoa development. I can see maybe having to put a few lines
    of ActionScript onto frame 1 (though really I'm hoping Flash would
    have a better method of kicking off the application at this point
    that using code tied to frames) to load my classes & such, but
    after that I'd like all of my code to be held in external class
    files.
    So maybe I've got:
    Interface.fla - My interface
    Button_1
    Button_2
    TextField_1
    Main.as - My main controller class using to handle all of my
    applications behavior
    SomeClass.as - Some helper Class
    SomeOtherClass.as - Some helper Class
    Main.as would have instructions in its initialization method
    to go ahead & attach events to buttons & initialize
    anything else that needs to happen when the application starts.
    From there on it would all be objects communicating back &
    forth. Button_1 would get clicked with would fire
    Main.someMethod(). Main.someMethod() would then do it's thing and
    set the value of TextField_1. All very clean & code is very
    separated from interface.
    Unfortunately I can't for the life of me figure out how AS3
    classes reference each other like that. There doesn't seem to be
    any kind of a global 'root' or '_root' I can use to locate any
    movie clips on the stage. I've searched the help & the web for
    any kind of simple tutorial but to no avail. My job has tasked me
    with building a flash app for a project but I'd really rather not
    have a tone of ActionScript just shoved into frame 1. That just
    seems... ugh! (::shudder::)
    Can someone maybe point me in the right direction here? I'm
    really willing to do my homework but I can't seem to locate the
    info I need to get started. Also, is there an ActionScript IRC
    channel or something maybe?
    Thanks,
    Cliff

    I worked with the problem last night and the solution I
    started coming to involved creating my own custom document class
    based off which extends MovieClip. My thought is that way I have
    access to the initialization routine of the timeline itself and
    that all of the elements on the main timeline should be
    "properties" of my custom class.
    Is this correct? Is there a down side to doing this & if
    so what is it & why?
    Also, just for my reference, the last time I did anything
    with ActionScript I think I was using '_root' to target the main
    timeline. WHat are the global variable names in AS 3? Is it just
    'root' & 'stage' or 'Root' & 'Stage' or what?

  • Passing a variable from a movie clip to the main timeline

    Hi,
    I'm having trouble passing a variable from a movie clip in my
    flash file to the main timeline.
    I have a movieclip with the instance name IntroNav which
    contains several buttons. Clicking a button sets the variable
    "page" to a specific name, i.e. page = "home"
    However, outside of the movie clip, on the main timeline I am
    unable to call this variable, and "page" seems to have no value.
    Can anyone tell me why this is and how to solve it?
    Thanks

    Umm, yes ... declare your variables correctly.
    var page:String = new String(); //proper complete
    var page:String; //strict typing
    var page:String = "home"; //stirct typing with value
    declaration
    Do not declare the variable in your buttons, you would have
    to do so in every button and be constantly resetting the value.
    Declare it on the main timeline at the lowest level. You do not
    need to use it as a _global, you just need to resolve your path
    issues. You can 'set' the variable value from a button, without any
    problem, but you have to call to the variable correctly.
    You do not 'name' a variable as "_root.page" , the '_root'
    refers to the lowest level of the SWF or the main timeline, as does
    a call to ' _level0' (that's a zero). If the variable is declared
    on the main timeline, and you're calling from the MC/button or
    anywhere you can refer to the variable by calling to it by
    the proper path of '_root.page'
    To set the variable from any of your button/MC instances
    call:
    _root.page = "value"; OR _level0.page = "value";
    But you must have the varibale declared on the main timeline,
    and only once and the playhead should be stopped or it will reset
    the value to the default upon looping.

  • Load a MC on the main timeline from a MC.     AS3

    I have a movie clip (mc_menu) on that is on the main timeline.
    This movie clip has buttons that I want to use to display other movie clips on the main (parent) timeline.

    Start here:
    http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9 b90204-7e4e.html

  • How do I set a variable on the main timeline from within a symbol?

    Just getting started with Animate and coming to it from Flash, as may be apparent from my question. How do you set a variable to the main timeline from within a symbol?
    I have 24 pairs of clickable elements, each in their own symbols, and all 24 of those symbols sit inside another symbol. I want all 24 to be able to set the same global variable when clicked. I can't find that this question is addressed anywhere, which makes me think I may be stuck in a Flash mindset and approaching the task in the wrong way. (There are however MANY discussions of how to address objects at different levels in the hierarchy. That's well covered.)
    Relatedly, how do you access a function on the main timeline from within a symbol?
    Adobe should consider putting together a support page (or pages) just for folks migrating form Flash. In the materials I've encountered so far there seems to be a studied effort to refrain from mentioning Flash in any way. I imagine there are a lot of people out there like me who have a deep background in Flash coding, but are just getting started with Animate. We don't need help with most of the basic concepts, but we may still have some pretty basic questions about how to accomplish some things in Animate because our Flash knowledge is getting in the way.

    Hi Bill,
    There are plenty of threads on here about scope, but here's one way to create a global variable:
    // code on Stage.compositionReady
    sym.myGlobalVar = 1;
    Then, anywhere in your project, you can check/set that var like so:
    sym.getComposition().getStage().myGlobalVar = 2;
    And here's one way to create a global function:
    // code on Stage.compositionReady
    sym.myGlobalFunction = function(){
              console.log('myGlobalFunction');
    Then, anywhere in your project, you can call that function like so:
    sym.getComposition().getStage().myGlobalFunction();

  • Controll the ROOT timeline from externally loaded movie clip?

    does anyone know how to controll the root timeline from an
    externally loaded movie clip?
    I have loaded a movie clip, which has buttons on it that I
    would like to controll the main original website timeline with.
    something like this.parent.parent?
    thanks a lot
    harky

    feedmeapples <[email protected]> wrote:
    > does anyone know how to controll the root timeline from
    an externally
    > loaded movie clip?
    >
    > I have loaded a movie clip, which has buttons on it that
    I would like
    > to controll the main original website timeline with.
    >
    > something like this.parent.parent?
    _root.doStuff;
    Freundliche Grüße,
    Franz Marksteiner

  • Toolkit for CreateJS: How to control the main timeline from outside the canvas.

    Hey Everyone,
    I'm currently trying to do something simple, but my animation breaks whenever I attempt to change my code. I have created a basic animation in Flash where an object moves from the left side of the canvas, to the right, and then loops from the last frame to the first frame. Nothing else. The animation is simply put on the main timeline. I exported the animation with Toolkit for CreateJS through Flash's extension and the animation runs as it should. I am trying to start and stop (restarting from the first frame) the animation with mouse over and mouse off events. I want the events to fire when moused over/off a div OUTSIDE the animation's canvas tag. Is this possible with CreateJS? I'm trying to figure out how to control the main timeline without being inside the canvas tag.
    Example HTML:
    http://www.thephotoncore.com/testing/example_test.html
    Example Code:
    <section id="container">
      <canvas id="canvas" width="550" height="400" style="background-color:#cccccc"></canvas>
      <section id="animation_control">
        <p>Roll over to start and stop animation.</p>
      </section>
    </section>
    Thanks again for the help!
    -DJ

    Hi DjPhantasy5,
    All movieclips on the stage are children of the stage,
    So on the "mouseover" all movieclips on the stage could be stopped with stop and on the "mouseout" all children could be restarted with gotoAndPlay like this:
    function Stop()
              if (stage && stage.children)
                        var i, l = stage.children.length;
                        for (i = 0; i < l; i++)
                                  var child = stage.children[i];
                                  if ("stop" in child)
                                            child.stop();
    function Restart()
              if (stage && stage.children)
                        var i, l = stage.children.length;
                        for (i = 0; i < l; i++)
                                  var child = stage.children[i];
                                  if ("gotoAndPlay" in child)
                                            child.gotoAndPlay(0);
    See http://www.liauw.nl/forums/adobe/djfantasy5/index.html
    But it is also possible to expose "ball1", for example, by adding it to the document.
    This can be done by adding code to "ball1" like so:
    /* js
    document.ball1 = this;
    Then the stopping of the animation would look like:
    function Stop()
         if ("ball1" in document)
              document.ball1.stop();
    etc.
    Have fun!
    Ronald

  • How to _root in as3 (buttons in movie clip referencing to main timeline)

    Hi, I created buttons within a movie clip that i placed in the main timeline.I am  a novice to as3. I just wanted the button to go to the frame label of the main timeline. i used to do this with _root in the old flash. how do i do this?
    thumb02_btn.addEventListener(MouseEvent.CLICK, buttonClicked);
    function buttonClicked(event:MouseEvent):void
        gotoAndPlay("slide2");

    Thanks for the quick reply!
    somehow i must be doing something wrong though. It's not working...
    I added a stop to the "slide02" labeled section of the main timeline.
    and I also added a stop to the beginning and end of the movieclip. Am I doing something wrong? attached is my file....thanks!!
    stop();
    thumb02_btn.addEventListener(MouseEvent.CLICK, buttonClicked);
    function buttonClicked(event:MouseEvent):void
        MovieClip(this.root).gotoAndPlay("slide2");
    stop();

  • Please help! first website! movie clip placed on main timeline wont play!

    Hi! if any one could please help me it would be greatly
    appreciated!
    So im trying to make my first website in flash and ive ran
    into a problem. I have the main movie, my main time line. I have a
    few animations going on in this that were all created in that main
    time line. those work fine. however, i created two new movie clips
    (still inside the same .fla file) and animated them with thier own
    time line. I then thought you could just drag and drop these movie
    clips onto your main time line and they would play inside the
    movie. but when i press ctrl + enter, the dont play!
    here are some points of intrest.
    my main movie (the main time line) is 130 frames.
    the movie clips i made inside the same .fla file are between
    400 and 600 frames.
    i placed both new movie clips on the 130th frame in the time
    line with their own layers.
    also there is a layer for actions on the 130th that has
    stop();
    i thought that maybe the time line had to be as long as those
    movie clips i created and so i extended it but they still didnt
    play.
    im thinking action script is involved? please help me im
    getting pretty frustrated and im sure there is something simple to
    achieve this.
    here is a link where you can download the source files im
    using. if you open the file the two movie clips i created are
    called front two and front one and are layers with the same name.
    this board wont let me fully post my link cause the last word
    in it is s*h*i*t* so youll have to type it in your browser. its
    http://public.me.com/matts*h*i*t*
    (just remove the asterisks)
    also i noticed that my file is huge. i used photoshop to
    create everything and them imported it into flash. is there a way i
    can reduce this size?
    thank you sooo much! please help!
    -Matt

    Hey Matt,
    I'll take a look at your file, but as a general rule, a
    movieclip's timeline plays automatically when it is first
    instantiated. Instatiated means its first frame where "it exists"
    on the timeline that contains it. So the layer that holds your
    movieclip animation, needs to extend the length of the timeline you
    want that movieclip to "exist". Other than that rule, the frames
    don't NEED to match the frames inside said movieclip.
    So, if movieclips play automatically, and yours isn't, there
    must be something either stopping the movieclips timeline, or your
    movieclip isn't existing on the timeline because the layer that
    holds it, doesn't have keyframes the length you need it to.
    Yeah optimizing your sprites (2d graphical elements), and
    using vector when you need to (if you don't know the difference
    between raster and vector, google it) will significantly lower your
    outputted .swf file size.
    Edit: After looking at your file, your movieclips are not
    playing (well, they're technically playing, just not showing up)
    because your masker layer has multiple objects on it. A masker
    layer (not to be confused with the maskee layer, the layer being
    masked) needs to have only one object on it, or else you break the
    mask. The grey border of your mask movieclip needs to be deleted
    before your animation will play.

  • How to control the main timeline from within a symbol?

    I have a small world map as a symbol called "verden" and I want the user to click Europe, Asia, or Africa and jump to named labels in the main timeline.
    http://www.dagbladet.no/grafikk/neshorn/neshorn.html
    On the main timeline a have the label "intro" with a Stop action and the label "europa". At label "europa" I have a symbol also called "europa" which has a display of None at label "intro" and On at the label "europa".
    The animation never goes to label "europa"
    I have this code on europa in the symbol "verden" :
    // insert code for mouse click here
    sym.getComposition().getStage().getSymbol("europa").play("europa");
    The files are on Dropbox here
    Update, now it works:
    sym.getComposition().getStage().play("europa");

    Hi Bill,
    There are plenty of threads on here about scope, but here's one way to create a global variable:
    // code on Stage.compositionReady
    sym.myGlobalVar = 1;
    Then, anywhere in your project, you can check/set that var like so:
    sym.getComposition().getStage().myGlobalVar = 2;
    And here's one way to create a global function:
    // code on Stage.compositionReady
    sym.myGlobalFunction = function(){
              console.log('myGlobalFunction');
    Then, anywhere in your project, you can call that function like so:
    sym.getComposition().getStage().myGlobalFunction();

  • Control the property of an object in main stage from a loaded swf timeline

    please someone help me here, im loosing my mind
    i have a UILoader that loads an image from an xml list when you click its thumbnail ( in its thumbnails mc on mainstage aswell)
    thing is, i have another UILoader on the layer above that loads in a swf ( a slideshow that fades in and out the pictures when they change to the next,
    with all the coding on frame 1, frame 2 only has a stop and some code for when the mouse is idle for 5 secs it goes back to frame 1)
    so when you go to "portraits" it takes you to frame "x" where the slideshow ( loaded external swf ) starts playing automaticly right,
    if i click any thumbnail the slideshow goes to frame 2 ( wich is perfect and the mouse idle thing i wanted works great ) the ONLY THING IS
    after the slideshow runs by default for the first time ( i enter the category portraits )
    and i click any thumbnail ( moving slideshow swf to frame 2 enabling mouse idle event )
    and the mouse is idle ( so it does the event and starts playing the slideshow again ( goes back to frame 1 ) )
    I CANT MAKE THE UILOADER OF THE THUMBS IMAGE TO DISSAPPEAR!!!
    i have tried everything i can think of and everything i have read trying to adapt it with what i know,
    im no guru at this i reeeeally need some help
    THANK YOU  SO VERY MUCH ! 

    and where would i put the remove.simpleScreen ( simpleScreen is the loader i would want to remove )
    would it be on the external swf on frame 1 where the slideshow plays?
    or in the main timeline's category's frame?
    the problem ( that i see ) is that both loaders are on the same frame ( different layers tho )
    so if i put a the remove simplescreen there it wont show me the pictures when i click the thumbs
    or could i make it so that it removes it BECAUSE its playing on frame 1 ?

  • Referencing the main timeline from elsewhere

    From inside a movie clip (button) which is inside a display
    object (buttonSet), I want to gotoAndPlay a specific frame on the
    main timeline. I've tried stage.gotoAndPlay(thisFrame). I got
    closer with gotoAndPlay(stage.thisFrame). I still have something
    wrong.
    I have about 15 frames on the main timeline. Each frame
    contains a myriad of objects all doing different things. Most
    importantly they transition from frame to frame based on the
    current frame (last button clicked) and the next frame (the newly
    clicked button).
    Example: the last button that was clicked was button #4, the
    button I have just clicked is button #2. Based on this knowledge, I
    want the main timeline to gotoAndPlay frame #6.
    Thanks for the aid. :)

    the flash compiler (in strict mode) often has trouble
    "remembering" the class-type of objects/variables. "typing" those
    objects explicitly helps the compiler to overcome erroneous error
    messages.

  • Moving the play head in the main timeline from a button in a movie clip

    I have a movie clip that loads and when it is done playing it has a close button that unloads the movie clip... I want to add code to this button that moves the play head to frame 20 of my main timline using actionScript 3.0

    Tried that but dose not work think its because I am loading the movie this way...
    Play button "playFinal"
    function lastQuestion(event:MouseEvent):void{
         var Info:final1 = new(final1);
         this.stage.addChild(Info);
         Info.x=511
         Info.y=340; }
    So I tried using the Name "Info"
    //example......    MovieClip(Info.root).gotoAndStop(20);
    And I tried the name of the clip in the library "final1"
    //example......    MovieClip(final1.root).gotoAndStop(20);
    Is it because im loading it with actions script instead of having it on the timeline?

  • Menus - how do i go to a frame in  the main scene from a loaded movie?

    hi...
    need help... i actually have done this beofre but dont know
    what ia doing worng now..
    i created an intro. this into is a seperte movie loaded into
    my main movie.
    in the intro there is a skip button so that the user can skip
    intor and go to a a frame on the main scene i loaded the movie
    into...
    i tried _root.gotoAndPlay(10) it doenst work...
    i trird )level0gotoANdPlay(10) it doent work...
    please help !
    thanks

    Hi there,
    Normally you use something like:
    loadMovie("intro.swf", intro_mc);
    And then you have to say:
    _root.intro_mc.gotoAndPlay(10);
    The movie that you loaded is in the movieclip. So this should
    work.
    Greeting Guido
    Creation site internet |
    Radin
    |
    Jeux
    Concours |
    Echantillons

  • Moving the timeline from a loaded swf file

    Hi,
    I have been at this problem for awhile now.
    I have a two swf files, whic are loaded using ths code as an example:
    stop();
    var req:URLRequest = new URLRequest("Enchilada_A.swf");
    var loader:Loader = new Loader();
    function imageLoaded(event:Event):void {
        ldContainerB.addChild(loader);
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
    loader.load(req);
    The first one is triggerrd by a MC button that is on the timeline.
    That first swf loads fine.
    At the end of that file(which is short animation)
    I have code that says:
    MovieClip(parent).gotoAndStop("frameThree");
    I have also tried:
    MovieClip(root) and
    if (movie Clip is parent) {
    MovieClip(parent).gotoAndStop("frameThree");
    and/MovieClip(parent).nextFrame();
    I have also tried placing this. or root. into the code.
    I am not talking to the timeline from this swf file.
    Once the timeline moves to the next Frame the new swf file can load.
    My solution was to combine both swf files into one, which loads from the timeline button.
    It works and I can gt by but I really woud like to learn how to load a swf and talk to the timeline fro more flexibilty.
    I'm out of strategies.
    Is my code in the wrong place(at the last frame of the animation?
    Should it be written on the timeline by creating a new var that has a function once the animation is completed.
    Any suggestions and/or commens would be greatly appreciated.
    Thanks.

    Thanks,
    I finally had a chance to get back to this project and used your suggestions, whichare definitiley helpful. I also, created a new and very basic version of the project so I could easily see what was happening.
    This is the code that works:
    stop();
    MovieClip(parent.parent).nextFrame();
    trace(container_mc);
    I'm still trying to understand how the child parent relationship is working but this will get me going in the right direction.

Maybe you are looking for

  • When m installng latest version of i tunes error comes

    when m installng latest version of i tunes some error comes it is ''service apple mobile device (apple mobile device) failed to start verify tht u have sufficient privileges to start system service" what should i do????????/

  • Agent Desktop logging out frequently !!

    User is reporting that they periodically get logged out from the agent desktop application every 30 minutes. This happens frequently. A message appears on our desktop(cisco agent desktop application) in a grey box saying the time and connection lost

  • Computer Hangs or Freezes on Shut Down or Restart

    I have a B&W running OSX Server 10.3.9 and for some reason it will not shut down. It logs out and goes to the Blue Screen with the spinning logo thing but nothing happens. The Computer just sits there and doesn't shut down. I checked the Ram, The Bat

  • Generate Function But Can't Call It? --Reload

    hi all, I have program like below, but the SAP system tell me "Call Function NOT FOUND" when lv_idx = 2. How to make it work? *& Report  Z_TEST_DYN REPORT  z_test_dyn. DATA fname TYPE rs38l-name. DATA:       lt_code TYPE TABLE OF rssource,       lv_i

  • Photoshop and Video

    Is it possible to edit a Sony Vegas Video Using Photoshop?  If so, what will I need?  Elements?  Or am I just out of luck?