Using an array to assign movie clips to buttons

Thanks in advance for any help you can give me!!
I've got 5 movie clip buttons.  When a user rolls over a button, I want one movie clip to play. When a user clicks on that button, an alternate movie clip plays. I'm trying to use an array to assign certain movie clips to certain buttons and actions, but I'm not doing something quite right. I can get one button to work correctly, but then am having issues getting the other buttons to work.
Here is the code I have:
var currentPage:MovieClip;
var currentScreen:MovieClip;
var prevPage:MovieClip;
var currentButton:MovieClip;
var arrNavigation:Array = [{button:m1_mcButton, page:m1_mc, screen:s1_mc},
   {button:m2_mcButton, page:m2_mc, screen:s2_mc}]
for(var i=0;i<arrNavigation.length;i++){
arrNavigation[i].button.buttonMode=true;
arrNavigation[i].button.addEventListener(MouseEvent.ROLL_OVER, onButtonOver);
arrNavigation[i].button.addEventListener(MouseEvent.ROLL_OUT, onButtonOut);
arrNavigation[i].button.addEventListener(MouseEvent.CLICK, onButtonClick);
function onButtonOver(e:MouseEvent):void
for(i=0;i<arrNavigation.length;i++) {
if(arrNavigation[i].button == e.currentTarget)
currentPage = arrNavigation[i].page;
currentPage.gotoAndStop("over");
function onButtonOut(e:MouseEvent):void{
currentPage.gotoAndStop("out");
function onButtonClick(e:MouseEvent):void{
for(i=0;i<arrNavigation.length;i++) {
if(arrNavigation[i].button == e.currentTarget)
currentScreen = arrNavigation[i].screen;
arrNavigation[i].screen.gotoAndPlay("over");

if your buttons are movieclips, use:
var currentPage:MovieClip;
var currentScreen:MovieClip;
var prevPage:MovieClip;
var currentButton:MovieClip;
var arrNavigation:Array = [{button:m1_mcButton, page:m1_mc, screen:s1_mc},
   {button:m2_mcButton, page:m2_mc, screen:s2_mc}]
for(var i=0;i<arrNavigation.length;i++){
arrNavigation[i].button.buttonMode=true;
arrNavigation[i].button.addEventListener(MouseEvent.ROLL_OVER, onButtonOver);
arrNavigation[i].button.addEventListener(MouseEvent.ROLL_OUT, onButtonOut);
arrNavigation[i].button.addEventListener(MouseEvent.CLICK, onButtonClick);
arrNavigation[i].button.ivar=i;
function onButtonOver(e:MouseEvent):void
currentPage = arrNavigation[e.currentTarget.ivar].page;
currentPage.gotoAndStop("over");
function onButtonOut(e:MouseEvent):void{
currentPage.gotoAndStop("out");
function onButtonClick(e:MouseEvent):void{
currentScreen = arrNavigation[e.currentTarget.ivar].screen;
currentScreen.gotoAndPlay("over");

Similar Messages

  • Movie clips as buttons

    Hi all having a bit of difficulty with a project,
    Iam using movie clips as buttons, the only function they
    perform is loading in external swf files into a blank movie clip.
    The script I have used for this is as follows:
    on (release) {
    loadMovie("folio.swf", "_level0.holder");

    Hi joakimpilo, im not to sure im following your question
    correctly but here goes...
    I am assuming b1, b2, b3 and b4 are your MC buttons and you
    want these to load in information.
    This is what I do for similar situations,
    on your main timeline have an MC named holder that you will
    load external swf files into when you click a certain button. It is
    important that you take a note of the size so you can create the
    external swf at the same size, so when they load in they fit
    correctly.
    then in the buttonMC have a top layer that contains a simple
    box that covers the entire area of the MC. this kind of acts as a
    hit area so if you have animated the MC for a roll over effect make
    sure the button covers the area you need. I then apply the script
    to this button as follows (still in the buttonMC, not on main
    timeline)
    on (release) {
    loadMovie("yourexternalmovie.swf", "_level0.holder");
    "yourexternalmovie.swf" is the name of the external movie
    holding the informatiion you want loaded in to the "holder" MC.
    This is created in an entirely different flash document. Make sure
    and remember the name of these external files and just apply to
    each button.
    It is also very important to keep all the swf files in the
    same folder as the main flash file so it can see them to import.
    Hope that makes some sort of sense, and is actually what your
    looking for.

  • Movie Clips as buttons – ignoring my stop actions and event listeners

    Ok, so I think I am hear with the proper linked files to show you guys! Pretty much learning everything, so forgive my ignorance thus far!
    Anyway, I am just trying to figure out movie clips as buttons, and have been following along on Lynda.com – however, I seem to be doing these things right, but when i test my movie, the button just loops regardless of rollovers or stop actions.
    You can check this address www.midnyc.com to see the failed anim, and you should be able to import it as well. Here is my coding:
    function rollover (e:EVENT){
        myBtn.gotoAndPlay ("in");
    myBtn.addEventListener (MouseEvent.MOUSE_OVER, rollover);
    function rollout (e:EVENT){
        myBtn.gotoAndPlay ("out");
    myBtn.addEventListener (MouseEvent.MOUSE_OUT, rollout);
    thank you in advance for your help. And to KGLAD, thanks for recommending how to post a bit better! Since I never had links etc... sorry about that.

    Do you get any kind of error messages?  Normally if there's a coding error, movieclips and other things go haywire.
    For you event handler functions, try specifying the event that matches the listener event...
    function rollout (e:MouseEvent){
    I think "EVENT" would be wrong anyways... "Event" would be correct

  • Help - Using Cue Points to Play Movie Clips

    I have a FLV, into which I have placed about 8 cue points. I
    want a movie clip to play - (each movie clip is simply a snippet of
    supporting text for the video) - when a cue point is "hit". I am
    really quite baffled by most of the documentation that I have read
    so far.
    How can I do this? Many, many thanks for any support you can
    give.
    tommy53

    You can build out a menu by reading the cuePoints array in
    the NetStream.onMetadata handler, or by using the MetadataEvent
    with the FLVPlayback component (AS3). The simple thing for me to
    say is to refer to Chapter 9 of my new Flash Video book. :) (see
    link in my signature below.)

  • Using cue points to acrivate movie clips

    I'm trying to write a simple piece of ActionScript that I can
    adapt and re-use easily. (I'm not very good at programming and I've
    been finding the "help" information very confusing.) I've devised
    quite an elegant solution, if only I could get it to work!.
    I'm using a single frame loop with an onEnterFrame
    construction that deletes itself when the flv has finished playing.
    I've set up a movie clip with various start points for animations
    to be activated at cue points. I'm testing for the cue points in
    the same frame, storing previous cue point names so that each cue
    point triggers the corresponding animation once only. I know the
    main logic works because I've tested it with trace statements to
    prove that the cue points are actually being reached. The problem
    is that the goToAndPlay instructions don't seem to activate the
    movie clip as intended.
    My best guess is that the stop action on the self-looping
    frame is also stopping the movie clip as soon as it starts. Even if
    that is true, I don't know how to solve the problem. And I'm sure
    one of you much more clever people will know better. Here's the
    code. Any suggestions?

    You can build out a menu by reading the cuePoints array in
    the NetStream.onMetadata handler, or by using the MetadataEvent
    with the FLVPlayback component (AS3). The simple thing for me to
    say is to refer to Chapter 9 of my new Flash Video book. :) (see
    link in my signature below.)

  • How do I use a variable to set movie clip properties?

    I'm building a simple contact page that allows users to
    select a city from a comboBox. I'd like to pass the selected
    comboBox data through a variable that controls a movie clip with
    the same name. (already on the stage)
    locationListener.change = function (loc_obj:Object) {
    var loc_mc = loc_obj.target.selectedItem.data;
    loc_mc._visible = true;
    So far this hasn't worked. I've tested hardcoding the movie
    clip instance name (Atlanta._visible = true) and it works, but I
    can't figure out why using the variable loc_mc won't trigger
    interaction with the movie clip.
    Something simple, I assume. Thanks in advance for any
    help.

    clbeech:
    I tried using your suggestion, but for some reason it doesn't
    recognize it as naming the movie clip instance. I traced the
    variable and confirmed that the correct value (Atlanta) is being
    passed.
    I assume this is because the variable is not declared as a
    MovieClip, but I can't figure out how to convert it inside the
    function.

  • Using movie clips as buttons

    I dont ever use buttons because movie clips appear to do all
    of the same stuff with the same code.
    so in my set up i have a "video" section that, when you "roll
    over" it expands and reveals some video thumbnails. i want it so
    when you click the video thumb that a page will open on the right
    side. i have all the "on release" code set up but it still wont
    work???? i think that the expanding window is all worried about
    waiting for the "roll out" to happen so the buttons cant be
    clicked.
    how do i have it so that the movie clip does its roll in roll
    out stuff but dosent change your courser into the little hand and
    finger like its a button?
    NOTE: the "korath" article has the same type of code as the
    thumbnails (except for the different target object)
    oh and should i be using "relative" or "absolute" for the
    target object???
    there is the example at
    www.wafflecone.ca
    i couldnt upload the full fla cuz its 15 MB!

    uhmmm well this is all getting a little confusing.
    i havent used this kind of code before and it hasent worked
    in the few places iv tried (I replaced the "movieclipname" text)
    the best way is too look at the fla....heres a link
    http://www.mediafire.com/?zlld2j0mxxj
    i know that the movie clips can be confusing, im still
    learning on how to set everything up.
    -double click on the "video" box on the left side
    -move the timeline to 20
    -"click the "video" box once
    that is where i have been putting most of the code.
    you can go further into the "video" box where there is more
    movie clips.
    masking
    than where the thumbnails are.
    hope you can take a look at it.

  • Using one instance of a Movie Clip to load Graphics from library

    Hi all,
    another question... How would i go about loading a variable into a movie clip and have it pull different graphics from my library at different spots in the main timeline???
    thanks!
    Patrick

    Hi NED! thank you for all your help so far!!!
    I was wondering about the flexability of loading movies into a movie clip.
    Currently, thanks to your help i am well able to load one movie into a movie "loader" clip, but thought maybe there is a way to load additional movie clips into that same "loader" clip, as i am starting to accumulate several different graphics that i need to have be inside movie clips so that i can make them change colors on the same frame when needed.
    i shot from the hip and tried this code, but didnt have any luck:
    mc_LCD_loader.attachMovie("hilight", "g", 1), ("header", "X", 1);
    mc_LCD_loader.g._x = 0;
    mc_LCD_loader.g._y = 1000;
    mc_LCD_loader."X"._x = 0;
    mc_LCD_loader."X"._y = 1000;
    - - - where "hilight" is the identifier name of a given movie clip and "header" is the identifier of a given movie clip in the same library...
    "hilight" loads fine
    i dont fully understand what "g" means to the identifier...
    i am just unsure of how or if it is even possible to load another MC into the same MC Loader...
    is it possible? if so could you give me a hint?
    thank you!
    - patrick

  • Using Events To Play Another Movie Clip

    Dear Readers:
    I have a set of buttons in my flash movie that, when a mouse
    cursor passes over it, another movie clip on the stage causes a
    layer with text to gradually appear from below. It pops up, so to
    speak, and eventually stops, displaying the text related to the
    button in full view.
    Passing over a different button causes the text layer to move
    downward, slowly disappear off the stage, then reappear in the same
    manner with text associated with that latest button. Its fairly
    simple and works fine, as long as the user waits patiently for the
    text layer to scroll down and back up before passing over another
    button. See code below.
    However, if the user decides to quickly pass over multiple
    buttons (before the text layer reaches the top), the event handler
    is coded such that if the mouseover event occurs BEFORE the text
    layer reaches the top, the text layer starts over at the bottom, so
    the transition is not smooth. Imagine the text layer just about to
    reach the top, when the mouseover event occurs, now the text layer
    starts over from the bottom. Very choppy.
    I'd like to grab the current frame of the text layer movie
    clip when the mouseover event occurs, and have the layer move back
    down from there, reach the bottom, then come back up, rather than
    starting from the bottom. Any help in coming would be great. Thanks
    in advance.

    yourI = setInterval(f,t) starts a loop. it repeatedly calls
    the function f() every t milliseconds until a clearInterval(yourI)
    is executed.
    the most common problem that occurs with setInterval() is
    executing it twice (or more) with no intervening clearInterval().
    when that happens all hell breaks loose and the swf will call the
    function much more rapidly than intended and can not be (easily)
    stopped no matter how many clearInterval() statements you try and
    execute.
    the easiest way to prevent that problem is to execute a
    clearInterval() just BEFORE all setInterval() statements. it
    doesn't hurt anything to (try and) clear and interval that doesn't
    exist and occasionally it'll stop the seemingly bizarre problems
    that occur with out-of-control intervals:
    clearInterval(yourI);
    yourI=setInterval(f,t);

  • Changing depths of movie clips with button clicks

    Hello all,
    I've got a file on working on that has 4 different movie clips on one layer that, when clicked, will zoom in (made with tweens in the timeline).
    The issue I'm having, is that when I click one of them, they are arranged in a way that won't work for what I need. I click one, and it works, but it is hidden by the movie clip that is on top of it in the heirarchy. Click another, zooms in, but is partially hidden by another one.
    My question is: Is there anyway in AS2 to code these so that when one is clicked, it will the top spot in the heriarchy? So that I can code them all like this so that whenever one is clicked, it goes to the top so it is not hidden?
    Thanks

    Correct me if I'm wrong, but isn't that just used to swap 2 movie clips?
    Or is there a number I can input instead of the movie clip name that will change all of them?

  • Noob help: Triggering Movie Clips with Buttons

    Hi guys,
    I'm taking an intro Flash and Action Script class and for my final I need to create a portfolio project that contains 5 unique buttons that trigger 5 unique movie clips. I'm having a hard time with this. I've been able to trigger the 1st movie clip with the first button (although I can't stop it) but I can't trigger any ohter movies with any other buttons.
    Here's my code:
    stop();
    chuck1_btn.addEventListener(MouseEvent.CLICK, playMovie);
    function playMovie(event:MouseEvent):void
        spaceship_mc.play();
    chuck2_btn.addEventListener(MouseEvent.CLICK,playSaucers);
    function playSaucers(event:MouseEvent):void
        saucers_mc.play();
    Nothing happens when I click on chuck2_btn when I test the movie. I think I need to create a variable or class but I'm not sure. I'm a super noob with this stuff. Any thoughts? Thanks!
    Rick

    You should learn how to use the Help documentation to find answers like how to use the visible property.  For the code you showed earlier, here's what you can try in frame 1 to replace it.
    stop();
    spaceship_mc.visible = false;
    saucers_mc.visible = false;
    slideshow_mc.visible = false;
    chuck1_btn.addEventListener(MouseEvent.CLICK, playMovie);
    function playMovie(event:MouseEvent):void
         spaceship_mc.visible = true;
         saucers_mc.visible = false;
         slideshow_mc.visible = false;
        spaceship_mc.play();
    chuck2_btn.addEventListener(MouseEvent.CLICK,playSaucers);
    function playSaucers(event:MouseEvent):void
         spaceship_mc.visible = false;
         saucers_mc.visible = true;
         slideshow_mc.visible = false;
        saucers_mc.play();
    etc...
    It could be refined, like having a function that hides everything and using that every time before making the one you need to show visible.  You might find it necessary to include telling the movies to gotoAndStop(1) as well.
    That's about as generous as I'm going to get.  It's important that you learn things, and handing you a solution isn't going to help do that.

  • Attaching movie clips to buttons

    I would like to design a portfolio site in which I have small
    buttons that, when moused over, they display, a pic just above it.
    Each button triggers a different pic above it.

    The best way to go about doing is is to use the MovieClip
    class instead of the button class. Use the onRollover event. For
    example, have a movie clip that displays the image on the second
    frame. The use the actionscript: nameOfMovieClip.onRollover =
    function():Void {
    this.gotoAndStop(2);
    If you want to use the button class to accomplish the same
    task, then you will have to create an image that you want to
    display then under the "over" frame of the button, place the image.
    If you want the original image to be there and display the new
    image, then just add a new layer and put the image in the new layer
    while keeping to original layer.

  • How to change the movie clip a button links to???

    I am working on a website in Flash that had already been
    designed by someone else. There are a number of buttons across the
    website that are linked to the same symbol. Those buttons link to
    movie clips, in the button's actions, that pop up as small windows
    providing more information in regards to the button clicked. The
    problem is that I cannot figure out how to properly change the link
    association between button and movie clip.
    Here is the action script for one of the buttons:
    on (release) {
    _root.scrHEIGHT=100
    _root.scroller.scroller.gotoAndStop(2);
    _root.scroller._x = 100;
    _root.scroller._y = 150.7;
    _root.TM_title = "About Chris Smith";
    _root.READ = 3;
    When I change the number after "root.READ =" it will change
    it to another movie clip but I how do I know what that association
    is based on? For instance if I make a duplicate movie clip how can
    I make the above script link to it? Also, what exactly does that
    last line in the above script mean? When I tested various numbers,
    like 3 and 6, they would link to the same movie clip.
    Please help! This is driving me crazy!
    Thanks!!!

    Hi,
    buttons can be defined with static icon/text, or dynamically via a variable (containing @08\Qtooltip@text for example). You choose the pushbutton type when you define your button using the screen painter. For the dynamic definition, you must tick the "output only" checkbox, enter a global variable name, that you'll fill in your program, preferably using ICON_CREATE function module.
    BR
    Sandra

  • Access Movie clip inside Button

    Is there a way to access a movie clip inside a buttion?
    I have a bunch of images in a movie clip, and I want to have the same mc to change frames in different button symbols. But when try to talk to it myButton.myMovieClip.gotoAndStop(3);
    It gives me and error.
    1119: Access of possibly undefined property myMovieClip through a reference with static type flash.display:SimpleButton.

    no.
    use a movieclip button.

  • Movie clip as button label

    Hi,
    I need to place a lot of buttons in the scene with different labels. I have created one button (not ui component). It is having custom look and feel. And I have placed many of the instances of this button in the scene.
    Now I need to add different labels two each button. These labels are not simply some texts, but movie clips.
    So how can I place these labels to each button? Placing an empty movie clip and calling attachMovie in action script failed...
    I am not sure how to achieve my requirement. If needed, I can give more explanation about the requirement.
    Thanks in advance.

    Thank you for the reply.
    But I am not sure how to add the movieclip holder (with which I call .attachMovie) to the button. If I add it the UP location of the button, I cannot access it. What I need to do is attach the movieclips in the Library (with Linkage ID specified) to each buttons from the scene using AS.
    Example:
    In action script,
    myBtn1.myLabel_mc.attachMovie( "myLabelClip1_ID", ........ );
    myBtn2.myLabel_mc.attachMovie( "myLabelClip2_ID", ........ );
    So could you please suggest me a little more better?

Maybe you are looking for

  • Channel Guide not Full Screen

    Since the new update for the FIOS cable box, the channel guide will not fill the screen. I did some research and found that it is because I have one of the older models of cable boxes. I called Verizon and the supprt tech told me that I could order a

  • Oracle IDS Version problem (IDS is not compatible )

    Please address my technical query mentioned below. We are facing problems while porting/deploying our application on the Oracle 10g application server. The application server version is 10g R-2 (64bit)(10.1.2.0.2), the IDS version is 10g (9.0.4) and

  • After auto update to Widows 8.1, my office 2013 is not working.

    FOLLOWING ERROR IS SHOWN ON OPENING OF ANY EXCEL OR WORD FILE. "THE UPDATE PACKAGE COULD NOT BE OPENED. VERIFY THAT THE UPDATE PACKAGE EXISTS AND THAT YOU CAN ACCESS IT, OR CONTACT THE APPLICATION VENDOR TO VERIFY THAT THIS IS A VALID WINDOWS INSTALL

  • How to use spry in the dreamweaver with the php/mysql

    hello, Iam new to the spry framework and i want to know can we use the spry in the dreamweaver along with php / mysql code if so please tell how to do this thanks in advance

  • Which is better as UI technology among Flex and Oracle ADF for oracle SOA suit

    We have one application which is using oracle's Service oriented Architecture (SoA) suite. Currently, there is a debate on the technology for UI in the new architecture that will be rich, easy to maintain, scalable and integrates well with SOA suite.