Thanks! The labels are now showing perfectly!
However, I am getting an error when I attempt to check the radio buttons:
TypeError: Error #1009: Cannot access a property or method of a null object
reference.
at
com.wallykolcz.views.components::RadioButtonPanel/changeStartType()[D:\wkolcz\My
Documents\Flex3\landingPage\src\com\wallykolcz\views\components\RadioButtonPanel.as:34]
Line 34 (in this case since I chose Airport to make this error) is part of this:
public function changeStartType(e:Event):void {
if (startLocation.selectedValue == "address"){
maps.start_txt.text = "Enter Starting Address";
maps.frmAirport.includeInLayout = false;
maps.frmAirport.visible = false;
maps.frmAddress.includeInLayout = true;
maps.frmAddress.visible = true;
maps.submit_btn.visible = true;
}else{
maps.start_txt.text = "Choose Your Airport";
maps.frmAddress.includeInLayout = false;
maps.frmAddress.visible = false;
maps.frmAirport.includeInLayout = true;
maps.frmAirport.visible = true;
maps.submit_btn.visible = true;
}
}
I did import and create a variable for the 'maps' component in which this panel
is inside.
import edu.umich.body.Maps;
private var maps:Maps;
Is there something I am missing?
If you need a visual reference you can see the concept site at
http://www.med.umich.edu/prmc/landing/helipad
----------------------------------------
From: "Tim Hoff" <[email protected]>
Sent: Wednesday, June 24, 2009 8:04 AM
To: [email protected]
Subject: [flexcoders] Re: Extending Custom Panel with RadioButtons - Help
Hi Wally,
Pretty close, just a few minor tweaks needed:
// add the
event parameter
public
function
changeStartType( event:Event ):
void
// change to
group
addressRB.group = startLocation ;
airportRB.group = startLocation ;
protected
override
function
updateDisplayList(unscaledWidth:Number,
unscaledHeight:Number):
void
{
super
.updateDisplayList(unscaledWidth, unscaledHeight);
// gap between label and edges
of button
var
margin:int = 4;
// set the sizes
addressRB.setActualSize(addressRB.getExplicitOrMeasuredWidth(),
addressRB.getExplicitOrMeasuredHeight());
airportRB.setActualSize(airportRB.getExplicitOrMeasuredWidth(),
airportRB.getExplicitOrMeasuredHeight());
// position the buttons in the
panel
addressRB.move(145,5 );
airportRB.move(255,5 );
}
-TH
--- In [email protected], "Wally Kolcz" <wko...@...> wrote:
>
>
>
> Using an example from the web I am trying to create a custom Panel component
> that had radio buttons in the panel header for a specific piece of a web
> site. The panel works and I am getting 2 radio buttons but no labels for
> either button and the radioGroup's
> changeStartType() is not being called
> . What am I doing wrong? Here is the AS:
>
> package com.wallykolcz.views.components
> {
>
> import edu.umich.body.Maps;
> import flash.events.Event;
> import mx.containers.Panel;
> import mx.controls.Button;
> import mx.controls.RadioButton;
> import mx.controls.RadioButtonGroup;
>
> public class RadioButtonPanel extends Panel
> {
>
> //Create Radio Button Group and Buttons
> private var startLocation:RadioButtonGroup = new RadioButtonGroup();
> private var addressRB:RadioButton = new RadioButton();
> private var airportRB:RadioButton = new RadioButton();
> private var maps:Maps;
>
> //constructor
> public function RadioButtonPanel()
> {
> super();
> }
>
> public function changeStartType():void {
> if (startLocation.selectedValue == "address"){
> maps.start_txt.text = "Enter Starting Address";
> maps.frmAirport.includeInLayout = false;
> maps.frmAirport.visible = false;
> maps.frmAddress.includeInLayout = true;
> maps.frmAddress.visible = true;
> maps.submit_btn.visible = true;
> }else{
> maps.start_txt.text = "Choose Your Airport";
> maps.frmAddress.includeInLayout = false;
> maps.frmAddress.visible = false;
> maps.frmAirport.includeInLayout = true;
> maps.frmAirport.visible = true;
> maps.submit_btn.visible = true;
> }
> }
>
> protected override function createChildren():void{
> super.createChildren();
> //instantiate new radiobuttons and assign properties
> addressRB.value="address";
> addressRB.label="My Address";
> addressRB.groupName = "startLocation";
>
> airportRB.value="airport";
> airportRB.label="Airport";
> airportRB.groupName="startLocation"
>
> //add event listener for change event and call method
> startLocation.addEventListener(Event.CHANGE, changeStartType);
>
> //add the buttons to rawChildren
> rawChildren.addChild(addressRB);
> rawChildren.addChild(airportRB);
> }
>
> protected override function updateDisplayList(unscaledWidth:Number,
> unscaledHeight:Number):void{
> super.updateDisplayList(unscaledWidth, unscaledHeight);
> //gap between label and edges of button
> var margin:int = 4;
>
> //position the buttons in the panel
> addressRB.move(145, 15);
> airportRB.move(255,15)
> }
>