RADIO BUTTON COMPONENT as2 |
This tutorial shows how to use actionscript 2.0 component RadioButton. In this case they change numbers in textfield and size of those numbers.
Ofcourse the action assigned to the buttons can be change as you like. The result should look like this:
Open new actionscript 2.0 document. Insert dynamic textfield and call it ( instance name ) hodnoty. Now open component library (ctrl + F7) and insert 5 RadioButton components to stage.
Call them b1, b2, b3, b4, b5.Now open component inspector (shift+F7) and set the parameters of first three radio buttons exactly as u can see on pictures below.
![]() These three will change the value displayed in text field. Now we need to setup parameters for last two radio buttons. These two will change the size of text field. ![]() Now open actions ( F9 ) and insert the actionscript you can see below. function RADIO(){ hodnoty.text = radioGroup.getValue(); } function SCALE(){ if(b4.selected==true){ hodnoty._xscale=100; hodnoty._yscale=100; }else if(b5.selected==true){ hodnoty._xscale=50; hodnoty._yscale=50; } } uiComponents = new Object(); uiComponents.click = function(eventObj) { for(key in eventObj.target) { RADIO() SCALE() } } radioGroup.addEventListener("click", uiComponents); scaleGroup.addEventListener("click", uiComponents); RADIO();
Lines 1-3 is function that changes numbers in textfield based on data value sent by first group of radio buttons (the radioGroup). Lines 4-12 is function which changes scale of the textfield
based on which button from second group of radio buttons (scaleGroup) is selected. Lines 13-23 creates event listeners for both radio buttons group and executes radio and scale functions.
|