A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: controlling movieClips using other movieClips

  1. #1
    Junior Member
    Join Date
    Dec 2005
    Posts
    21

    controlling movieClips using other movieClips

    Using Flash CS4 - AS 3.0

    I am goin nuts, trying to figure out how to control a movie clip using a separate movie clip.

    on scene 1 (2 frames long), i have 2 movie clips.
    -bFind (24 frames long)
    -textEffects (14 frames long)

    i want to jump to frame 7 of the textEffect movieClip when i hover over bFind

    i have my AS code in the first frame of the movieClip called "Bfind"
    Code:
    stop();
    
    addEventListener(
      MouseEvent.MOUSE_OVER,
      function(evt:MouseEvent):void {
      gotoAndPlay(1); //this works, it starts a hover effect
      root.textEffects(7); //this DOES NOT WORK
      }  
    );
    ERROR MSG:
    1061: Call to a possibly undefined method textEffects through a reference with static type flash.displayisplayObject.

    I have combed this message board and have tried a bunch of solutions with no luck.

    Thanks in advance

  2. #2
    Member
    Join Date
    Apr 2008
    Posts
    97
    Looks like your migrating from AS 2.0. Make sure both clips are on the main timeline and have instance names (example mc01 & mc02)
    Code:
    mc01.addEventListener(MouseEvent.MOUSE_OVER , controlClip)
    
    function controlClip(e:MouseEvent):void
    {
       mc01.gotoAndPlay(1);
       mc02.gotoAndStop(9); // you can call a function on mc02 if you want
       textEffect(7); //or call a function that will alter mc02
    }

  3. #3
    Junior Member
    Join Date
    Dec 2005
    Posts
    21
    Quote Originally Posted by FlashDevSD View Post
    Looks like your migrating from AS 2.0. Make sure both clips are on the main timeline and have instance names (example mc01 & mc02)
    Code:
    mc01.addEventListener(MouseEvent.MOUSE_OVER , controlClip)
    
    function controlClip(e:MouseEvent):void
    {
       mc01.gotoAndPlay(1);
       mc02.gotoAndStop(9); // you can call a function on mc02 if you want
       textEffect(7); //or call a function that will alter mc02
    }
    would this code go in frame one of Scene 1 (main timeline)?

    if so, should i be controlling all mc's and buttons from teh main timeline?
    Last edited by cjdevine; 11-20-2009 at 04:30 PM. Reason: additional info

  4. #4
    Member
    Join Date
    Apr 2008
    Posts
    97
    if that is where the movieclips are located then yes.

  5. #5
    Junior Member
    Join Date
    Dec 2005
    Posts
    21
    perfect. seems so simple. i like the way AS 3.0 has migrated to OOP, i just have to relearn the way i work within Flash. Any suggestions on some good tutorials? No matter the case, thanks for the help.

  6. #6
    Senior Member caroach's Avatar
    Join Date
    Nov 2002
    Location
    Chicago, IL
    Posts
    374
    If you need to use the timeline for AS, it's good practice to keep the "meat" of it on the root timeline. As you dig into AS3, you'll find that using a Document Class and a Class pattern will be much cleaner and easier to modify because everything is encapsulated. It's the way AS3 is intended to be used.

    However, I still use AS on the timeline for quick projects and I've found myself in similar situations. If you need to control a MC on the root or in the parent, you'll have to data type the root/parent as a MovieClip like:

    MovieClip(this.root).textEffects.gotoAndPlay(7); or
    MovieClip(this.parent).textEffects.gotoAndPlay(7);

    Using "root" or "parent" will return a DisplayObject or DisplayObjectContainer respectively. So, in order to access things like children or methods such as "gotoAndPlay", you have to data type that object as a MovieClip. You could also use:

    var mc:MovieClip = this.root as MovieClip;
    mc.textEffects.gotoAndPlay(7);

    The previous is just more of a shortcut to do the same thing. Of course, this isn't the recommended approach, but it will work in a crunch.

    Check out gotoandlearn.com for some good free video tutorials, or a great paid service is lynda.com. It's a bit pricey for a membership, but its a good investment.

    Hope that helps!
    moo

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