Array to control MCs on the root timeline

HI - - - a continuing saga
I have a main timeline thats about 900 frames long. During
the course of this 900 frames I bring in short MCs (subA, subB,
subC, etc) on their own layer which play their duration - (a 90
frame sub MC gets 90 frames on the main timeline).
Using a mc I made into a play/pause btn, I can pause and
resume play of the main timeline by targeting “_root”.
I can also use the same button to pause/play the sub_mcs IF I
list each one at the pause and play commands. I thought an array
would help me avoid that code repetition but it doesn't work.
Can someone look at my code and let me know what's missing
and/or what I did wrong?
TIA
JL

Hi --
Try this:
obj = allSubMCs[0]
obj.play();
etc..
You have to define the index of the array. If you want the
pause/play button
to work for all MCs in the array then just loop through the
array.
Rich
"jlucchesi" <[email protected]> wrote in
message
news:ghun7u$pjn$[email protected]..
> HI - - - a continuing saga
>
> I have a main timeline thats about 900 frames long.
During the course of
> this
> 900 frames I bring in short MCs (subA, subB, subC, etc)
on their own layer
> which play their duration - (a 90 frame sub MC gets 90
frames on the main
> timeline).
>
> Using a mc I made into a play/pause btn, I can pause and
resume play of
> the
> main timeline by targeting ?_root?.
> I can also use the same button to pause/play the sub_mcs
IF I list each
> one at
> the pause and play commands. I thought an array would
help me avoid that
> code
> repetition but it doesn't work.
>
> Can someone look at my code and let me know what's
missing and/or what I
> did
> wrong?
>
> TIA
>
> JL
>
> var allSubMCs:Array = new Array("sub1_mc", "sub2_mc",
"sub3_mc");
>
>
> playPause_btn.onRollOver = function() {
>
> if(this._currentframe == 1) {
> this.gotoAndStop("pauseOver");
> }
>
> else {
> this.gotoAndStop("playOver");
> }
>
> }
>
>
> playPause_btn.onRollOut = function() {
>
> if(this._currentframe == 10) {
> this.gotoAndStop("pause");
> }
>
> else {
> this.gotoAndStop("play");
> }
>
> }
>
>
> playPause_btn.onRelease = function() {
>
> if(this._currentframe == 10) {
> this.gotoAndStop("playOver");
> _root.sub1_mc.stop(); // naming each sub mc does
> //_root.allSubMCs.stop(); // the array doesn't work
> _root.stop();
> }
>
> else {
> this.gotoAndStop("pauseOver");
> //_root.allSubMCs.play(); // the array doesn't work
> _root.sub1_mc.play(); // naming each sub mc does
> _root.play();
> }
>
> }
> //------END PlayPause TOGGLE--------
>

Similar Messages

  • 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

  • Controlling the root timeline from inside a MovieClip

    [preface] I'll apologize in advance. I'm a designer, not a
    developer. I know very little about actionscript so if you
    can help me out, please pretend like I know nothing.
    [/ preface]
    I just need actionscript to check the value of a variable
    when the end of a movie clip is reached and then call an action.
    Here's what I've got and it doesn't work. Please don't laugh.
    if (p == 1){
    tellTarget (_root) {
    play();
    else if (p == 0){
    stop();
    (the "stop" on the "else if"
    is referring to the movie clip's timeline, not the root
    timeline... in case you're wondering)
    Any help would be greatly appreciated. Thanks!

    No it's not a school project. Good guess though. It's
    actually a self-promo piece for the ad agency I work for. I'm an
    art director expanding my horizons. I would take a class or run
    through one of the good actionscript books but unfortunately, I
    don't have time.
    Thanks for the help again kglad.
    btw, I've used tellTarget successfully in a few projects in
    the last few months. I'm using Flash 8.

  • Refering to a class imported on the root timeline?

    This is probably ueber basic, but I don't know how to do it.
    I am importing tweenlite on the root timeline like this:
    import gs.TweenLite;
    I now want animate things in other MCs. I tried something like this, but it did not seem to work.
    _parent.TweenLite.to(text1, 3, {_alpha:100, overwrite:0});
    How would I do this?
    Thanks a lot for any help with this!!!

    it's easiest to not even bother with the import statement and always use:
    gs.TweenLite.to();
    or
    gs.TweenLite.from()
    from any timeline.

  • Remove child on the root timeline from within a movieclip

    Hi
    How do I remove a child from the root timeline from within a separate movieclip?
    I've tried
    MovieClip(parent).removeChild(mc1);
    But I get this error
    1120: Access of undefined property mc1.
    I could write a function in the root timeline that just removes child and then run that from within the movieclip but is there a better way?
    Thanks in advance.

    Thanks for replying.
    I asked on Kirupa but I couldn't access the site so I asked here.
    I guy answered with this
    MovieClip(parent).removeChild(MovieClip(parent).getChildByName("mc1"));
    It works fine, is this the best way to do it?
    Not sure if I understand what you meant?
    Just to be clear I have to movie clips on the stage mc1 and mc2 and i want to remove mc1 from within mc2's timeline.
    Thanks again

  • 4 mc's on the root timeline. Using onClipEvents... all mcs play at once.

    I have 4 mc's on a root timeline. I'd like each, when clicked, to animate individually. Currently with the code I have, when I click one, they all play. 3 of these mc's are identical mc's (they have instance names, but aren't called out in the code, not sure how to). The fourth mc is a different mc altogether, yet this particular mc along with the other 3 (identical) all play at once.
    I thought using "this" would only have the mc I click on play. Not the case. I also tried putting the instance name (i.e. onoff1) bofore "this." and after "this." and no luck.
    Thanks for any help, and I regret to say that I'm not savvy in AS2, so I hope you don't mind spelling things out for me because this a bit over my head.
    Also, wanted to say, that the mc's timeline do have a stop at the beginning and end. So when you export the swf (currently) the mc is stopped, and when you click on it they all play to the next stop. So they act like I want them, just that they're all animating at once no matter which one I click.
    onClipEvent(mouseUp) {
    this.gotoAndPlay(1);

    Wow! You are the man!!!!! Karma points! Thanks so much.
    I've only used on(release) for buttons, and have always used onClipEvent(mouseUp) for mcs. I didn't know you could use on(release) for mcs, didn't think you could.
    I know enough AS3, more than AS2. I got a gig that asks for AS2 and I had to learn it from the ground up. I miss using the function command in AS3, I think I used it for everything.
    Thanks again.

  • Reffering to code in the root timeline

    I'm very suprised I theres not an obvious answer to this
    question to be found. In AS 2 I would often write most of my code
    in the main timeline, and then refer to it from various other
    movies etc. I dont seem to be able to do that in AS 3? how can I do
    it in AS 3?
    For example if i had a function on the main timeline, and
    wanted to call it from the code in another movie. In that past I
    would have just used _root.functionName();

    _root in AS3 is now simply root (no underscore). The root
    property,
    however, is only available to DisplayObject instances, not
    other classes.
    The root reference is also null unless the DisplayObject
    instance is a child
    of a display list attached to the stage. For timeline scripts
    within a Flash
    FLA, however, where the movie clip is added to the screen
    within the Flash
    environment, root is always available.
    A good practice for globally accessible functions, however,
    would be to
    define your functions as static methods in a class. Then you
    can reference
    those functions anywhere from any object (even non
    DisplayObject instances)
    using ClassName.functionName()
    "smazr123" <[email protected]> wrote in
    message
    news:f29rrb$4nl$[email protected]..
    > I'm very suprised I theres not an obvious answer to this
    question to be
    > found.
    > In AS 2 I would often write most of my code in the main
    timeline, and then
    > refer to it from various other movies etc. I dont seem
    to be able to do
    > that in
    > AS 3? how can I do it in AS 3?
    >
    > For example if i had a function on the main timeline,
    and wanted to call
    > it
    > from the code in another movie. In that past I would
    have just used
    > _root.functionName();
    >

  • 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

  • GotoAndStop at the the root of the timeline

    HI
    I have a movie clip with onRollOver and onRollOut script
    attached. When clicked I would like the root of the timeline to
    move to a different label. At present I have tried the following
    first script on the MC to move the root timeline, however this is
    not working and I assume this is due to the complexity of the movie
    clip:
    I have therefore used the following 2nd script for the first
    frame of the timeline within the MC which works with getURL but I
    am unable to get it to work with moving the root of the timeline.
    Do I need to add .root somewhere? Thanks

    Here is the answer:

  • Load swf AFTER playing to end of root timeline

    Don't know if this can be done or not...
    I have my Home page - 5 Navigation buttons on the page. Each
    button "onRelease" will load an external swf file ( a new page).
    The problem i'm having is getting the the buttons to play the rest
    of the root timeline (after "Stop) before it loads the external
    swf. The rest of the timeline is just a short fade to Alpha 0 of
    all buttons before the new page comes in.
    any help?
    thanks in advance.

    michaeltowse wrote:
    > Could you not assign a variable which is then picked up
    at the end of the main
    > timeline. This variable could be used within a loadMovie
    command. Your buttons
    > would have the variable declaration and then a play()
    command.
    >
    What you seem to need is some sort of non unloading loading
    of the movie.
    You got the level loading method, the movieclip loading
    method and the
    dedicated loader class.

  • Reffering to Code in root timeline

    I'm very suprised I theres not an obvious answer to this
    question to be found. In AS 2 I would often write most of my code
    in the main timeline, and then refer to it from various other
    movies etc. I dont seem to be able to do that in AS 3? how can I do
    it in AS 3?
    For example if i had a function on the main timeline, and
    wanted to call it from the code in another movie. In that past I
    would have just used _root.functionName();
    RESPONCE:
    _root in AS3 is now simply root (no underscore). The root
    property,
    however, is only available to DisplayObject instances, not
    other classes.
    The root reference is also null unless the DisplayObject
    instance is a child
    of a display list attached to the stage. For timeline scripts
    within a Flash
    FLA, however, where the movie clip is added to the screen
    within the Flash
    environment, root is always available.
    A good practice for globally accessible functions, however,
    would be to
    define your functions as static methods in a class. Then you
    can reference
    those functions anywhere from any object (even non
    DisplayObject instances)
    using ClassName.functionName()
    RESPONCE:
    Ummm... I named my document class main, thinking that might
    help me refer to it from child clips, but it didnt. Using root
    seems to refer to main, but then I cant refer to anything on the
    stage, or any function written there. From reading the help I got
    the impression that function defined in the root timeline would
    become publicly accessable functions that could be accessed with
    dot notation. Is this not the case?
    When I trace root, or main, it outputs [object main]. So then
    thats the class... Why cant I refer to the functions of that class
    from another movie?
    Are you suggesting I write a document class with my functions
    in it? could I still refer to objects on the stage if I do that.
    I've read over these subjects alot in the documentation and its
    really not clear... perhaps someone could write a tutorial.

    _root in AS3 is now simply root (no underscore). The root
    property,
    however, is only available to DisplayObject instances, not
    other classes.
    The root reference is also null unless the DisplayObject
    instance is a child
    of a display list attached to the stage. For timeline scripts
    within a Flash
    FLA, however, where the movie clip is added to the screen
    within the Flash
    environment, root is always available.
    A good practice for globally accessible functions, however,
    would be to
    define your functions as static methods in a class. Then you
    can reference
    those functions anywhere from any object (even non
    DisplayObject instances)
    using ClassName.functionName()
    "smazr123" <[email protected]> wrote in
    message
    news:f29rrb$4nl$[email protected]..
    > I'm very suprised I theres not an obvious answer to this
    question to be
    > found.
    > In AS 2 I would often write most of my code in the main
    timeline, and then
    > refer to it from various other movies etc. I dont seem
    to be able to do
    > that in
    > AS 3? how can I do it in AS 3?
    >
    > For example if i had a function on the main timeline,
    and wanted to call
    > it
    > from the code in another movie. In that past I would
    have just used
    > _root.functionName();
    >

  • What is a Root Timeline?

    Hello All
    I'm using CS3 (Mac) and I just bought a book on Actionscript (first timer with AS). What is a "root timline" and where is it at? For example the author says: "Since you've attached your script to the root timeline", and I'm thinking to myself, "I did?", where is it? LOL. I just made a car go from the left side of the stage to the right side with the car shaking and vibrating, and I did good with that. But I have no idea where this root timeline thing is at? Can anyone help me with this?
    Thanks
    Why_atl

    the root timeline is the main timeline.  it's the timeline you see when you open a newly created fla file.

  • Accessing Root Timeline Button

    Hi,
    I think this is a fairly basic thing to do, but I can't seem
    to figure it out. I have a movie clip(
    mc1) with a button(
    btn1) and a movie clip(
    mc2) in it. The button plays this second embedded movie
    clip(
    mc2). In this second movie clip(
    mc2), I have a button(
    btn2) that, when clicked, I would like to cause the first
    button(
    btn1) (on the root timeline) to disappear. Is this possible,
    and if so, could you help me figure out how to do so?
    Thank you,
    Brad
    EDIT: Just so its easier to visualize, here's a hierarchy of
    the relevant elements:
    mc1
    btn1
    mc2
    btn2

    Thank you kglad.
    Unfortunately, I'm not 100% sure what you're suggesting. Are
    you saying I should test to see if the btn2 will respond to a click
    using hitTest? If so, I already know that I can click on btn2
    because I have some actionscript that runs when I click it, and
    that particular part of the code is functional. However, I'm not
    sure what actionscript will allow me to modify btn1 when I click on
    btn2. One snippet of code that I tried (but didn't work) was:
    btn2.onRelease = function(){
    _root.btn1._alpha = 0;
    I'm guessing I'm doing something either wrong, or not
    possible, but I'm still pretty new to actionscripting, so I
    couldn't tell you. Anyway, thank you again, and I look forward to
    your response.
    -Brad

  • Can I have an array of controls without having them in the array front panel holder?

    I would like to link a number of boolean control buttons in an array without grouping them on the front panel the way it does when you make an array and then put in a boolean control.
    Here's the background:
    I have 8 linear motors controlled by CANbus, and so each button type (Move, Stop, Home, etc) is duplicated 8 fold.  I have an event structure that is currently triggered with a separate case for EVERY button with only a very small difference in the code inside each case.  Ideally I could have the buttons in arrays and then check the new array value against the old value on a value change event.  The alternative for me is to have each case handle the 8 buttons (with a Mouse Down? filter event) and then use the Boolean.Text value from the CtlRef and search an array of all Boolean.Text Values for the 8 buttons to see which name matches and process accordingly.  I have something like 200 buttons, so making the arrays of Boolean.Text values from the reference nodes is WAY too time consuming as I have to go through like 5 levels of right click menus.  Any suggestions?  

    Mark,
    You might consider using clusters on the front panel.  Create a type def'd cluster that has all the boolean controls for 1 channel.  You can drop 8 of these on the front panel and the event structure can detect a change in a cluster.  Easy to convert cluster to array behind the scenes.  Remember that order of cluster determines index of value in array.
    Message Edited by Wayne.C on 04-09-2010 05:19 PM

  • Using an mc to control the main timeline with multiple scenes

    OK, I have a main timeline that has 27 different scenes.  I have a movie clip that is an "on call" navigation menu for the main timeline.  I can call the menu once, and it will go to the first place I want it to go.  However, I cannot seem to figure out how to get it to go away to be able to call it again.  I get the "must be child of caller" error.  Any thoughts on how to get rid of it each time I use it?

    A button is clicked which calls the following AS3 code:
    MovieClip(this.root).addChild(myMenu);

Maybe you are looking for

  • How can I change my apple ID email address?

    How can I change my apple ID email address?

  • IPhoto won't export photos

    I was using iPhoto to edit some RAW photos I took today. Several times iPhoto stopped responding, the color wheel just spun until I did a forced quit. After about the third time of this, while I was exporting the edited photos as jpegs. I got a messa

  • Unable to find wireless HP5510 printer

    I have had a HP5510 Photosmart printer for over 6 months.  Until last week it was working well and used as a wireless printer from my iMac.  For some reason the wireless connection to my iMac stopped working.  I unistalled the driver, downloaded the

  • Trying to get a 64-bit virtual machine on a G505s

    Hey I'm a little lost in trying to figure out how to make a  64-bit guest on my  G505s Hyper-V, seems to be a problem, but I don't have it installed. I'm not sure what amd-v is, but I don't have avirtualization tab options in my bios. I'm guessing I

  • Completely erased iPod, still 3.3 GB of other!

    I have a 4th gen, 8 GB iPod Touch, it's about two years old. Over half my memory was being used by Other, so after trying all these different suggestions and failing, I restored it to factory settings. Everything has been erased and it still has 3.3