A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Nested movie clip button to go to and play a frame in another movie clips frame

  1. #1
    Junior Member
    Join Date
    Apr 2015
    Posts
    9

    Nested movie clip button to go to and play a frame in another movie clips frame

    I have a flash file that needs 2 menus with buttons linking to frames in one movie clip timeline. This is an exercise to build an app interface and I am using
    a left and right menu to allow for left and right handed users so the menu links are the same. I've messed around trying to keep instances and functions
    with different names and can get the left menu to work great but the right menu slides out but the buttons don't work.

    Below is a link to the fla, please someone help as I am a newbie with actionscript and it has to be as3. I need ot get this working for a college deadline.

    https://drive.google.com/file/d/0B7n...ew?usp=sharing

    Thanks everyone

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    I have looked at your file and done something a tad different for you.

    I have renamed the button/clips inside menuright_mc to the same names as menu_mc button/clip names.

    and used this code instead of your code, basically both set of buttons use the same functions, less code.

    PHP Code:
    stop();

    //file downloaded from www.riacodes.com
    import com.greensock.TweenLite;
    import com.greensock.easing.*;
    import flash.display.MovieClip;

    var 
    i:int;
    var 
    buttonArray:Array = ["home_mc""origins_mc""scrolls_mc" ,"weapons_mc""quiz_mc"];

    menu_mc.addEventListener(MouseEvent.ROLL_OVER,showMenu(menu_mc,0));
    menu_mc.addEventListener(MouseEvent.ROLL_OUT,hideMenu(menu_mc,menu_mc.x));

    menuright_mc.addEventListener(MouseEvent.ROLL_OVER,showMenu(menuright_mc,885));
    menuright_mc.addEventListener(MouseEvent.ROLL_OUT,hideMenu(menuright_mc,1090));

    for (
    0buttonArray.lengthi++)
    {
        
    menu_mc[buttonArray[i]].buttonMode true;
        
    menu_mc[buttonArray[i]].addEventListener(MouseEvent.CLICKshowContent(1));
        
        
    menuright_mc[buttonArray[i]].buttonMode true;
        
    menuright_mc[buttonArray[i]].addEventListener(MouseEvent.CLICKshowContent(1));
    }

    function 
    showContent(arg:Number):Function
    {
        return function 
    showContent(event:MouseEvent):void
        
    {
            
    content_mc.gotoAndStop(arg);
        }
    }

    function 
    showMenu(clipToDo:MovieClip,destinationX:Number):Function
    {
        return function(
    event:MouseEvent):void
        
    {
            
    TweenLite.to(clipToDo.4, {x:destinationX,ease:Linear.easeNone});
        }
    }

    function 
    hideMenu(clipToDo:MovieClip,destinationX:Number):Function
    {
        return function(
    event:MouseEvent):void
        
    {
            
    TweenLite.to(clipToDo.4, {x:destinationX,ease:Linear.easeNone});
        }


  3. #3
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    Slight typo in that one, nothing to fuss about though, use this instead.
    PHP Code:
    stop();

    //file downloaded from www.riacodes.com
    import com.greensock.TweenLite;
    import com.greensock.easing.*;
    import flash.display.MovieClip;

    var 
    i:int;
    var 
    buttonArray:Array = ["home_mc""origins_mc""scrolls_mc" ,"weapons_mc""quiz_mc"];

    menu_mc.addEventListener(MouseEvent.ROLL_OVER,showMenu(menu_mc,0));
    menu_mc.addEventListener(MouseEvent.ROLL_OUT,hideMenu(menu_mc,-200);

    menuright_mc.addEventListener(MouseEvent.ROLL_OVER,showMenu(menuright_mc,885));
    menuright_mc.addEventListener(MouseEvent.ROLL_OUT,hideMenu(menuright_mc,1090));

    for (
    0buttonArray.lengthi++)
    {
        
    menu_mc[buttonArray[i]].buttonMode true;
        
    menu_mc[buttonArray[i]].addEventListener(MouseEvent.CLICKshowContent(1));
        
        
    menuright_mc[buttonArray[i]].buttonMode true;
        
    menuright_mc[buttonArray[i]].addEventListener(MouseEvent.CLICKshowContent(1));
    }

    function 
    showContent(arg:Number):Function
    {
        return function(
    event:MouseEvent):void
        
    {
            
    content_mc.gotoAndStop(arg);
        }
    }

    function 
    showMenu(clipToDo:MovieClip,destinationX:Number):Function
    {
        return function(
    event:MouseEvent):void
        
    {
            
    TweenLite.to(clipToDo.4, {x:destinationX,ease:Linear.easeNone});
        }
    }

    function 
    hideMenu(clipToDo:MovieClip,destinationX:Number):Function
    {
        return function(
    event:MouseEvent):void
        
    {
            
    TweenLite.to(clipToDo.4, {x:destinationX,ease:Linear.easeNone});
        }

    I had "return function showContent(", it should have been "return function("

    and menu_mc.x instead 0f -200;
    Last edited by fruitbeard; 04-26-2015 at 01:03 PM.

  4. #4
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    I've been busy as I had some time to kill, you could also do it like so.

    Again making sure all button/clips are named the same within each menu.
    PHP Code:
    stop();

    //file downloaded from www.riacodes.com
    import com.greensock.TweenLite;
    import com.greensock.easing.*;
    import flash.display.MovieClip;

    var 
    i:int;
    var 
    j:int;

    var 
    menuArray:Array = ["menu_mc","menuright_mc"]
    var 
    buttonArray:Array = ["home_mc""origins_mc""scrolls_mc" ,"weapons_mc""quiz_mc"];

    var 
    m1xa:Number 0;
    var 
    m1xb:Number = -200;

    var 
    m2xa:Number 885;
    var 
    m2xb:Number 1085;

    menu_mc.addEventListener(MouseEvent.ROLL_OVER,showMenu(menu_mc,m1xa));
    menu_mc.addEventListener(MouseEvent.ROLL_OUT,hideMenu(menu_mc,m1xb));

    menuright_mc.addEventListener(MouseEvent.ROLL_OVER,showMenu(menuright_mc,m2xa));
    menuright_mc.addEventListener(MouseEvent.ROLL_OUT,hideMenu(menuright_mc,m2xb));

    for (
    0menuArray.lengthi++)
    {
        for(
    0buttonArray.lengthj++)
        {
            
    this[menuArray[i]][buttonArray[j]].buttonMode true;
            
    this[menuArray[i]][buttonArray[j]].addEventListener(MouseEvent.CLICKshowContent(1));
        }
    }

    function 
    showContent(arg:Number):Function
    {
        return function(
    event:MouseEvent):void
        
    {
            
    content_mc.gotoAndStop(arg);
        }
    }

    function 
    showMenu(clipToDo:MovieClip,destinationX:Number):Function
    {
        return function(
    event:MouseEvent):void
        
    {
            
    TweenLite.to(clipToDo.4, {x:destinationX,ease:Linear.easeNone});
        }
    }

    function 
    hideMenu(clipToDo:MovieClip,destinationX:Number):Function
    {
        return function(
    event:MouseEvent):void
        
    {
            
    TweenLite.to(clipToDo.4, {x:destinationX,ease:Linear.easeNone});
        }


  5. #5
    Junior Member
    Join Date
    Apr 2015
    Posts
    9

    Cheers dude

    Thanks so much for all the effort I really appreciate it, I will go through your code and see if I can get my interface to work.

    Best regards

    Jason

    Quote Originally Posted by fruitbeard View Post
    Hi,

    I've been busy as I had some time to kill, you could also do it like so.

    Again making sure all button/clips are named the same within each menu.
    PHP Code:
    stop();

    //file downloaded from www.riacodes.com
    import com.greensock.TweenLite;
    import com.greensock.easing.*;
    import flash.display.MovieClip;

    var 
    i:int;
    var 
    j:int;

    var 
    menuArray:Array = ["menu_mc","menuright_mc"]
    var 
    buttonArray:Array = ["home_mc""origins_mc""scrolls_mc" ,"weapons_mc""quiz_mc"];

    var 
    m1xa:Number 0;
    var 
    m1xb:Number = -200;

    var 
    m2xa:Number 885;
    var 
    m2xb:Number 1085;

    menu_mc.addEventListener(MouseEvent.ROLL_OVER,showMenu(menu_mc,m1xa));
    menu_mc.addEventListener(MouseEvent.ROLL_OUT,hideMenu(menu_mc,m1xb));

    menuright_mc.addEventListener(MouseEvent.ROLL_OVER,showMenu(menuright_mc,m2xa));
    menuright_mc.addEventListener(MouseEvent.ROLL_OUT,hideMenu(menuright_mc,m2xb));

    for (
    0menuArray.lengthi++)
    {
        for(
    0buttonArray.lengthj++)
        {
            
    this[menuArray[i]][buttonArray[j]].buttonMode true;
            
    this[menuArray[i]][buttonArray[j]].addEventListener(MouseEvent.CLICKshowContent(1));
        }
    }

    function 
    showContent(arg:Number):Function
    {
        return function(
    event:MouseEvent):void
        
    {
            
    content_mc.gotoAndStop(arg);
        }
    }

    function 
    showMenu(clipToDo:MovieClip,destinationX:Number):Function
    {
        return function(
    event:MouseEvent):void
        
    {
            
    TweenLite.to(clipToDo.4, {x:destinationX,ease:Linear.easeNone});
        }
    }

    function 
    hideMenu(clipToDo:MovieClip,destinationX:Number):Function
    {
        return function(
    event:MouseEvent):void
        
    {
            
    TweenLite.to(clipToDo.4, {x:destinationX,ease:Linear.easeNone});
        }


  6. #6
    Junior Member
    Join Date
    Apr 2015
    Posts
    9

    It worked

    It worked flawlessly and I've learned an awful lot thanks to you.
    You have just made my day. I hope I can repay you at someday for this amazing help.

    Quote Originally Posted by jasonconway View Post
    Thanks so much for all the effort I really appreciate it, I will go through your code and see if I can get my interface to work.

    Best regards

    Jason

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center