10.4.11

This one's a Larf

If you really want to do something for a larf, link this script up to your FLA file and run it.



package  {
import flash.display.MovieClip;
import flash.events.*
import flash.system.*
import flash.errors.InvalidSWFError;
import flash.filters.BlurFilter;
import flash.display.ActionScriptVersion;
import flash.net.FileReferenceList;
import flash.desktop.Clipboard;
import flash.sensors.Geolocation;
import flash.external.ExternalInterface;
import flash.errors.IOError;
import flash.text.FontType;
import flash.text.CSMSettings;
import flash.ui.Keyboard;
import flash.ui.KeyboardType;
import flash.profiler.profile;
import flash.xml.XMLNode;
import flash.printing.PrintJobOptions;
import flash.ui.KeyLocation;

public class Structure extends MovieClip {
public function Structure() {
PlusListeners()
}
public function PlusListeners() {
stage.addEventListener(Event.ENTER_FRAME, Event1);
stage.addEventListener(Event.ENTER_FRAME, Event2);
stage.addEventListener(Event.ENTER_FRAME, Event3);
stage.addEventListener(Event.ENTER_FRAME, Event4);
stage.addEventListener(Event.ENTER_FRAME, Event5);
stage.addEventListener(Event.ENTER_FRAME, Event6);
stage.addEventListener(Event.ENTER_FRAME, Event7);
stage.addEventListener(Event.ENTER_FRAME, Event8);
stage.addEventListener(Event.ENTER_FRAME, Event9);
stage.addEventListener(Event.ENTER_FRAME, Event10);
}
private function Event1(event:Event):void {
trace("flash.system.ApplicationDomain.MIN_DOMAIN_MEMORY_LENGTH: " + flash.system.ApplicationDomain.MIN_DOMAIN_MEMORY_LENGTH)
}
private function Event2(event:Event):void {
trace("flash.system.Security.sandboxType: " + flash.system.Security.sandboxType);
}
private function Event3(event:Event):void {
trace ("flash.system.Capabilities.cpuArchitecture: " + flash.system.Capabilities.cpuArchitecture);
}
private function Event4(event:Event):void {
trace ("flash.errors.IOError: " + flash.errors.IOError);
}
private function Event5(event:Event):void {
trace ("flash.system.Capabilities.serverString: " + flash.system.Capabilities.serverString);
}
private function Event6(event:Event):void {
trace ("flash.display.ActionScriptVersion.ACTIONSCRIPT3: " + flash.display.ActionScriptVersion.ACTIONSCRIPT3);
}
private function Event7(event:Event):void {
trace("flash.ui.Keyboard.CharCodeStrings: " + flash.ui.Keyboard.CharCodeStrings);
}
private function Event8(event:Event):void {
trace ("flash.desktop.Clipboard.generalClipboard.formats: " + flash.desktop.Clipboard.generalClipboard.formats)
}
private function Event9(event:Event):void {
trace ("flash.external.ExternalInterface.objectID: " + flash.external.ExternalInterface.objectID); 
}
private function Event10(event:Event):void {
trace ("flash.system.IME.conversionMode: " + flash.system.IME.conversionMode);
}
}
}

What you're seeing here is the internal information that is stored deep inside Flash; everything from the Keyboard Character codes to the server string. 

The result should look like this:

flash.system.ApplicationDomain.MIN_DOMAIN_MEMORY_LENGTH: 1024
flash.system.Security.sandboxType: localTrusted
flash.system.Capabilities.cpuArchitecture: x86
flash.errors.IOError: [class IOError]
flash.system.Capabilities.serverString: A=t&SA=t&SV=t&EV=t&MP3=t&AE=t&VE=t&ACC=t&PR=t&SP=f&SB=f&DEB=t&V=WIN%2010%2C1%2C52%2C14&M=Adobe%20Windows&R=1280x1024&COL=color&AR=1.0&OS=Windows%20Vista&ARCH=x86&L=en&IME=t&PR32=t&PR64=f&PT=External&AVD=f&LFD=f&WD=f&TLS=t&ML=5.1&DP=72
flash.display.ActionScriptVersion.ACTIONSCRIPT3: 3
flash.ui.Keyboard.CharCodeStrings: Up,Down,Left,Right,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,F14,F15,F16,F17,F18,F19,F20,F21,F22,F23,F24,F25,F26,F27,F28,F29,F30,F31,F32,F33,F34,F35,Insert,Delete,Home,Begin,End,PgUp,PgDn,PrntScrn,ScrlLck,Pause,SysReq,Break,Reset,Stop,Menu,User,Sys,Print,ClrLn,ClrDsp,InsLn,DelLn,InsChr,DelChr,Prev,Next,Select,Exec,Undo,Redo,Find,Help,ModeSw
flash.desktop.Clipboard.generalClipboard.formats: air:text
flash.external.ExternalInterface.objectID: null
flash.system.IME.conversionMode: ALPHANUMERIC_HALF

9.4.11

How Does it Work?

Here's how the preceding code works. At the top you will see the import commands for all of the classes used within the document. Below that is the class declaration. This class is an extension of the Movieclip class because it is attached to my main FLA file, which can only instantiate a Movieclip.

Inside the Class declaration is the main constructor. This is the big branch that will spawn all of the little branches. Now within the constructor there is only one function to b run. This is PlusListeners(). All this function does is add ten event listeners to the stage.

As you can see in the body of PlusListeners(),  each of the ten listeners is  identical. Each listener waits for the FLA stage to dispatch an event. The name of that event is ENTER_FRAME. This event is dispatched every time the animation moves forward a frame, which will occur automatically unless you tell Flash to stop moving forward.

Anyway, at the end of each listener a function is called. In the first listener, that function is called Event1. After the right brace signifies that PlusListeners() is complete, each of the "Event" functions is . In the case of Event1, all the function does is call a trace function.

private function Event1(event:Event):void {
trace("This is event1")
}

This message will be printed in the output window of Flash every time a frame is passed in the animation.

You'll notice that at the end of the Actionscript file are three braces. The first declares an end to the Event10 function, the second declares that the Structure class has been completed, and the third denotes the completion of the package.

Event Listeners

I have finally come up with a standard Actionscript 3.0 structure that I will use in my future experiments. This is it:

package  {

import flash.display.MovieClip;
import flash.events.*

public class Structure extends MovieClip {


public function Structure() {
PlusListeners()
}

public function PlusListeners() {
stage.addEventListener(Event.ENTER_FRAME, Event1);
stage.addEventListener(Event.ENTER_FRAME, Event2);
stage.addEventListener(Event.ENTER_FRAME, Event3);
stage.addEventListener(Event.ENTER_FRAME, Event4);
stage.addEventListener(Event.ENTER_FRAME, Event5);
stage.addEventListener(Event.ENTER_FRAME, Event6);
stage.addEventListener(Event.ENTER_FRAME, Event7);
stage.addEventListener(Event.ENTER_FRAME, Event8);
stage.addEventListener(Event.ENTER_FRAME, Event9);
stage.addEventListener(Event.ENTER_FRAME, Event10);
}

private function Event1(event:Event):void {
trace("This is event1")
}
private function Event2(event:Event):void {
trace("This is event2");
}
private function Event3(event:Event):void {
trace ("This is event3");
}
private function Event4(event:Event):void {
trace ("This is event4");
}
private function Event5(event:Event):void {
trace ("This is event5");
}
private function Event6(event:Event):void {
trace ("This is event6");
}
private function Event7(event:Event):void {
trace("This is event7");
}
private function Event8(event:Event):void {
trace ("This is event8");
}
private function Event9(event:Event):void {
trace ("This is event9");
}
private function Event10(event:Event):void {
trace ("This is event10");

}

}

}
Now, I had a few unique errors when creating this. This is the first error:

C:\Users\Owner\Documents\FlashCS5\Structure\Structure.as, Line 26 1046: Type was not found or was not a compile-time constant: Event.

After some trial and error I figured this one out. When flash compiled my SWF, it was looking for the Event constant and couldn't find it because I hadn't imported it. Now often times flash will import classes automatically as needed, but there is no guarantee. Eventually you're going to have to learn the classes so that you can import them when you need them.

import flash.events.* 

The second error was a nail biter:

C:\Users\Owner\Documents\FlashCS5\Structure\Structure.as, Line 26 1126: Function does not have a body.

This is the function, (and it does have a body):

private function Event1(event:Event);{
trace("This is event1")
}

So why does Flash keep lying to me and saying that my function doesn't have a body when it does? Well, there's a semicolon at the end of the function when the compiler sees that semicolon, the function body becomes invisible. 

this version works:

private function Event1(event:Event):void {
                trace("This is event1")
                }