|
-
radiobutton between frames
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
-
Senior Member
Here is a simple script for 2 radiobuttons:
PHP Code:
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;
- The right of the People to create Flash movies shall not be infringed. -
-
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;
-
Senior Member
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);
}
- The right of the People to create Flash movies shall not be infringed. -
-
You mean I need a listener for each set (group) of radiobuttons.
-
Senior Member
That is correct, but not for each radiobutton.
- The right of the People to create Flash movies shall not be infringed. -
-
Can I do a similar thing with input textboxes so they don't lose their contents?
-
Senior Member
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.
- The right of the People to create Flash movies shall not be infringed. -
-
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
-
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.
-
Senior Member
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.
- The right of the People to create Flash movies shall not be infringed. -
-
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/.
-
Senior Member
You have to show coding, if anybody should help you. We cannot guess what custType is or anything else.
- The right of the People to create Flash movies shall not be infringed. -
-
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.
-
Senior Member
Your script works for me. When you say "frame", which frame or frames do you mean?
- The right of the People to create Flash movies shall not be infringed. -
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|