<< Chapter < Page Chapter >> Page >

Hopefully most of this terminology will become clear as we pursue these lessons.

Sample code

We have reached the point in this discussion where I should provide some examples of ActionScript 3 class definitions so that you can get a preview ofwhat lies ahead.

A simple class named MyClass

The code beginning with the word public in Listing 1 is the definition of a very simple class named MyClass . I don't expect this code to mean much to you at this point. Suffice it to say that an object of this class is anew GUI component consisting of a Button object, a RadioButton object, and a NumericStepper object, all contained in a VBox object.

Class file named myclass.as.

package Classes{ import mx.containers.VBox;import mx.controls.Button; import mx.controls.RadioButton;import mx.controls.NumericStepper;public class MyClass extends VBox{ //Constructor followspublic function MyClass(){ addChild(new Button());addChild(new RadioButton()); addChild(new NumericStepper());setStyle("backgroundColor",0xFFFF00); }//end constructor}//end class }//end package

A new data type

The definition of the class creates a new data type, which is unknown to the compiler until it is defined by the programmer.

Two instances (objects) of the class named MyClass

Two objects of the new class named MyClass are shown in Figure 2. You should be able to spot the Button object (rectangular) , the RadioButton object (circular) , and the NumericStepper object in each of the two MyClass objects.

Two objects of the class named myclass.

Missing image.
Two objects of the class named MyClass.

A yellow background

Normally you can't see a VBox object. You can only see the components that it contains. However, I included code in Listing 1 to set the background style of the VBox object to yellow to make it possible for you to visually separate the two new custom objects in Figure 2.

The Flex MXML file

Listing 2 shows the Flex file that was used to instantiate the two objects of the class named MyClass and to display them in the Flash Player window in a browser.

Flex file named simpleclass01.mxml.

<?xml version="1.0" encoding="utf-8"?><!--SimpleClass01 --><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"xmlns:classes="Classes.*"><classes:MyClass /><classes:MyClass /></mx:Application>

The two lines of code beginning with the words classes in Listing 2 cause thetwo new objects to be instantiated and displayed.

Another custom component - NumericTextAreaA

One of the standard Flex components is named TextArea . This component is an object of the ActionScript class having the same name.

A custom component that extends TextArea

As an example of creating a new custom component that extends an existing class, I will present and discuss a new custom component that extends the TextArea class. The new class is named NumericTextAreaA.

An object of the NumericTextAreaA class behaves just like an object of the standard TextArea class except that the new component will only accept numeric characters, the space character, the backspace character, and the return character. Allother characters are rejected when the user attempts to type them into the text area.

Questions & Answers

Is there any normative that regulates the use of silver nanoparticles?
Damian Reply
what king of growth are you checking .?
What fields keep nano created devices from performing or assimulating ? Magnetic fields ? Are do they assimilate ?
Stoney Reply
why we need to study biomolecules, molecular biology in nanotechnology?
Adin Reply
yes I'm doing my masters in nanotechnology, we are being studying all these domains as well..
what school?
biomolecules are e building blocks of every organics and inorganic materials.
anyone know any internet site where one can find nanotechnology papers?
Damian Reply
sciencedirect big data base
Introduction about quantum dots in nanotechnology
Praveena Reply
what does nano mean?
Anassong Reply
nano basically means 10^(-9). nanometer is a unit to measure length.
do you think it's worthwhile in the long term to study the effects and possibilities of nanotechnology on viral treatment?
Damian Reply
absolutely yes
how to know photocatalytic properties of tio2 nanoparticles...what to do now
Akash Reply
it is a goid question and i want to know the answer as well
characteristics of micro business
for teaching engĺish at school how nano technology help us
Do somebody tell me a best nano engineering book for beginners?
s. Reply
there is no specific books for beginners but there is book called principle of nanotechnology
what is fullerene does it is used to make bukky balls
Devang Reply
are you nano engineer ?
fullerene is a bucky ball aka Carbon 60 molecule. It was name by the architect Fuller. He design the geodesic dome. it resembles a soccer ball.
what is the actual application of fullerenes nowadays?
That is a great question Damian. best way to answer that question is to Google it. there are hundreds of applications for buck minister fullerenes, from medical to aerospace. you can also find plenty of research papers that will give you great detail on the potential applications of fullerenes.
what is the Synthesis, properties,and applications of carbon nano chemistry
Abhijith Reply
Mostly, they use nano carbon for electronics and for materials to be strengthened.
is Bucky paper clear?
carbon nanotubes has various application in fuel cells membrane, current research on cancer drug,and in electronics MEMS and NEMS etc
so some one know about replacing silicon atom with phosphorous in semiconductors device?
s. Reply
Yeah, it is a pain to say the least. You basically have to heat the substarte up to around 1000 degrees celcius then pass phosphene gas over top of it, which is explosive and toxic by the way, under very low pressure.
Do you know which machine is used to that process?
how to fabricate graphene ink ?
for screen printed electrodes ?
What is lattice structure?
s. Reply
of graphene you mean?
or in general
in general
Graphene has a hexagonal structure
On having this app for quite a bit time, Haven't realised there's a chat room in it.
what is biological synthesis of nanoparticles
Sanket Reply
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get the best Algebra and trigonometry course in your pocket!

Source:  OpenStax, Object-oriented programming (oop) with actionscript. OpenStax CNX. Jun 04, 2010 Download for free at http://cnx.org/content/col11202/1.19
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Object-oriented programming (oop) with actionscript' conversation and receive update notifications?