|
-
[RESOLVED] [F8] Radio Buttons for fake poll
I don’t think this is hard, but I’m not finding any tutorials or models I could get coding and syntax from.
I want to make a fake webpoll, 1 question with five choices on radio buttons and a vote button. If the user chooses radio button 1 or 2, the vote button sends them to a webpage. (radiobutton data is “gogoth”) If they’ve chosen 3, 4, or 5 they are sent to a different webpage. (data is “needhint”)
I gather I’ll need a listening object but don’t know where or how to set it up.
I know the data on the radio buttons is important, but I don’t know what it’s called in code, how to “get at it.”
I know I’ve got a fairly simple if code to make for the vote button. I think I can handle that once I know the rest.
-
FK'n_dog
open a new file
drag a RadioButton component into the Library
add a button - instance name - vote_button
add this code to the main timeline
publish and test in the browser
PHP Code:
for(var n=1;n!=6;n++){
objRB = {_x:50 ,_y:n*20+50, label:" choice "+n, data:n, groupName:"poll"};
this.attachMovie("RadioButton", "rb"+n, n, objRB);
}
var rbL:Object = new Object();
rbL.click = function(obj:Object){
num = obj.target.selection.data;
switch(num){
case 1: choice = "gogoth.html"; break;
case 2: choice = "gogoth.html"; break;
case 3: choice = "needhint.html"; break;
case 4: choice = "needhint.html"; break;
case 5: choice = "needhint.html"; break;
}
};
poll.addEventListener("click", rbL);
vote_button.onRelease = function(){
trace(choice);
getURL(choice, "_blank");
};
hope this helps you on your way
-
Okay, I almost get it. We're building the radio buttons in the framescript rather than building them on the stage. Works beautifully. So far so good.
Now can you tell me how I would assign different labels that are whole lines of text?
e.g. "Political opponents" "Maroni Crime Family" and so on.
-
FK'n_dog
add labels to an array, and set them to the radiobuttons within the object
PHP Code:
aLabels = ["Political opponents", "Maroni Crime Family","blah","blah","blah"];
for(var n=1;n!=6;n++){
objRB = {_x:50 ,_y:n*20+50, label:aLabels[n-1], data:n, groupName:"poll"};
this.attachMovie("RadioButton", "rb"+n, n, objRB);
}
-
You're amazing, AMD. Thank you so much. Hope one day I can return the favor.
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
|