I have a poll that on submit also launchs a 2nd SWF on submit. Everything works, except I want to launch one of three separate SWFs based on which option is selected, either radioBtns_mc.pr_option1, radioBtns_mc.pr_option2 or radioBtns_mc.pr_option3.
I think I am close but can't figure out how to check which option was selected.
Code:
// Submit poll input and open panels one of three
pr_submitBtn.onRelease = function():Void {
// Load URL, and display poll results on load
result_lv.load(optionLink);
result_lv.onLoad = function() {
pollResults();
};
// Sets activity for submit
myPR.activity(myPR.activityID.Polling.SUBMIT);
trace("Poll submitted");
radioBtns_mc._visible = false;
pr_submitBtn._visible = false;
pr_replayBtn._visible = true;
// Header will say "Polling Results"
textHeader(2);
//_root.myPR.openPanel(1);
//_root.myPR.pin(1);
// launch one of three panels depending on selection
if (radioBtns_mc.pr_option1 == selected)
trace("one is selected");
{_parent.myPR.openPanel(1);
}
if (radioBtns_mc.pr_option2 == selected)
trace("two is selected");
{_parent.myPR.openPanel(2);
}
if (radioBtns_mc.pr_option3 == selected)
trace("three is selected");
{_parent.myPR.openPanel(3);
}
};
Complete AS
Code:
// This file demonstrates how polling functionality can be implemented.
// Import Pointroll API
import PointRollAPI.PointRoll;
// Create new PointRoll instance
var myPR:PointRoll = new PointRoll(this);
// Loading new vars
var result_lv:LoadVars = new LoadVars();
// Radio buttons code
radioBtns_mc.pr_option1.onPress = function():Void {
myPR.activity(1, true);
this.gotoAndStop(2);
radioBtns_mc.pr_option2.gotoAndStop(1);
// Pointroll Option 1 Link
optionLink="http://clk.pointroll.com/polling/?survey=2707955&decimal=2&Q1=1";
trace("Option 1 selected");
};
radioBtns_mc.pr_option2.onPress = function():Void {
myPR.activity(2, true);
this.gotoAndStop(2);
radioBtns_mc.pr_option1.gotoAndStop(1);
// Pointroll Option 2 Link
optionLink="http://clk.pointroll.com/polling/?survey=2707955&decimal=2&Q1=2";
trace("Option 2 selected");
};
radioBtns_mc.pr_option3.onPress = function():Void {
myPR.activity(3, true);
this.gotoAndStop(2);
radioBtns_mc.pr_option1.gotoAndStop(1);
// Pointroll Option 3 Link
optionLink="http://clk.pointroll.com/polling/?survey=2707955&decimal=2&Q1=3";
trace("Option 3 selected");
};
// Submit poll input and open panels one of three
pr_submitBtn.onRelease = function():Void {
// Load URL, and display poll results on load
result_lv.load(optionLink);
result_lv.onLoad = function() {
pollResults();
};
// Sets activity for submit
myPR.activity(myPR.activityID.Polling.SUBMIT);
trace("Poll submitted");
radioBtns_mc._visible = false;
pr_submitBtn._visible = false;
pr_replayBtn._visible = true;
// Header will say "Polling Results"
textHeader(2);
//_root.myPR.openPanel(1);
//_root.myPR.pin(1);
// launch one of three panels depending on selection
if (radioBtns_mc.pr_option1 == selected)
trace("one is selected");
{_parent.myPR.openPanel(1);
}
if (radioBtns_mc.pr_option2 == selected)
trace("two is selected");
{_parent.myPR.openPanel(2);
}
if (radioBtns_mc.pr_option3 == selected)
trace("three is selected");
{_parent.myPR.openPanel(3);
}
};
// Replay poll
pr_replayBtn.onRelease = function()
{
//
myPR.activity(3, true);
visiblePollBtns();
this._visible = false;
result_lv.unload(optionLink);
// Show option as selected
radioBtns_mc.pr_option1.gotoAndStop(1);
radioBtns_mc.pr_option2.gotoAndStop(1);
radioBtns_mc.pr_option3.gotoAndStop(1);
// Clear displayed results
result1.text = "";
result2.text = "";
result3.text = "";
// Header will say "Choose Option"
textHeader(1);
trace("Replay button selected");
};
// Will display results of poll input
function pollResults() {
var option1 = result_lv.Q1A1 + "%";
var option2 = result_lv.Q1A2 + "%";
var option3 = result_lv.Q1A3 + "%";
result1.text = option1;
result2.text = option2;
result3.text = option3;
trace("Option1 ="+" "+option1);
trace("Option2 ="+" "+option2);
trace("Option3 ="+" "+option3);
}
/* import PointRollAPI.data.DataStorage;
if (pr_option1 == true) {
DataStorage.setVariable("whichFrame", "one");
_parent.myPR.openPanel(1); //(you really shouldn’t use _root)
} else if (pr_option2 == true) {
DataStorage.setVariable("whichFrame", "two");
_parent.myPR.openPanel(1);
} else if (pr_option3 == true) {
DataStorage.setVariable("whichFrame", "three");
_parent.myPR.openPanel(1);
}*/
function visiblePollBtns() {
txtMC._visible = true;
radioBtns_mc._visible = true;
pr_submitBtn._visible = true;
}
function hidePollBtns() {
txtMC._visible = false;
radioBtns_mc._visible = false;
pr_submitBtn._visible = false;
pr_replayBtn._visible = false;
}
// Handles what this textfield will display
function textHeader(header:Number) {
if (header == 1) {
txtMC.polling_instructions.text = "Choose Your Favorite";
} else {
txtMC.polling_instructions.text = "The Favorites Are:";
}
}