<< Chapter < Page Chapter >> Page >

Listing 4 begins by adding a Rect object whose dimensions cover one-hundred percent of the Flash window. (Note that all of the elements in Listing 4 are in the spark namespace named "s".)

What is a fill element?

Unfortunately, this is the point where you need become heavily involved in the concepts of object-oriented programming in ActionScript for the code in Listing 4 to makesense. I apologize in advance for the explanation that follows. However, I don't know any other way to explain it, so I will explain it using a combination ActionScript OOPterminology and mxml terminology.

What is a Rect element?

Rect is a class that represents a rectangle in the ActionScript packagenamed spark.primitives . The mxml code in Listing 4 causes an object of the Rect class to be placed in the Flash window in front of the white default background. As mentioned above, the dimensions of therectangle are such as to cover the entire Flash window, even when the size of the window is changed by the user. (Note that the name Rect begins with an upper-case character. That is a clue as to what is going on.)

Once again, what is a fill element?

Note that the name of this element begins with a lower-case character. That is also a clue as to what is going on. The fill element refers to a property of the Rect object. According to the documentation , the value of this property must be of type IFill .

What is type IFill ?

IFill is the name of an ActionScript interface . (Note that IFill begins with an upper-case character. Once again, that is a clue.) Declaring that the value of the property named fill must be of type IFill means that the value must be a reference to an object of any class that satisfies the interface requirements defined by IFill .

According to the documentation , the following classes satisfy that requirement:

Add a LinearGradient object

The next thing that appears in Listing 4 is an element named LinearGradient . (Note that LinearGradient begins with an upper-case character.) According to the documentation , LinearGradient is a class in the ActionScript package named mx.graphics . (It isn't clear how it can be accessed via the spark namespace, but as you can see in Listing 4, that is obviously thecase.)

What have we accomplished so far?

Up to this point, the interpretation of the code in Listing 4 is that we have:

  1. Created a Rect object, set its width and height attributes to completely cover the Flash window, and added it to the FlashWindow.
  2. Created a LinearGradient object, set its rotation attribute to 90, and assigned its reference to the fill property of the Rect object.

The element named entries

The next thing that we see in Listing 4 is an element named entries that is added to the LinearGradient element. Once again, note that this name begins with a lower-case character.

The documentation tells us that the LinearGradient class has a property named entries . The documentation further tells us that the value of this property must be an array containing references to objects of the class named GradientEntry . These objects "define the fill pattern for the gradient fill."

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Introduction to xml. OpenStax CNX. Dec 02, 2014 Download for free at https://legacy.cnx.org/content/col11207/1.18
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Introduction to xml' conversation and receive update notifications?

Ask