Jonny5ive
10-15-2009, 05:03 PM
Hi,
I'm new to flash and I've got as far as to use addChild to add radio buttons to the stage. What I'm trying to do is add the radio buttons to a certain point in the time line and then I would like to remove the radio buttons with a mouse event click. I would be most grateful if anyone can offer any help or advice on this.
Source code:
--------------------------------------------------------------------------
package oaksuite
{
import flash.display.MovieClip;
import flash.text.TextField;
import flash.events.MouseEvent;
import flash.display.Sprite;
import flash.display.SimpleButton
import fl.controls.RadioButton;
import fl.controls.RadioButtonGroup;
import flash.net.URLRequest;
import flash.display.Loader;
public class OakSuite2 extends MovieClip
{
var facilities:RadioButtonGroup=new RadioButtonGroup('My facilities');
var style:RadioButtonGroup=new RadioButtonGroup('My style');
private var result_txt:TextField;
private var result_mc:MovieClip;
private var first_step:int=5;
private var second_step:int=4;
private var facilities_result:String;
private var style_result:String;
public function OakSuite2()
{
firstStep();
secondStep();
zoom_mc.titles_mc.close_btn.addEventListener(Mouse Event.CLICK, unloadSwf);
function unloadSwf(event:MouseEvent):void{
zoom_mc.gotoAndPlay(16);
}
zoom_mc.titles_mc.equipment_btn.addEventListener(M ouseEvent.CLICK, btnHandler10);
function btnHandler10(event:MouseEvent):void{
var request:URLRequest = new URLRequest(host_domain + "oak_equipment.swf");
var loader:Loader = new Loader()
loader.load(request);
addChild(loader);
}
zoom_mc.titles_mc.photo_btn.addEventListener(Mouse Event.CLICK, btnHandler11);
function btnHandler11(event:MouseEvent):void{
var request:URLRequest = new URLRequest(host_domain + "oak_photos.swf");
var loader:Loader = new Loader()
loader.load(request);
addChild(loader);
}
}
private function firstStep():void
{
var field:TextField=new TextField();
field.x=205;
field.y=210;
addChild(field);
for(var i:int=0;i < first_step;i++)
{
var rb:RadioButton=new RadioButton();
rb.move(field.x,field.y*2+22*i);
rb.width=220;
addChild(rb);
rb.group=facilities;
if(!i)
rb.label='Power sockets';
if(i==1)
rb.label='Lighting controls';
if(i==2)
rb.label='Data port';
if(i==3)
rb.label='Air conditioning';
if(i==4)
rb.label='Fire exit';
rb.addEventListener(MouseEvent.CLICK,reportResult) ;
}
}
code continues....
I'm new to flash and I've got as far as to use addChild to add radio buttons to the stage. What I'm trying to do is add the radio buttons to a certain point in the time line and then I would like to remove the radio buttons with a mouse event click. I would be most grateful if anyone can offer any help or advice on this.
Source code:
--------------------------------------------------------------------------
package oaksuite
{
import flash.display.MovieClip;
import flash.text.TextField;
import flash.events.MouseEvent;
import flash.display.Sprite;
import flash.display.SimpleButton
import fl.controls.RadioButton;
import fl.controls.RadioButtonGroup;
import flash.net.URLRequest;
import flash.display.Loader;
public class OakSuite2 extends MovieClip
{
var facilities:RadioButtonGroup=new RadioButtonGroup('My facilities');
var style:RadioButtonGroup=new RadioButtonGroup('My style');
private var result_txt:TextField;
private var result_mc:MovieClip;
private var first_step:int=5;
private var second_step:int=4;
private var facilities_result:String;
private var style_result:String;
public function OakSuite2()
{
firstStep();
secondStep();
zoom_mc.titles_mc.close_btn.addEventListener(Mouse Event.CLICK, unloadSwf);
function unloadSwf(event:MouseEvent):void{
zoom_mc.gotoAndPlay(16);
}
zoom_mc.titles_mc.equipment_btn.addEventListener(M ouseEvent.CLICK, btnHandler10);
function btnHandler10(event:MouseEvent):void{
var request:URLRequest = new URLRequest(host_domain + "oak_equipment.swf");
var loader:Loader = new Loader()
loader.load(request);
addChild(loader);
}
zoom_mc.titles_mc.photo_btn.addEventListener(Mouse Event.CLICK, btnHandler11);
function btnHandler11(event:MouseEvent):void{
var request:URLRequest = new URLRequest(host_domain + "oak_photos.swf");
var loader:Loader = new Loader()
loader.load(request);
addChild(loader);
}
}
private function firstStep():void
{
var field:TextField=new TextField();
field.x=205;
field.y=210;
addChild(field);
for(var i:int=0;i < first_step;i++)
{
var rb:RadioButton=new RadioButton();
rb.move(field.x,field.y*2+22*i);
rb.width=220;
addChild(rb);
rb.group=facilities;
if(!i)
rb.label='Power sockets';
if(i==1)
rb.label='Lighting controls';
if(i==2)
rb.label='Data port';
if(i==3)
rb.label='Air conditioning';
if(i==4)
rb.label='Fire exit';
rb.addEventListener(MouseEvent.CLICK,reportResult) ;
}
}
code continues....