<< Chapter < Page Chapter >> Page >

This method draws a yellow segmented lightening bolt four pixels thick (as shown in Figure 2) that is generally random but always ends up striking the top of the tree.

Long and tedious

As was the case earlier, this method is long and tedious but not technically difficult. Therefore, I will leave it as an exercise for the student to wadethrough the details in order to understand how it draws the lightening bolt.

The method named soundCompleteHandler

That brings us to the method shown in Listing 15 that is called each time a sizzle sound finishes playing.

The method named soundcompletehandler.

private function soundCompleteHandler(e:Event):void {//Allow another sizzle sound to be played now that // this one is finished.sizzlePlaying = false; //Play the thunder immediately following the end of// the sizzle sound. thunder.play();//Switch the background color from dark yellow// to the normal background color. redBkgnd = 0;greenBkgnd = 128; blueBkgnd = 128;//Erase the lightening bolt. Note that this will// also erase the yellow circle. canvasObj.graphics.clear();//Make the tree almost invisible. newTreeImage.alpha = 0.2;}//end soundCompleteHandler

Each time this method is called, it sets the sizzlePlaying variable to false to clear the way for the sizzle sound to be played again.

Then it plays the thunder sound and sets the color variables so that the background color will be restored to a dark cyan color by the code in Listing 7.

Finally it calls the clear method of the Graphics class to erase the lightening bolt, which also erases the moon as well.

Then it sets the alpha value on the tree image to a low value to make the tree appear to be lost in the fog.

The method named processChromaKey

That leaves only the method named processChromaKey that I haven't explained. The purpose of this method is to cause the blue backgroundpixels of the tree image shown in Figure 6 to become transparent.

The tree image.

Missing image
The tree image.

This method is essentially the same as a method that I explained in an earlier lesson titled Using Chroma Key Compositing to Create Transparent Backgrounds . Rather than to explain that method again, I will simply refer you to the earlier lesson for an explanation. You can view the method inits entirety in Listing 17.

Run the program

I encourage you to run this program from the web. Then copy the code from Listing 16 and Listing 17. Use that code tocreate your own project. Compile and run the project. Experiment with the code, making changes, and observing the results of your changes. Makecertain that you can explain why your changes behave as they do.

Resources

I will publish a list containing links to ActionScript resources as a separate document. Search for ActionScript Resources in theConnexions search box.

Complete program listings

Complete listings of the programs discussed in this lesson are provided below.

Code for main.mxml

<?xml version="1.0" encoding="utf-8"?><!-- Project LighteningStorm01See Driver.as for a description of this project. --><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"xmlns:cc="CustomClasses.*"><cc:Driver/></mx:Application>

Questions & Answers

what is Nano technology ?
Bob Reply
write examples of Nano molecule?
Bob
The nanotechnology is as new science, to scale nanometric
brayan
nanotechnology is the study, desing, synthesis, manipulation and application of materials and functional systems through control of matter at nanoscale
Damian
Is there any normative that regulates the use of silver nanoparticles?
Damian Reply
what king of growth are you checking .?
Renato
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
?
Kyle
yes I'm doing my masters in nanotechnology, we are being studying all these domains as well..
Adin
why?
Adin
what school?
Kyle
biomolecules are e building blocks of every organics and inorganic materials.
Joe
anyone know any internet site where one can find nanotechnology papers?
Damian Reply
research.net
kanaga
sciencedirect big data base
Ernesto
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.
Bharti
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
Daniel
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
Maciej
characteristics of micro business
Abigail
for teaching engĺish at school how nano technology help us
Anassong
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
NANO
what is fullerene does it is used to make bukky balls
Devang Reply
are you nano engineer ?
s.
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.
Tarell
what is the actual application of fullerenes nowadays?
Damian
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.
Tarell
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.
Virgil
is Bucky paper clear?
CYNTHIA
carbon nanotubes has various application in fuel cells membrane, current research on cancer drug,and in electronics MEMS and NEMS etc
NANO
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.
Harper
Do you know which machine is used to that process?
s.
how to fabricate graphene ink ?
SUYASH Reply
for screen printed electrodes ?
SUYASH
What is lattice structure?
s. Reply
of graphene you mean?
Ebrahim
or in general
Ebrahim
in general
s.
Graphene has a hexagonal structure
tahir
On having this app for quite a bit time, Haven't realised there's a chat room in it.
Cied
how did you get the value of 2000N.What calculations are needed to arrive at it
Smarajit Reply
Privacy Information Security Software Version 1.1a
Good
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?

Ask