As3: Main
Did you ever try to make a RadioButton, or maybe a CheckBox?
Did you get errors when addChild'ing components from the fl folder? (Like the RadioButton)
Do you like tutorials that make you say "There has to be another way, this sucks!" to yourself!?
Then this is the tutorial for you!
Wait... what's a radiobutton?
This is an .swf with radiobuttons on the left and checkboxes on the right!
I can't find any use for those!
Well, neither can I!
Or well, I'm using it for a game right now!
You'll see >: 3
Let's just get on with it!
Allright, make a .fla and save it in a new folder on your desktop.
At the top of you fuzzy Flash CS3 window, go to File > Publish Settings > the Flash panel > Settings (Next to 'Actionscript version')
Allright, now press that plus and type in C:\Program Files\Adobe\Adobe Flash CS3\en\Configuration\Component Source\ActionScript 3.0\User Interface
or whereever you keep your stuff!
Now we're ready for it!
Make a new .as file and save it in the same folder as the .fla as Wurzt.
Now type in:
package {
import flash.display.MovieClip;
import fl.controls.CheckBox;
public class Wurzt extends MovieClip{
private var cBox1:CheckBox = new CheckBox();
private var cBox2:CheckBox = new CheckBox();
private var cBox3:CheckBox = new CheckBox();
public function Wurzt () {
addChild(cBox1);
addChild(cBox2);
addChild(cBox3);
}
}
}
Allright, in your .fla, in Properties (Ctrl+F3) set the document class to Wurzt.
Now test your .fla.
It doesn't work!
Go to C:\Program Files\Adobe\Adobe Flash CS3\en\Configuration\Components
and open up the "User Interface" .fla.
From it, copy the RadioButton and CheckBox, and paste it in your .fla.
Now you have a folder called "Component Assets" in your library, don't touchorz it!
Delete the radiobutton and checkbox laying about on your workspace. (They're still in the library!)
Now try your .fla again!
Allright, now I'm just gonna give you this huge chunk of code:
package {
import flash.display.Sprite;
import fl.controls.CheckBox;
import fl.controls.RadioButton;
import flash.events.MouseEvent;
public class Wurzt extends Sprite{
private var cBox1:CheckBox = new CheckBox();
private var cBox2:CheckBox = new CheckBox();
private var cBox3:CheckBox = new CheckBox();
private var rB1:RadioButton = new RadioButton();
private var rB2:RadioButton = new RadioButton();
private var rB3:RadioButton = new RadioButton();
public function Wurzt () {
addChild(rB1);
addChild(rB2);
addChild(rB3);
rB1.move(100,20);
rB2.move(100,40);
rB3.move(100,60);
rB1.label = "Male";
rB2.label = "Female";
rB3.label = "Other";
rB1.addEventListener(MouseEvent.CLICK,Click);
rB2.addEventListener(MouseEvent.CLICK,Click);
rB3.addEventListener(MouseEvent.CLICK,Click);
addChild(cBox1);
addChild(cBox2);
addChild(cBox3);
cBox1.move(20,20);
cBox2.move(20,40);
cBox3.move(20,60);
cBox1.label = "Newsletter";
cBox2.label = "Cat";
cBox3.label = "Monees";
cBox1.addEventListener(MouseEvent.CLICK,Click);
cBox2.addEventListener(MouseEvent.CLICK,Click);
cBox3.addEventListener(MouseEvent.CLICK,Click);
}
private function Click (e:MouseEvent) {
switch(e.target){
case rB1:
trace("I'm not a woman!");
break;
case rB2:
trace("I'm a woman!")
break;
case rB3:
trace("I might be a woman!");
break;
case cBox1:
if(cBox1.selected){
trace("I DO want annoying newsletters!");
}
break;
case cBox2:
if(cBox2.selected){
trace("I have a cat!");
}
break;
case cBox3:
if(cBox3.selected){
trace("I will gladly give you my money!");
}
break;
}
}
}
}
A load of repetive and boring code!
But that's how you make them buttons.
I want them to look differentzors!
You can either make new skins, or edit the allready excisting ones!
Since we copied the stuff from the other .fla, we might aswell edit them!
So doubleclick CheckBox in the library and then doubleclick the square that says "up".
Do whatever you want to it! O_O
Draw some nice little checkbox-related.. thing!
Then edt the others, remember to add some sort of checker on the "selected_" ones!
I think that's all, you can of coure edit the radiobutton too!
If you want to make things like ComboBoxes, ColorPickers, or anything else in the User Interface .fla... well, it's not that hard, it's pretty much like this.
If you really need it, tell me, and I'll add it in.