View Full Version : movie clip and radio buttons
Temper
04-01-2008, 03:21 PM
Hi,
I have 2 questions that I really need answering, please can someone help.
I have 9 movie clips and 2 radio buttons. My movie clips have 4 frames each.
1] Can someone please tell me how, I can specify that, if radiobutton 1 is clicked, then frame 2 of the movie clip will be displayed??
2] how can i set each movie clip to frame 1 before any radio button is selected?
any help is appreciated.
temps
pelkin000
04-02-2008, 06:29 AM
You will have to use "event listeners" - if you aren't familiar with them I suggest you read some tutorials on their basic use. However, I'll post some tips here below:
#1 - Add event listeners to the buttons after giving them each an instance name (done either in AS3 like below, or manually in flash) and making them part of the same "Group" (see help for more explanation)
#2 - then add event listeners
var rb:RadioButton = new RadioButton();
rb.addEventListener(MouseEvent.CLICK, changeFrame);
rb.group = "group1";
rb.label = "My Label2";
rb.move(0, 0);
addChild(rb);
var rb2:RadioButton = new RadioButton();
rb2.group = "group1";
rb2.label = "My Label2";
rb2.move(25, 0);
addChild(rb2);
function changeFrame(evt:MouseEvent):void {
if (evt.currentTarget.label == "rb.label") {
movieclip1.gotoAndStop(2);
if (evt.currentTarget.label == "rb2.label") {
movieclip2.gotoAndStop(2);
}
}
Temper
04-02-2008, 05:27 PM
var rb:RadioButton = new RadioButton();
For the first line, I get this error:
"a conflict exists with definition rb in namespace internal"
^^I dont understand what that means.
also I dont understand what this is for:
rb.move
also.. what I dont know hwo to do is this, say I have a movie clip called "mc11" and that movieclip is inside a button called "btn_1" how do I specify that:
if btn_1 is selected and radiobutton 1 then play mc11 on frame 2 otherwise
if btn_1 is selected and radiobutton 2 then play mc11 on frame 3
thanks for the help
stompwampa
04-02-2008, 05:49 PM
also.. what I dont know hwo to do is this, say I have a movie clip called "mc11" and that movieclip is inside a button called "btn_1" how do I specify that:
You can't do that...you cannot talk to object inside of buttons....it's just a part of the SimpleButton class.
If you want to do that, you should make all your buttons into MovieClips.
Temper
04-02-2008, 06:33 PM
If you want to do that, you should make all your buttons into MovieClips.
Can I make the movieclips selectable?? because im designig a noughts and crosses game..
so can i make it so that if the movie clip mc11 is selected and radiobutton 1then mc11 plays in frame 2???
stompwampa
04-02-2008, 07:38 PM
Can I make the movieclips selectable?? because im designig a noughts and crosses game..
so can i make it so that if the movie clip mc11 is selected and radiobutton 1then mc11 plays in frame 2???
Yes, you can do that.
Temper
04-02-2008, 07:43 PM
so far ive only seen movieclips with button states, so can u pls tell me how this could be done.. thank you so much
stompwampa
04-02-2008, 08:06 PM
Well, within each MovieClip you have two frames, and on each frame you have a stop(); action.
You just tell each MovieClip which frame to go to. Essentially, you're just simulating button states.
Temper
04-02-2008, 08:15 PM
can the movie-clip be selected ,by just moving a mouse over it.. ? What would the code look like?
stompwampa
04-03-2008, 04:00 AM
yep, like this:
myMovieClip.buttonMode = true;
myMovieClip.mouseEnabled = true;
myMovieClip.addEventListener(MouseEvent.MOUSE_OVER , hoverMouse);
function hoverMouse(event:MouseEvent):void
{
//do something here when the user hovers over tha clip
}
Temper
04-03-2008, 03:03 PM
thank u soo much, this has really helped
Temper
04-03-2008, 03:05 PM
Hi,
can someone pls tell me why I keep getting 'Access of undefined property":
import fl.controls.*;
import flash.display.*;
stop()
myMovieClip.buttonMode = true;
myMovieClip.mouseEnabled = true;
myMovieClip.addEventListener(MouseEvent.DOUBLE_CLI CK, hoverMouse); //error shows this line
myMovieClip.addEventListener(MouseEvent.DOUBLE_CLI CK, dcMouse); //and this line
x_rb.addEventListener(MouseEvent.CLICK, select)
o_rb.addEventListener(MouseEvent.CLICK, select2)
function select(evt:MouseEvent):void {
if (evt.currentTarget.label == "x_rb.label") {
function hoverMouse(event:MouseEvent):void{
myMovieClip.gotoAndStop(10);
}
}
}
function select2(evt:MouseEvent):void {
if (evt.currentTarget.label == "x_rb.label") {
function dcMouse(event:MouseEvent):void{
myMovieClip.gotoAndStop(20);
}
}
}
temps
Mazoonist
04-03-2008, 03:14 PM
Add this line:
myMovieClip.doubleClickEnabled = true;
Edit: There's another problem, too. Your handler functions shouldn't be nested like that.
Temper
04-03-2008, 03:24 PM
I still get the same error :s
what do you mean by:
Your handler functions shouldn't be nested like that.
and what should i do :S
thanks for your help
Mazoonist
04-03-2008, 03:30 PM
If your functions are inside of other functions, they won't be known outside of the enclosing function. You can't set an event listener to a function that's hidden like that. If I could duplicate your problem, or you could attach your fla file here, and I knew exactly what you want to do, I could help.
Temper
04-03-2008, 03:46 PM
I sort of solved the problem, because I removed the radio buttons.. and ive used two different mouse events, I dont know if thats clever, but its solved my problem, this is what I done:
stop()
myMovieClip.buttonMode = true;
myMovieClip.mouseEnabled = true;
myMovieClip.addEventListener(MouseEvent.ROLL_OVER, hoverMouse);
myMovieClip.addEventListener(MouseEvent.DOUBLE_CLI CK, dcMouse);
myMovieClip.doubleClickEnabled = true;
function hoverMouse(event:MouseEvent):void{
myMovieClip.gotoAndStop(10);
}
function dcMouse(event:MouseEvent):void{
myMovieClip.gotoAndStop(20);
}
but then i will be stuck on my next stage. I am designing a type of Noughts and Crosses game, and im using a movie clip for each square and each square will use the method pasted above, how will i be able to specify that:
if myMovieClip1 (2) and myMovieClip2 (2) and myMovieClip3 (2) are selected then its a win.
(2) this being frame 2 within the movieclip which displays x and therefore with 3 X's in a line, it makes a win.
Does that make sense :s
Mazoonist
04-03-2008, 03:52 PM
You could use the MovieClip class's currentFrame property to test that:
if(myMovieClip1.currentFrame == 2 && myMovieClip2.currentFrame == 2 && myMovieClip3.currentFrame == 2) {
//do whatever
}
Temper
04-03-2008, 03:59 PM
thank you sooo much!! you've been a great help and I really appreciate it :) I'll let you know how I get on, just wish me luck :)
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.