;

PDA

Click to See Complete Forum and Search --> : radiobutton between frames


beaco
03-27-2006, 06:46 AM
Newbie using radiobuttons - everything works ok. Using it in a slide presentation that goes frame by frame using buttons and gotoandstop function.

When I go forward and back a frame any selections made on the radiobuttons are lots. Is there an easy way to save these so they are not lost when i change frames?

Thanks
beaco

cancerinform
03-27-2006, 08:55 AM
Here is a simple script for 2 radiobuttons:

import mx.controls.RadioButton;
var radio1:RadioButton;
var radio2:RadioButton;
var id:MovieClip;
radio1.label = "number 1";
radio2.label = "number 2";
var myListener:Object = new Object ();
myListener.click = function (obj:Object) {
id = obj.target;
};
radio1.addEventListener ("click", myListener);
radio2.addEventListener ("click", myListener);
id.selected = true;

beaco
03-27-2006, 10:54 PM
i think i just need the part of the code shown below as I have already created the radio buttons using the flash GUI.

Does this mean that for each set of radiobuttons i need a unique mylistener and id object?

var id:MovieClip;
var myListener:Object = new Object ();
myListener.click = function (obj:Object) {
id = obj.target;
};
radio1.addEventListener ("click", myListener);
radio2.addEventListener ("click", myListener);
id.selected = true;

cancerinform
03-28-2006, 07:47 PM
You need one listener for all radiobuttons. If you have several with a similar name like radio1, radio2 etc you can use a for loop.

var numButs:Number = 6;
for (var count=1;count<=numButs;count++){
this["radio"+count].addEventListener ("click", myListener);
}

beaco
03-29-2006, 07:07 AM
You mean I need a listener for each set (group) of radiobuttons.

cancerinform
03-29-2006, 09:22 AM
That is correct, but not for each radiobutton.

beaco
03-29-2006, 05:11 PM
Can I do a similar thing with input textboxes so they don't lose their contents?

cancerinform
03-29-2006, 05:18 PM
You can. Check the event handlers in the flash help files for textinput. I think the handler is change instead of click, but make it sure.

beaco
03-30-2006, 02:03 AM
Thanks for all your help. This is my first time using flash so its a bit quirky.

If I want to access id._name from a different frame can I declare it as global or something?

I was reading things that suggested declaring it as this.id:movieclip or _global.id:movieclip but i get syntax errors. Any help is appreciated.

Thanks

beaco
03-30-2006, 02:27 AM
Also the above code for radiobuttons doesn't work when using the tab key to make selections. Is there another methods like group.selected.changed() or similar to activate the change.

cancerinform
03-30-2006, 09:18 AM
1. key listener events are triggered differently. Check the flash help files.
2. this.id:movieclip is the wrong syntax. First you need to declare the var and add the datatype:
var id:MovieClip;
this.id = id;

3. Do not use _global. It is not recommended, because your var may interfere with other code and then debugging becomes difficult. In your case it is simple. Whenever you refer to id use the path, which would be this or _root or _level0.

beaco
03-30-2006, 10:28 PM
custType is defined on frame 3.

I still can't find a way to access custType._name from frame 6. I have tried this. and _parent. and _level0. and _root. and this._parent everything is returned as undefined.

Any ideas/.

cancerinform
03-31-2006, 08:33 AM
You have to show coding, if anybody should help you. We cannot guess what custType is or anything else.

beaco
04-03-2006, 06:43 AM
var custType:MovieClip;
var custTypeListener:Object = new Object ();
custTypeListener.focusIn = function (obj:Object) {
custType = obj.target;
};
busCustomer.addEventListener("focusIn", custTypeListener);
indCustomer.addEventListener ("focusIn", custTypeListener);
custType.selected = true;

as above - Is there a way of accessing custType.name from other frames?

Notel busCustomer and indCustomer and instances of the radiobutton component.

cancerinform
04-03-2006, 11:00 AM
Your script works for me. When you say "frame", which frame or frames do you mean?