A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: How do I access buttons nested within Movie Clips?

  1. #1
    Junior Member
    Join Date
    Sep 2008
    Posts
    24

    Smile How do I access buttons nested within Movie Clips?

    Hello,

    And thanks to everyone who has helped me work through a project far faster than I could have done on my own.

    This is I hope a simple query.

    Essentially, I'm trying to recreate something I've seen on the MediaStorm website a scrolling banner of images, each of which acts like a button to click through to a video player that I've managed to find.

    Anyway, the way I've tried to do it is to create a series of nested movieclips; the first is a two-layered movieclip in the library (which I've called fence) containing all of the pictures as profiles on one layer, and then a second layer on which I've laid a button overlay.

    The fence movieclip is then nested into a movieclip called doublefence so that I can scroll it with the mouse. That bit, thanks to help from sstalder, now works.

    I had planned to just create an event handler for the button overlays and then convert some old as2.0 code to create the onRelease rollOver and rollOut behaviours.

    However, I realise from the error codes that I'm getting that there is no access to the button overlays from within their double-nested MovieClips.

    Is there a way of getting access to the overlays. It looks as though it is something to do with mouseChildren and mouseEnabled, but I just can't work it out.

    Thank you for listening, and here is the code:
    PHP Code:
    stop();



    profilesMC.mouseEnabled false;
    profilesMC.mouseChildren false;

    arthurMitchell.mouseEnabled true;
    arthurMitchell.mouseChildren true;
    arthurMitchell.addEventListener(MouseEvent.MOUSE_OVERmouseOverHandler);
    arthurMitchell.addEventListener(MouseEvent.MOUSE_OUTmouseOutHandler);
    arthurMitchell.addEventListener(MouseEvent.MOUSE_DOWNamitchellVideo);

    function 
    mouseOverHandler(e:MouseEvent):void
    {
        
    arthurMitchell.alpha 0;
    }

    function 
    mouseOutHandler(e:MouseEvent):void
    {
        
    arthurMitchell.alpha =40;
    }

    function 
    amitchellVideo(e:MouseEvent):void
    {
        
    gotoAndStop("atkins");
    }

    import flash.display.MovieClip;
    import flash.events.Event;

    profiles_mc.addEventListener(Event.ENTER_FRAMEprofilesEnterFrame);

    function 
    parallax(layer:MovieClipspeed:Number):void
    {
        var 
    distance:Number = (mouseX - (stage.stageWidth 2));
        
        if (
    mouseX > (stage.stageWidth 2))
        {
            
    layer.-= (distance speed);
        }else{
            
    layer.+= distance * -speed;
        }
        
        if (
    layer.<= 0)
        {
            
    layer.layer.layer.width 2;
        }else if(
    layer.>= layer.width 2){
            
    layer.layer.layer.width 2;
        }
    }

    function 
    profilesEnterFrame(e:Event):void
    {
        
    parallax(e.target0.025);

    This code generates the following error:

    ReferenceError: Error #1065: Variable arthurMitchell is not defined.
    at Remembrance5_fla::MainTimeline/frame1()


    The full package is here


    Thank you for listening.

  2. #2
    Flactionscrish Baby Minion's Avatar
    Join Date
    Nov 2005
    Location
    Planet Earth
    Posts
    312
    That reference error is saying, that in the scope you are in (timeline) there is no arthurMitchell object.

    Where is the arthurMitchell object located?
    If it is nested, you may not be referencing that object properly.
    ktu[k-two]
    he who hesitates is lost; so i guess i'll wander intently

    Are you sure this is real?
    Life is Love, Love is Blind, Blind we go through Life.
    Life isn't hard, dealing with your self is.

    The concept of life in a human brain is weakening day after day. Live every day like its your last. Take the chances, and opportunities, and never let authority push you around for fun.


  3. #3
    Junior Member
    Join Date
    Sep 2008
    Posts
    24
    I thought that was the case, but I wasn't then sure how to reference the movieclip. I tried

    ProfilesMC.fence.ArthurMitchell (event handler code) but that didn't work.

    Should it be ProfileMC.doublefence.fence.ArthurMitchell (event handler code)?

  4. #4
    Junior Member
    Join Date
    Sep 2008
    Posts
    24
    I've almost sorted it, but not quite. Baby Minion's help allowed me to suss the scope issue, and the code below does activate the rollover, rolloff and button click functionality. But then it stops working altogether.

    I'm not sure why, though. Any offers?

    PHP Code:
    stop();



    profilesMC.mouseEnabled true;
    profilesMC.mouseChildren true;

    profilesMC.fence.mouseEnabled true;
    profilesMC.fence.mouseChildren true;

    profilesMC.fence.arthurMitchell.mouseEnabled true;

    profilesMC.fence.arthurMitchell.addEventListener(MouseEvent.MOUSE_OVERmouseOverHandler);
    profilesMC.fence.arthurMitchell.addEventListener(MouseEvent.MOUSE_OUTmouseOutHandler);
    profilesMC.fence.arthurMitchell.addEventListener(MouseEvent.MOUSE_DOWNamitchellVideo);

    function 
    mouseOverHandler(e:MouseEvent):void
    {
        
    profilesMC.fence.arthurMitchell.alpha 0;
    }

    function 
    mouseOutHandler(e:MouseEvent):void
    {
        
    profilesMC.fence.arthurMitchell.alpha =.4;
    }

    function 
    amitchellVideo(e:MouseEvent):void
    {
        
    gotoAndStop("atkins");
    }

    import flash.display.MovieClip;
    import flash.events.Event;

    profilesMC.addEventListener(Event.ENTER_FRAMEprofilesEnterFrame);

    function 
    parallax(layer:MovieClipspeed:Number):void
    {
        var 
    distance:Number = (mouseX - (stage.stageWidth 2));
        
        if (
    mouseX > (stage.stageWidth 2))
        {
            
    layer.-= (distance speed);
        }else{
            
    layer.+= distance * -speed;
        }
        
        if (
    layer.<= 0)
        {
            
    layer.layer.layer.width 2;
        }else if(
    layer.>= layer.width 2){
            
    layer.layer.layer.width 2;
        }
    }

    function 
    profilesEnterFrame(e:Event):void
    {
        
    parallax(e.target0.025);


  5. #5
    Junior Member
    Join Date
    Sep 2008
    Posts
    24
    Another update:

    You will see that the first section works, to a point, but because of the nested videoclips of fence and doublefence that there are times when the buttons don't work. Also the buttons are opaque black when the package is run - which is not as I planned it.

    There are more problems in the second piece of code:

    The second piece of code is taken from the video player tutorial on http://www.gotoandlearnforum.com which although it works when the stop() function is taken off the first frame of actionscript, it throws out an error:

    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at Remembrance9_fla::MainTimeline/mouseOutkenBettany()

    I'm not sure what this means or how to fix it, can anyone help?

    The latest update is here

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