<< Chapter < Page Chapter >> Page >

Project file structure for sound03.

Missing image
Project file structure for Sound03.

As you can see in Figure 2, all of the sound and image files are stored in the folder named src . In addition, all of the sound files were manually copied into the folder named bin .

Will explain in fragments

I will explain the code for this program in fragments. Complete listings of the MXML code and theActionScript code are provided in Listing 10 and Listing 11 near the end of the lesson.

The MXML code

The MXML code is shown in Listing 1 and also in Listing 10 for your convenience.

Mxml code for the project named sound03.

<?xml version="1.0" encoding="utf-8"?><!-- This project is intended to demonstrate the use of soundwith ActionScript. See the file named Driver.as for more information--><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"xmlns:cc="CustomClasses.*"><cc:Driver/></mx:Application>

As is often the case in this series of tutorial lessons, the MXML file is very simple because the program was coded almost entirely in ActionScript. TheMXML code simply instantiates an object of the Driver class. From that point forward, the behavior of the program is controlled byActionScript code.

The ActionScript code

Import directives for the Driver class

The code for the Driver class begins in Listing 2, which shows the package declaration and the import directives.

Import directives for the driver class

package CustomClasses{ import flash.display.Bitmap;import mx.containers.Canvas; import mx.controls.Image;import mx.events.FlexEvent; import flash.events.TimerEvent;import flash.utils.Timer; import flash.media.Sound;import flash.net.URLRequest; import flash.media.SoundChannel;import flash.events.Event;

New to this lesson

The directives to import the Sound class, the URLRequest class, the SoundChannel class, and possibly the Event class are all new to this lesson.

Beginning of the Driver class proper

The definition of the Driver class begins in Listing 3.

Beginning of the driver class proper.

public class Driver extends Canvas { //Extending Canvas makes it possible to locate// images with absolute coordinates. The default // location is 0,0;private var smallSky:Image = new Image();//Instantiate a Timer object that will fire ten events // per second.private var timer:Timer = new Timer(100);//Declare a counter that will keep track of the number // of timer events that have been fired.private var loopCntr:uint;//Declare variables for the four sounds. private var sizzle:Sound;private var thunder:Sound; private var wind:Sound;private var rain:Sound;//Declare variables that are used to control when the // thunder sound is played.private var channel:SoundChannel; private var sizzlePlaying:Boolean = false;

Nothing new here

There is nothing new in Listing 3. I will call your attention to the declaration of variables of type Sound and SoundChannel . Otherwise, no explanation beyond the embedded comments should be required.

The constructor for the Driver class

Questions & Answers

I'm interested in biological psychology and cognitive psychology
Tanya Reply
what does preconceived mean
sammie Reply
physiological Psychology
Nwosu Reply
How can I develope my cognitive domain
Amanyire Reply
why is communication effective
Dakolo Reply
Communication is effective because it allows individuals to share ideas, thoughts, and information with others.
effective communication can lead to improved outcomes in various settings, including personal relationships, business environments, and educational settings. By communicating effectively, individuals can negotiate effectively, solve problems collaboratively, and work towards common goals.
it starts up serve and return practice/assessments.it helps find voice talking therapy also assessments through relaxed conversation.
miss
Every time someone flushes a toilet in the apartment building, the person begins to jumb back automatically after hearing the flush, before the water temperature changes. Identify the types of learning, if it is classical conditioning identify the NS, UCS, CS and CR. If it is operant conditioning, identify the type of consequence positive reinforcement, negative reinforcement or punishment
Wekolamo Reply
please i need answer
Wekolamo
because it helps many people around the world to understand how to interact with other people and understand them well, for example at work (job).
Manix Reply
Agreed 👍 There are many parts of our brains and behaviors, we really need to get to know. Blessings for everyone and happy Sunday!
ARC
A child is a member of community not society elucidate ?
JESSY Reply
Isn't practices worldwide, be it psychology, be it science. isn't much just a false belief of control over something the mind cannot truly comprehend?
Simon Reply
compare and contrast skinner's perspective on personality development on freud
namakula Reply
Skinner skipped the whole unconscious phenomenon and rather emphasized on classical conditioning
war
explain how nature and nurture affect the development and later the productivity of an individual.
Amesalu Reply
nature is an hereditary factor while nurture is an environmental factor which constitute an individual personality. so if an individual's parent has a deviant behavior and was also brought up in an deviant environment, observation of the behavior and the inborn trait we make the individual deviant.
Samuel
I am taking this course because I am hoping that I could somehow learn more about my chosen field of interest and due to the fact that being a PsyD really ignites my passion as an individual the more I hope to learn about developing and literally explore the complexity of my critical thinking skills
Zyryn Reply
good👍
Jonathan
and having a good philosophy of the world is like a sandwich and a peanut butter 👍
Jonathan
generally amnesi how long yrs memory loss
Kelu Reply
interpersonal relationships
Abdulfatai Reply
What would be the best educational aid(s) for gifted kids/savants?
Heidi Reply
treat them normal, if they want help then give them. that will make everyone happy
Saurabh
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




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