# Class File - Noob

**URL:** <https://forum.kirupa.com/t/class-file-noob/276106>\
**Category:** flash\
**Created:** [November 22, 2008, 7:37pm UTC](https://forum.kirupa.com/t/class-file-noob/276106 "2008-11-22T19:37:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sephiroth1](https://avatars.discourse-cdn.com/v4/letter/s/7cd45c/32.png) [@Sephiroth1](https://forum.kirupa.com/u/Sephiroth1)\
**Post date:** [November 22, 2008, 7:37pm UTC](https://forum.kirupa.com/t/class-file-noob/276106/1 "2008-11-22T19:37:48Z")

</div>

Kaiii well, Haii guys, kinda new here :kir:

But yush anyway, I have a problem with this code…(when I say problem I mean the problem is actually myself - I’m useless with Class files)

**Its basically Drawing out some buttons using the API - On click display some text into a textbox. Also a lame tween and some sounds on buttons and on Loadframe.**

I need to know how the hell do I get this code into a class file, or have I gone too far with this aready :cry3:

Jason.

/\* -----------------------------------------------------------------

----------------------------------------------------------------- _/  
/_ -------------------- importing the filter(s) -------------------- \*/  
import flash.filters.GlowFilter;

import mx.transitions.Tween;  
import mx.transitions.easing.\*;  
var tween\_handler:Object = new Tween(ball\_mc, “\_alpha”, Strong.easeIn, 0, 100, 3, true);  
tween\_handler.onMotionFinished = function() {  
//trace(“onMotionFinished triggered”);  
clickSound = new Sound();  
clickSound.attachSound(“lotr-thunder”);  
clickSound.start();

};

var labelGlow:GlowFilter = new GlowFilter(0x7FFF0, .90, 4, 4, 3, 3);  
var labelFilters:Array = [labelGlow];  
import flash.filters.DropShadowFilter;  
var buttonShadow:DropShadowFilter = new DropShadowFilter(1, 95, 0xF0F8FF, 1, 4, 4, 1, 3);  
var buttonFilters:Array = [buttonShadow];  
/\* -------------------- creating and positioning the new movie clip that makes the button’s core -------------------- _/  
this.createEmptyMovieClip(“myButton1”,this.getNextHighestDepth());  
myButton1.\_x = 100;  
myButton1.\_y = 140;  
/_ -------------------- gradient fill parameters -------------------- \*/  
var fillType:String = “linear”;

var colors:Array = [0x000000, 0x000000, 0x00008B, 0xF8F8FF];  
var alphas:Array = [100, 100, 100, 100];  
var ratios:Array = [0, 126, 127, 255];  
var matrix:Object = {matrixType:“box”, x:0, y:0, w:120, h:30, r:90/180_Math.PI};  
/_ -------------------- creating the button’s background -------------------- _/  
myButton1.createEmptyMovieClip(“buttonBkg”,myButton1.getNextHighestDepth());  
/_ -------------------- drawing and filling the button background -------------------- _/  
 [//myButton1.buttonBkg.lineStyle](https://myButton1.buttonBkg.lineStyle)(0, 0x820F26, 60, true, “none”, “square”, “round”);  
myButton1.buttonBkg.lineStyle(0,0x7FFF00,60,true,“none”,“square”,“round”);  
myButton1.buttonBkg.beginGradientFill(fillType,colors,alphas,ratios,matrix);  
myButton1.buttonBkg.lineTo(120,0);  
myButton1.buttonBkg.lineTo(120,30);  
myButton1.buttonBkg.lineTo(0,30);  
myButton1.buttonBkg.lineTo(0,0);  
myButton1.buttonBkg.endFill();  
/_ -------------------- creating the TextFormat object -------------------- _/  
var myFormat:TextFormat = new TextFormat();  
myFormat.align = “center”;  
myFormat.font = “Tahoma”;  
myFormat.size = 13;  
myFormat.color = 0xFFFFFF;  
/_ -------------------- creating the text field that will be the button’s label -------------------- _/  
myButton1.createTextField(“labelText”,myButton1.getNextHighestDepth(),0,5,myButton1.\_width,24);  
/_ -------------------- setting the various options for the button label -------------------- _/  
myButton1.labelText.text = “The King”;  
myButton1.labelText.embedFonts = true;  
myButton1.labelText.selectable = false;  
myButton1.labelText.antiAliasType = “advanced”;  
myButton1.labelText.setTextFormat(myFormat);  
/_ -------------------- applying the filters to the button label -------------------- _/  
myButton1.labelText.filters = labelFilters;  
/_ -------------------- making the button clickable and creating a link -------------------- \*/  
myButton1.onPress = function() {  
var currentButtonNumber:Number = this.\_name.substr(-1, 1);

attachMovie(“Window”,“newName”,depth,intObject);

newName.title = “Sample Window”;  
newName.closeButton = true;  
newName.contentPath = “ani”;  
newName.setSize(500,500);  
var listener:Object = new Object();  
listener.click = function(){  
newName.\_visible = false;  
}  
newName.addEventListener(“click”,listener);  
myText.text = “It has been reported that beta keys and invites have been sent to some European players on July 17th, 2008. Additionally, a beta registration page went live allowing those who had received a beta key to activate a new account and download the beta client. Notably, there is no NDA governing the opt-in beta, so participants are free to discuss their experience openly”;  
clickSound = new Sound();  
clickSound.attachSound(“buttonsound”);  
myButton1.onRelease = function () {  
clickSound.start();  
}

};  
/\* -------------------- applying the filters to button graphics -------------------- \*/  
myButton1.filters = buttonFilters;

//NEW BUTTON

this.createEmptyMovieClip(“myButton2”,this.getNextHighestDepth());  
myButton2.\_x = 100;  
myButton2.\_y = 200;  
/\* -------------------- gradient fill parameters -------------------- \*/  
var fillType:String = “linear”;

var colors:Array = [0x000000, 0x000000, 0x00008B, 0xF8F8FF];  
var alphas:Array = [100, 100, 100, 100];  
var ratios:Array = [0, 126, 127, 255];  
var matrix:Object = {matrixType:“box”, x:0, y:0, w:120, h:30, r:90/180_Math.PI};  
/_ -------------------- creating the button’s background -------------------- _/  
myButton2.createEmptyMovieClip(“buttonBkg”,myButton2.getNextHighestDepth());  
/_ -------------------- drawing and filling the button background -------------------- _/  
 [//myButton1.buttonBkg.lineStyle](https://myButton1.buttonBkg.lineStyle)(0, 0x820F26, 60, true, “none”, “square”, “round”);  
myButton2.buttonBkg.lineStyle(0,0x7FFF00,60,true,“none”,“square”,“round”);  
myButton2.buttonBkg.beginGradientFill(fillType,colors,alphas,ratios,matrix);  
myButton2.buttonBkg.lineTo(120,0);  
myButton2.buttonBkg.lineTo(120,30);  
myButton2.buttonBkg.lineTo(0,30);  
myButton2.buttonBkg.lineTo(0,0);  
myButton2.buttonBkg.endFill();  
/_ -------------------- creating the TextFormat object -------------------- _/  
var myFormat:TextFormat = new TextFormat();  
myFormat.align = “center”;  
myFormat.font = “Tahoma”;  
myFormat.size = 13;  
myFormat.color = 0xFFFFFF;  
/_ -------------------- creating the text field that will be the button’s label -------------------- _/  
myButton2.createTextField(“labelText”,myButton2.getNextHighestDepth(),0,5,myButton2.\_width,24);  
/_ -------------------- setting the various options for the button label -------------------- _/  
myButton2.labelText.text = “History”;  
//SET EMBED FONT  
myButton2.labelText.embedFonts = true;  
myButton2.labelText.selectable = false;  
myButton2.labelText.antiAliasType = “advanced”;  
myButton2.labelText.setTextFormat(myFormat);  
/_ -------------------- applying the filters to the button label -------------------- _/  
myButton2.labelText.filters = labelFilters;  
/_ -------------------- making the button clickable and creating a link -------------------- \*/  
myButton2.onPress = function() {

attachMovie(“Window”,“newName”,depth,intObject);

newName.title = “Sample Window”;  
newName.closeButton = true;  
newName.contentPath = “ani2”;  
newName.setSize(250,200);  
var listener:Object = new Object();  
listener.click = function(){  
newName.\_visible = false;  
}  
newName.addEventListener(“click”,listener);  
var currentButtonNumber:Number = this.\_name.substr(-1, 1);  
myText.text = “History…t has been reported that beta keys and invites have been sent to some European players on July 17th, 2008. Additionally, a beta registration page went live allowing those who had received a beta key to activate a new account and download the beta client. Notably, there is no NDA governing the opt-in beta, so participants are free to discuss their…etctcddw…etctcddw…etctcddw…”;  
clickSound = new Sound();  
clickSound.attachSound(“buttonsound”);  
myButton2.onRelease = function () {  
clickSound.start();

}

};  
/\* -------------------- applying the filters to button graphics -------------------- \*/  
myButton2.filters = buttonFilters;

//background

wSize = Stage.width;  
hSize = Stage.height;  
fillType = “linear”;  
colors = [0x00BFFF, 0x000000];  
alphas = [100, 100];  
ratios = [0, 255];  
matrix = {matrixType:“box”, x:0, y:0, w:wSize, h:hSize, r:90/180\*Math.PI};  
\_root.lineStyle(9,0xFFFFFF,0);  
\_root.beginGradientFill(fillType,colors,alphas,ratios,matrix);  
\_root.lineTo(wSize,0);  
\_root.lineTo(wSize,hSize);  
\_root.lineTo(0,hSize);  
\_root.lineTo(0,0);  
\_root.endFill();
