PDA

View Full Version : movie clip control



stevedc
June 11th, 2008, 10:31 PM
Hi all,

I'm new to AS3 and to Kirupa, but plan on spending a lot of time here learning. I have a pretty simple question and can't seem to figure it out. I'm putting together a small animation using mostly the timeline for assistance. All I want to do is able to click on text (a movieclip called "mc_pete_ross") and have it go to another frame further down the timeline. Here is my code.


stop ();

this.mc_pete_ross.onRelease = function () {
mc_pete_ross.gotoAndPlay("pete");
}

-- the frame label is pete and the movieclip has an instance name of "mc_pete_ross" -- I'm sure of it. However, nothing works. Yet if I try giving the mc_pete_ross a URL function such as


stop ();

this.mc_pete_ross.onRelease = function () {
mc_pete_ross.getURL("http://www.somewebsite.com","_blank");
}

it works!!! However, I don't want to visit an external page :|

I'm wondering if the stop action has something to do with it? The timeline animation spans 50 frames then it must stop. Once it stops, I want to have each piece of text or navigation to go to frame 65 or 80 etc. This is basic flash so I'm sorry, but most of my web background is in CSS and HTML.

~ Regards
Steve

snickelfritz
June 11th, 2008, 11:52 PM
Since you are using CS3, I would highly recommend you start with AS3; it will be easier to learn if you don't have "unlearn" outdated AS2 syntax.
AS3 is significantly more powerful, and once learned, far easier to use.

Below is an example of frame-based navigation code in AS3.
This works by storing the button instance name in a variable, then sending the playhead to a frame label with the same name.
So, movieclip "button1" will send the playhead to frame label "button1" and so forth.
This is a very basic way to build a website in Flash.
BTW, to add more buttons to the project, simply place them inside the "buttonGroup" movieclip, give them instance names, then add matching frame labels on the timeline.

frame1 actionscript:

stop();

buttonGroup.addEventListener(MouseEvent.CLICK, navigate, false, 0, true);
buttonGroup.mouseEnabled = false;
buttonGroup.buttonMode = true;

var button:String = "";

function navigate(evt:MouseEvent):void {
button = evt.target.name;//value of button variable = the button instance name.
play();
}

function loadPage():void {
trace(button);
gotoAndPlay(button);//go to frame label that matches the value of the button variable.

}

frame39 actionscript:

//unload current page
stop();
trace("page is unloaded");
loadPage();

frame40 actionscript:

//load new page
stop();
trace("page is loaded");