Game Development Reference
In-Depth Information
The reason Flash does this is because it needs a point of refer-
ence to be able to instantiate that symbol on the stage if it is used
in script somewhere. To see the evidence of this, you can look at
all the classes embedded in a compiled SWF inside of FlashDeve-
lop. In Fig. 4.1 , you can see the Flash library on the left, with the
symbol exported with the name
and reflected on the
right in the FlashDevelop project panel with the classes used in
the SWF.
If you had a class defined for the square, it would use that file
rather than generating its own. To see the result of this, we can
renamethelinkageclassfor the symbol to uppercase
square
Square
to
match the name of a class I have defined for it.
package {
import flash.display.Sprite;
public class Square extends Sprite {
public function Square() {
rotation = 45;
}
}
}
Now,whenthesquareisaddedtothestage,itwillberotated
45 degrees.
Class versus Base Class
When you open the linkage panel to assign a class to a symbol,
there is an additional field that is used to define the base class for a
symbol. The base class symbol is where you define what class you
would like to extend for that symbol. In the previous example, the
Square class extended from Sprite, so the base class for that symbol
was flash.display.Sprite, as shown in Fig. 4.2 .
Figure 4.1 FlashDevelop can
reveal the classes used in a
SWF.
Search Nedrilad ::




Custom Search