Solved

Transitioning between content MC's in AS3?

Posted on 2009-05-19
4
624 Views
Last Modified: 2013-11-11
Hi, im currently trying to make the jump from as2 to as3...which happens to be not so easy; who would have thought.So my question is:

i have multiple menu buttons on the stage: btn_home, btn_contact etc
and each btn relates to a content movie clip: mc_home, mc_contact ... these movie clips have  'animateON' & 'animateOFF' sections which are marked by frame labels inside the MC's.

when a menu button is pressed i need the current MC on the stage to play through its 'animateOFF' section, and on completion, the content MC relating to the menu button which was pressed to begin playing through it's 'animateON' section. This way the content MC's will seem to transition between each other.

Seems to me like a pretty generic question but as of yet i have not been able to find any tutorials or resources in regards to AS3?
Cheers.
0
Comment
Question by:simophat
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 9

Expert Comment

by:asaivan
ID: 24423533
What's your AS2 look like?  I can help translate.
0
 
LVL 39

Accepted Solution

by:
blue-genie earned 500 total points
ID: 24424991
Hi, first place to start would be to have a look at listeners.
what you need to do is have a variable to store what's currently playing.
then create a function that you can call from your menu buttons.

are you creating classes or are you doing everything on the timeline?
you'll need something along these lines

import flash.events.MouseEvent;

var currentMovieClip:MovieClip;
btn_home.addEventListener(MouseEvent.CLICK, doItem);

function doItem(ev:MouseEvent):void
{
            home_mc.gotoAndPlay("animateOff");
}
0
 

Author Comment

by:simophat
ID: 24428049
Thanks for your help guys, i found a tutorial on dorklessons.com (for real) and the script read as below.

Also on the last frame inside each content MC (ie. menu1, menu2) there was the code to call the next intro after the current outro had finished playing:

var theRoot:MovieClip = MovieClip(root);
theRoot.current.gotoAndPlay("intro");

now all i have to do is incorporate some deep linking in with this code and i will be good to go...


var current:MovieClip = menu1;
current.gotoAndPlay("intro");
 
button.addEventListener(MouseEvent.CLICK, clickHandler);
button2.addEventListener(MouseEvent.CLICK, clickHandler);
 
function clickHandler(e:MouseEvent):void
{
	current.gotoAndPlay("outro");
	switch(e.target.name)
	{
	case"button":
	current = menu1;
	break;
	
	case"button2":
	current = menu2;
	break;
	}
}
	
	

Open in new window

0
 
LVL 9

Expert Comment

by:asaivan
ID: 24432762
When you say deep linking are you talking about browser integration.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question