[flash-thunderbolt commit] r139 - in trunk: . as2 as2/docs as2/docs/img as2/example as2/example/deploy as2/example/deploy/cs...

13 views
Skip to first unread message

codesite...@google.com

unread,
Apr 14, 2008, 12:41:06 AM4/14/08
to flash-th...@googlegroups.com
Author: sectore
Date: Sun Apr 13 02:28:07 2008
New Revision: 139

Added:
trunk/as2/
trunk/as2/build.xml
trunk/as2/docs/
trunk/as2/docs/img/
trunk/as2/docs/img/console_details.gif (contents, props changed)
trunk/as2/docs/img/console_inspect.gif (contents, props changed)
trunk/as2/docs/img/console_output.gif (contents, props changed)
trunk/as2/docs/img/console_sample.gif (contents, props changed)
trunk/as2/example/
trunk/as2/example/deploy/
trunk/as2/example/deploy/css/
trunk/as2/example/deploy/css/styles.css
trunk/as2/example/deploy/js/
trunk/as2/example/deploy/js/swfobject.js
trunk/as2/example/deploy/thunderbolt.html
trunk/as2/example/deploy/thunderbolt.swf (contents, props changed)
trunk/as2/example/source/
trunk/as2/example/source/Sample.as
trunk/as2/example/source/Sample.fla (contents, props changed)
trunk/as2/source/
trunk/as2/source/org/
trunk/as2/source/org/osflash/
trunk/as2/source/org/osflash/thunderbolt/
trunk/as2/source/org/osflash/thunderbolt/Logger.as
trunk/as2/source/org/osflash/thunderbolt/Settings.as
trunk/as2/source/org/osflash/thunderbolt/data/
trunk/as2/source/org/osflash/thunderbolt/data/JSReturn.as
trunk/as2/source/org/osflash/thunderbolt/data/ObjectType.as
trunk/as2/source/org/osflash/thunderbolt/data/Parser.as
trunk/as2/source/org/osflash/thunderbolt/data/StringyfiedObject.as
trunk/as2/source/org/osflash/thunderbolt/io/
trunk/as2/source/org/osflash/thunderbolt/io/Commandline.as
trunk/as2/source/org/osflash/thunderbolt/io/Console.as
trunk/as2/source/org/osflash/thunderbolt/io/JavaScriptInterface.as
trunk/as2/source/org/osflash/thunderbolt/logging/
trunk/as2/source/org/osflash/thunderbolt/logging/LogInfo.as
trunk/as2/source/org/osflash/thunderbolt/logging/LogLevel.as
trunk/as2/source/org/osflash/thunderbolt/profiling/
trunk/as2/source/org/osflash/thunderbolt/profiling/ProfileHandle.as
trunk/as2/source/org/osflash/thunderbolt/profiling/Profiler.as
trunk/as2/thunderbolt_classes.zip (contents, props changed)
Removed:
trunk/build.xml
Modified:
trunk/as3/example/flex/bin/AC_OETags.js
trunk/as3/example/flex/bin/ThunderBoltFlexExample.html
trunk/as3/example/flex/bin/ThunderBoltFlexExample.swf
trunk/as3/example/flex/src/ThunderBoltFlexExample.mxml
trunk/as3/example/flex/src/ThunderBoltTargetExample.mxml

Log:
- structure updated

Added: trunk/as2/build.xml
==============================================================================
--- (empty file)
+++ trunk/as2/build.xml Sun Apr 13 02:28:07 2008
@@ -0,0 +1,60 @@
+<?xml version='1.0' encoding="utf-8"?>
+<project name="ThunderBolt AS2 Logger" default="Compile and Launch" basedir=".">
+ <description>
+ ThunderBolt example Main Build File
+ </description>
+
+ <!--
+ global properties "mtasc", "firefox" and "flash.classpath" need to
be set up as global ant parameters!
+ eclipse > window > preferences > ant > runtime > properties
+ -->
+
+ <property name="example.classpath" value=".\example\source\" />
+ <property name="example.folder" value=".\example\deploy\" />
+ <property name="example.html" value="thunderbolt.html"/>
+ <property name="example.zip" value="thunderbolt_classes.zip"/>
+
+ <property name="thunderbolt.classpath" value=".\source\" />
+
+ <target name="Compile SWF" description="compile example swf using mtasc">
+ <property name="example.swf" value="thunderbolt.swf"/>
+ <property name="example.main" value="Sample.as" />
+
+ <echo>SWF: ${example.swf}</echo>
+ <echo>Main: ${example.main}</echo>
+
+ <exec executable="${mtasc}" failonerror="true">
+ <!-- set swf version -->
+ <arg line="-v -mx -version 8"/>
+
+ <!-- add example class paths and set output file -->
+ <arg line="-cp ${example.classpath}"/>
+ <arg line="-swf ${example.folder}\${example.swf}"/>
+ <arg line="-main ${example.main}"/>
+
+ <!-- add thunderbolt classes and trace facilities-->
+ <arg line="-cp ${thunderbolt.classpath}"/>
+ <arg line="-trace org.osflash.thunderbolt.Logger.trace org/osflash/thunderbolt/Logger"/>
+ </exec>
+ </target>
+
+ <target name="Launch HTML" description="Open HTML in Firefox">
+ <echo>Open Firefox: ${firefox} ${example.folder}${example.html}</echo>
+ <exec executable="${firefox}" spawn="true">
+ <arg value="${example.folder}${example.html}"/>
+ </exec>
+
+ </target>
+
+ <target name="Compile and Launch">
+ <antcall target="Compile SWF"/>
+ <antcall target="Launch HTML"/>
+ </target>
+
+ <!-- Compile a single ZIP containing all package source files -->
+ <target name="Create ZIP" depends="Compile SWF" description="Create
ZIP file of classes">
+ <echo>Create ZIP...</echo>
+ <zip destfile="thunderbolt_classes.zip"
basedir="${thunderbolt.classpath}" />
+ </target>
+
+</project>
\ No newline at end of file

Added: trunk/as2/docs/img/console_details.gif
==============================================================================
Binary file. No diff available.

Added: trunk/as2/docs/img/console_inspect.gif
==============================================================================
Binary file. No diff available.

Added: trunk/as2/docs/img/console_output.gif
==============================================================================
Binary file. No diff available.

Added: trunk/as2/docs/img/console_sample.gif
==============================================================================
Binary file. No diff available.

Added: trunk/as2/example/deploy/css/styles.css
==============================================================================
--- (empty file)
+++ trunk/as2/example/deploy/css/styles.css Sun Apr 13 02:28:07 2008
@@ -0,0 +1,25 @@
+body {
+ background-color:#FFFFFF;
+ color:#242E35;
+ font-family:"Lucida Grande","Lucida Sans Unicode",Arial,Helvetica,sans-serif;
+ font-size:12px;
+ margin:10px 10px;
+}
+
+#code_samples{
+
+ font-family: "Courier New", Courier, monospace;
+ font-size: 12px;
+ color: #666666;
+}
+
+#code_samples a{
+
+ text-decoration: none;
+ color: #000099;
+}
+
+#code_samples a:hover{
+
+ text-decoration: underline;
+}
\ No newline at end of file

Added: trunk/as2/example/deploy/js/swfobject.js
==============================================================================
--- (empty file)
+++ trunk/as2/example/deploy/js/swfobject.js Sun Apr 13 02:28:07 2008
@@ -0,0 +1,233 @@
+/**
+ * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
+ *
+ * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
+ * http://www.opensource.org/licenses/mit-license.php
+ *
+ */
+if(typeof deconcept == "undefined") var deconcept = new Object();
+if(typeof deconcept.util == "undefined") deconcept.util = new Object();
+if(typeof deconcept.SWFObjectUtil == "undefined")
deconcept.SWFObjectUtil = new Object();
+deconcept.SWFObject = function(swf, id, w, h, ver, c, quality,
xiRedirectUrl, redirectUrl, detectKey) {
+ if (!document.getElementById) { return; }
+ this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
+ this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
+ this.params = new Object();
+ this.variables = new Object();
+ this.attributes = new Array();
+ if(swf) { this.setAttribute('swf', swf); }
+ if(id) { this.setAttribute('id', id); }
+ if(w) { this.setAttribute('width', w); }
+ if(h) { this.setAttribute('height', h); }
+ if(ver) { this.setAttribute('version', new
deconcept.PlayerVersion(ver.toString().split("."))); }
+ this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion();
+ if (!window.opera && document.all && this.installedVer.major > 7) {
+ // only add the onunload cleanup if the Flash Player version
supports External Interface and we are in IE
+ deconcept.SWFObject.doPrepUnload = true;
+ }
+ if(c) { this.addParam('bgcolor', c); }
+ var q = quality ? quality : 'high';
+ this.addParam('quality', q);
+ this.setAttribute('useExpressInstall', false);
+ this.setAttribute('doExpressInstall', false);
+ var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
+ this.setAttribute('xiRedirectUrl', xir);
+ this.setAttribute('redirectUrl', '');
+ if(redirectUrl) { this.setAttribute('redirectUrl', redirectUrl); }
+}
+deconcept.SWFObject.prototype = {
+ useExpressInstall: function(path) {
+ this.xiSWFPath = !path ? "expressinstall.swf" : path;
+ this.setAttribute('useExpressInstall', true);
+ },
+ setAttribute: function(name, value){
+ this.attributes[name] = value;
+ },
+ getAttribute: function(name){
+ return this.attributes[name];
+ },
+ addParam: function(name, value){
+ this.params[name] = value;
+ },
+ getParams: function(){
+ return this.params;
+ },
+ addVariable: function(name, value){
+ this.variables[name] = value;
+ },
+ getVariable: function(name){
+ return this.variables[name];
+ },
+ getVariables: function(){
+ return this.variables;
+ },
+ getVariablePairs: function(){
+ var variablePairs = new Array();
+ var key;
+ var variables = this.getVariables();
+ for(key in variables){
+ variablePairs[variablePairs.length] = key +"="+ variables[key];
+ }
+ return variablePairs;
+ },
+ getSWFHTML: function() {
+ var swfNode = "";
+ if (navigator.plugins && navigator.mimeTypes &&
navigator.mimeTypes.length) { // netscape plugin architecture
+ if (this.getAttribute("doExpressInstall")) {
+ this.addVariable("MMplayerType", "PlugIn");
+ this.setAttribute('swf', this.xiSWFPath);
+ }
+ swfNode = '<embed type="application/x-shockwave-flash" src="'+
this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'"
height="'+ this.getAttribute('height') +'" style="'+
this.getAttribute('style') +'"';
+ swfNode += ' id="'+ this.getAttribute('id') +'" name="'+
this.getAttribute('id') +'" ';
+ var params = this.getParams();
+ for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; }
+ var pairs = this.getVariablePairs().join("&");
+ if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; }
+ swfNode += '/>';
+ } else { // PC IE
+ if (this.getAttribute("doExpressInstall")) {
+ this.addVariable("MMplayerType", "ActiveX");
+ this.setAttribute('swf', this.xiSWFPath);
+ }
+ swfNode = '<object id="'+ this.getAttribute('id') +'"
classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+
this.getAttribute('width') +'" height="'+ this.getAttribute('height')
+'" style="'+ this.getAttribute('style') +'">';
+ swfNode += '<param name="movie" value="'+ this.getAttribute('swf')
+'" />';
+ var params = this.getParams();
+ for(var key in params) {
+ swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
+ }
+ var pairs = this.getVariablePairs().join("&");
+ if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+
pairs +'" />';}
+ swfNode += "</object>";
+ }
+ return swfNode;
+ },
+ write: function(elementId){
+ if(this.getAttribute('useExpressInstall')) {
+ // check to see if we need to do an express install
+ var expressInstallReqVer = new deconcept.PlayerVersion([6,0,65]);
+ if (this.installedVer.versionIsValid(expressInstallReqVer)
&& !this.installedVer.versionIsValid(this.getAttribute('version'))) {
+ this.setAttribute('doExpressInstall', true);
+ this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));
+ document.title = document.title.slice(0, 47) + " - Flash Player Installation";
+ this.addVariable("MMdoctitle", document.title);
+ }
+ }
+ if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){
+ var n = (typeof elementId == 'string') ?
document.getElementById(elementId) : elementId;
+ n.innerHTML = this.getSWFHTML();
+ return true;
+ }else{
+ if(this.getAttribute('redirectUrl') != "") {
+ document.location.replace(this.getAttribute('redirectUrl'));
+ }
+ }
+ return false;
+ }
+}
+
+/* ---- detection functions ---- */
+deconcept.SWFObjectUtil.getPlayerVersion = function(){
+ var PlayerVersion = new deconcept.PlayerVersion([0,0,0]);
+ if(navigator.plugins && navigator.mimeTypes.length){
+ var x = navigator.plugins["Shockwave Flash"];
+ if(x && x.description) {
+ PlayerVersion = new
deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|
\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
+ }
+ }else if (navigator.userAgent && navigator.userAgent.indexOf("Windows
CE") >= 0){ // if Windows CE
+ var axo = 1;
+ var counter = 3;
+ while(axo) {
+ try {
+ counter++;
+ axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+ counter);
+// document.write("player v: "+ counter);
+ PlayerVersion = new deconcept.PlayerVersion([counter,0,0]);
+ } catch (e) {
+ axo = null;
+ }
+ }
+ } else { // Win IE (non mobile)
+ // do minor version lookup in IE, but avoid fp6 crashing issues
+ // see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
+ try{
+ var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
+ }catch(e){
+ try {
+ var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
+ PlayerVersion = new deconcept.PlayerVersion([6,0,21]);
+ axo.AllowScriptAccess = "always"; // error if player version <
6.0.47 (thanks to Michael Williams @ Adobe for this code)
+ } catch(e) {
+ if (PlayerVersion.major == 6) {
+ return PlayerVersion;
+ }
+ }
+ try {
+ axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
+ } catch(e) {}
+ }
+ if (axo != null) {
+ PlayerVersion = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
+ }
+ }
+ return PlayerVersion;
+}
+deconcept.PlayerVersion = function(arrVersion){
+ this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0;
+ this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0;
+ this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0;
+}
+deconcept.PlayerVersion.prototype.versionIsValid = function(fv){
+ if(this.major < fv.major) return false;
+ if(this.major > fv.major) return true;
+ if(this.minor < fv.minor) return false;
+ if(this.minor > fv.minor) return true;
+ if(this.rev < fv.rev) return false;
+ return true;
+}
+/* ---- get value of query string param ---- */
+deconcept.util = {
+ getRequestParameter: function(param) {
+ var q = document.location.search || document.location.hash;
+ if (param == null) { return q; }
+ if(q) {
+ var pairs = q.substring(1).split("&");
+ for (var i=0; i < pairs.length; i++) {
+ if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
+ return pairs[i].substring((pairs[i].indexOf("=")+1));
+ }
+ }
+ }
+ return "";
+ }
+}
+/* fix for video streaming bug */
+deconcept.SWFObjectUtil.cleanupSWFs = function() {
+ var objects = document.getElementsByTagName("OBJECT");
+ for (var i = objects.length - 1; i >= 0; i--) {
+ objects[i].style.display = 'none';
+ for (var x in objects[i]) {
+ if (typeof objects[i][x] == 'function') {
+ objects[i][x] = function(){};
+ }
+ }
+ }
+}
+// fixes bug in some fp9 versions see http://blog.deconcept.com/2006/07/28/swfobject-143-released/
+if (deconcept.SWFObject.doPrepUnload) {
+ if (!deconcept.unloadSet) {
+ deconcept.SWFObjectUtil.prepUnload = function() {
+ __flash_unloadHandler = function(){};
+ __flash_savedUnloadHandler = function(){};
+ window.attachEvent("onunload", deconcept.SWFObjectUtil.cleanupSWFs);
+ }
+ window.attachEvent("onbeforeunload", deconcept.SWFObjectUtil.prepUnload);
+ deconcept.unloadSet = true;
+ }
+}
+/* add document.getElementById if needed (mobile IE < 5) */
+if (!document.getElementById && document.all) {
document.getElementById = function(id) { return document.all[id]; }}
+
+/* add some aliases for ease of use/backwards compatibility */
+var getQueryParamValue = deconcept.util.getRequestParameter;
+var FlashObject = deconcept.SWFObject; // for legacy support
+var SWFObject = deconcept.SWFObject;

Added: trunk/as2/example/deploy/thunderbolt.html
==============================================================================
--- (empty file)
+++ trunk/as2/example/deploy/thunderbolt.html Sun Apr 13 02:28:07 2008
@@ -0,0 +1,99 @@
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
+ <title>ThunderBolt - Flash Debugging At Your Webbrowser</title>
+
+ <script type="text/javascript" src="js/swfobject.js"></script>
+
+ <script type="text/javascript">
+
+ var thunderbolt = {
+
+ file: "thunderbolt.swf",
+ version: 0.34,
+ movie: null,
+ target: "flashcontent",
+
+ init: function(){
+
+ var url = this.file + "?version=" + this.version;
+
+ this.movie = new SWFObject(
+
+ url, "ThunderBolt", 400, 200, 8, "#fff"
+ );
+
+ this.movie.addParam("allowScriptAccess", "always");
+ this.movie.write(this.target);
+ },
+
+ initSampleCode: function(){
+
+ var links = document.getElementById("code_samples").getElementsByTagName("a");
+
+ for (var i=0; i<links.length; i++){
+
+ var link = links[i];
+ link.href = "javascript:" + link.innerHTML;
+ }
+ }
+ }
+
+ </script>
+
+ <link type="text/css" rel="stylesheet" href="css/styles.css"/>
+
+</head>
+
+<body onLoad="thunderbolt.initSampleCode();">
+
+ <div id="flashcontent">
+
+ <script type="text/javascript">
+ thunderbolt.init();
+ </script>
+
+ </div>
+
+ <div>
+ <p>
+ Make sure you have
+ <a href="http://www.getfirefox.com" target="_blank">Firefox</a> and
+ <a href="http://www.getfirebug.com/" target="_blank">Firebug</a> enabled.<br/>
+ Open Firebug to see the returned messages.
+ </p>
+
+ <h3>Try these commands via the Firebug console:</h3>
+
+ <div id="code_samples">
+
+ <p>
+ // inspect obejcts and set attributes <br/>
+ <a href="#">TB.inspect("_root");</a> // inspect movieclip
_level0 <br/>
+ <a href="#">TB.inspect("Sample.APP.profileObject");</a> //
inspect object <br/>
+ <a href="#">TB.set("_root.logo._x", 20);</a> // set new
position <br/>
+ <a href="#">TB.set("_root.logo.label.text", "Live hacking made
possible!");</a> // change text<br/>
+ </p>
+ <p>
+ // set context for later inspection <br/>
+ <a href="#">TB.cd("_root.logo.label");</a> // set new context<br/>
+ <a href="#">TB.inspect("_x");</a> // x position of
current content<br/>
+ <a href="#">TB.cd("..");</a> // select parent movieclip<br/>
+ </p>
+ <p>
+ // execute methods <br/>
+ <a href="#">TB.run("Sample.APP.randomizeAlpha(100)");</a> //
run a method<br/>
+ <a href="#">TB.run("Sample.APP.restoreAlpha()");</a> // run
another method<br/>
+ </p>
+ <p>
+ // test performance <br/>
+ <a href="#">TB.profile("Sample.APP.profileObject");</a> //
start profiling for all methods in object<br/>
+ <a href="#">TB.run("Sample.APP.profileObject.method2()");</a> //
execute profiling test<br/>
+ <a href="#">TB.profileEnd();</a> // stop profiling and
see results<br/>
+ </p>
+ </div>
+
+ <p>Read more about <a
href="http://code.google.com/p/flash-thunderbolt/">this project</a>.</p>
+ </div>
+</body>
+</html>

Added: trunk/as2/example/deploy/thunderbolt.swf
==============================================================================
Binary file. No diff available.

Added: trunk/as2/example/source/Sample.as
==============================================================================
--- (empty file)
+++ trunk/as2/example/source/Sample.as Sun Apr 13 02:28:07 2008
@@ -0,0 +1,142 @@
+import mx.utils.Delegate;
+import org.osflash.thunderbolt.profiling.Profiler;
+import org.osflash.thunderbolt.profiling.ProfileHandle;
+import org.osflash.thunderbolt.data.StringyfiedObject;
+import org.osflash.thunderbolt.io.Console;
+
+
+/**
+ * @author Martin Kleppe kle...@gmail.com
+ */
+class Sample {
+ public static var APP:Sample;
+ private var profileObject:Object;
+
+ function Sample() {
+ this.init();
+ }
+
+ // entry point
+ public static function main(mc:MovieClip):Void {
+ Sample.APP = new Sample();
+ }
+
+ private function init():Void{
+ trace("Init Sample Class");
+ for (var all in _root){
+ _root[all].onRelease = function(){
+ Sample.APP[this._name.split("Button")[0] + "Test"]();
+ };
+ }
+
+ this.profileObject = {
+ method1: function(){
+ var sum:Number = 0;
+ for (var i:Number=0; i<1000; i++) { sum += i; }
+ return sum;
+ },
+
+ method2: function(){
+ var sum:Number = 0;
+ for (var i:Number=0; i<1000; i++){ sum += this.method1(); }
+ return sum;
+ }
+ };
+ }
+
+ private function completeTest(){
+ this.logTest();
+ this.infoTest();
+ this.warnTest();
+ this.errorTest();
+ this.dateTest();
+ this.arrayTest();
+ this.objectTest();
+ this.xmlTest();
+ this.movieclipTest();
+ this.multilineTest();
+ this.groupTest();
+ this.profileTest();
+ }
+
+ private function logTest():Void{
+ trace("d This is a simple debug message.");
+ }
+
+ private function infoTest():Void{
+ trace("i An info icon will appear next to this line.");
+ }
+
+ private function warnTest():Void{
+ trace("w This warning message is highlighted.");
+ }
+
+ private function errorTest():Void{
+ trace("e Red and highlited error message.");
+ }
+
+ private function dateTest():Void{
+ trace(new Date());
+ }
+
+ private function arrayTest():Void{
+ trace([1, "2", "three", "IV", "101", {six:"seven"}]);
+ }
+
+ private function objectTest():Void{
+ trace({
+ a: "Hello",
+ b: "World",
+ c: {
+ d: "Here",
+ e: "We",
+ f: {
+ g: "Are"
+ }
+ }
+ });
+ }
+
+ private function xmlTest():Void{
+ trace(new XML("<parent><child id='first'>First
Paragraph</child><child id='second'><subchild>Subchild text content</subchild></child></parent>"));
+ }
+
+ private function movieclipTest():Void{
+ trace(_root);
+ }
+
+ private function groupTest():Void{
+ trace("+++ manually grouped output");
+ trace("these message has 'been' grouped");
+ trace("... with \"another\" message");
+ trace("---");
+ }
+
+ private function multilineTest():Void{
+ trace("multi \nline \rmessage");
+ }
+
+ private function profileTest():Void{
+ Profiler.start(this.profileObject);
+ trace("+++ Test Run: " + this.profileObject.method2());
+ var log:Array = Profiler.stop();
+ for (var i:Number=0; i<log.length; i++) {
+ trace(log[i]);
+ };
+ trace("---");
+ }
+
+ public function randomizeAlpha(value:Number):String{
+ for (var all in _root){
+ _root[all]._alpha = 100 - random(value);
+ }
+ return "Alpha randomized";
+ }
+
+ public function restoreAlpha():String{
+ for (var all in _root){
+ _root[all]._alpha = 100;
+ }
+ return "Alpha restored";
+ }
+}
\ No newline at end of file

Added: trunk/as2/example/source/Sample.fla
==============================================================================
Binary file. No diff available.

Added: trunk/as2/source/org/osflash/thunderbolt/Logger.as
==============================================================================
--- (empty file)
+++ trunk/as2/source/org/osflash/thunderbolt/Logger.as Sun Apr 13
02:28:07 2008
@@ -0,0 +1,118 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ *
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is the Thunderbolt Flash Debugging Interface.
+ *
+ * Contributors:
+ * - Martin Kleppe <kle...@gmail.com>
+ * - Jens Krause
+ *
+ * Project Home Page:
+ * http://code.google.com/p/flash-thunderbolt/
+ *
+ * ***** END LICENSE BLOCK *****
+ */
+
+import flash.external.ExternalInterface;
+import org.osflash.thunderbolt.data.Parser;
+import org.osflash.thunderbolt.io.Console;
+import org.osflash.thunderbolt.data.StringyfiedObject;
+import org.osflash.thunderbolt.io.Commandline;
+import org.osflash.thunderbolt.logging.LogInfo;
+import org.osflash.thunderbolt.logging.LogLevel;
+import org.osflash.thunderbolt.Settings;
+/**
+ * @author Martin Kleppe <kle...@gmail.com>
+ * @link http://code.google.com/p/flash-thunderbolt/
+ */
+
+class org.osflash.thunderbolt.Logger {
+
+ private static var initialized:Boolean = Logger.initialize();
+ public static var stopped:Boolean;
+
+ private var classes:Array = [Commandline];
+
+ private static function initialize():Boolean{
+ Logger.stopped = Settings.INITALLY_STOPPED;
+ return true;
+ }
+
+ /**
+ * Compiling your project using the MTASC trace command will replace
+ * all calls of trace by calls to your custom trace function
+ * and will add more parameters that contains debug infos such as
+ * full class name with method name, file name and line number
+ */
+ public static function trace(traceObject:Object,
fullClassWithMethodName:String, fileName:String, lineNumber:Number){
+
+ // send traces to console
+ // but only if Firebug is available
+ if (Console.enabled){
+ if (Logger.stopped){
+ return;
+ }
+ // get more detailed information about current trace
+ var info:LogInfo = new LogInfo(traceObject,
fullClassWithMethodName, fileName, lineNumber);
+ if (!info.matchClassFilter()){
+ return;
+ }
+
+ // check if movie has entered a new frame
+ info.checkFrameGroup();
+
+ if (String(traceObject).indexOf("+++") == 0){
+ if (Settings.LOG_LEVEL == LogLevel.LOG){
+ var message:String =
String(traceObject).slice(String(traceObject).charAt(3) == " " ? 4 : 3);
+ // open group
+ Console.group(message + (message ? " " : "") + "(" +
fullClassWithMethodName + ")");
+ }
+ } else if (traceObject == "---"){
+ if (Settings.LOG_LEVEL == LogLevel.LOG){
+ // close group
+ Console.groupEnd();
+ }
+ } else {
+ // switch between console actions: log, info, warn, error
+ var logLevel:LogLevel = new LogLevel(traceObject);
+
+ if (logLevel.sendToOutput){
+ // check if message should be sliced
+ traceObject = logLevel.messageModified ? logLevel.message : traceObject;
+ // start group for xml output
+ // if (info.objectType == "xml" || info.objectType == "xmlnode"){
+ //TODO: to debug XML output
+ if (false){
+ Console.group(info, new StringyfiedObject(traceObject));
+ Console.dirxml(traceObject);
+ Console.groupEnd();
+ // group multi line strings
+ } else if (typeof traceObject == "string" &&
traceObject.indexOf("\n") > -1 && logLevel.console == Console.log) {
+ // begin group
+ Console.group(info);
+ // log single lines
+ var lines:Array = traceObject.split("\n");
+ for (var i:Number = 0; i < lines.length; i++){
+ Console.log(lines[i]);
+ }
+ // end group
+ Console.groupEnd();
+ } else {
+ // request javascript action
+ logLevel.console(info, ":", new StringyfiedObject(traceObject));

+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file

Added: trunk/as2/source/org/osflash/thunderbolt/Settings.as
==============================================================================
--- (empty file)
+++ trunk/as2/source/org/osflash/thunderbolt/Settings.as Sun Apr 13
02:28:07 2008
@@ -0,0 +1,66 @@
+import org.osflash.thunderbolt.logging.LogLevel;
+/**
+ * @author Martin Kleppe <kle...@gmail.com>
+ *
+ * Change these settings for your need.
+ *
+ */
+class org.osflash.thunderbolt.Settings {
+
+ /*
+ * Set this flag to false if you do not want to group messages by frames.
+ */
+ public static var USE_FRAME_COUNTER:Boolean = true;
+
+ /*
+ * Set the debugger log level.
+ *
+ * LogLevel.LOG - traces all messages
+ * LogLevel.INFO - traces info, warning, error and fatal messages
+ * LogLevel.WARNING - traces warning, error and fatal messages
+ * LogLevel.ERROR - traces error and fatal messages
+ * LogLevel.FATAL - traces fatal messages only
+ */
+ public static var LOG_LEVEL:String = LogLevel.LOG;
+
+ /*
+ * If you want to trace debug messages only at a specific time
+ * you may set this value to "true" and later activate the debugger
+ * calling ThunderBolt.start(); via the console.
+ */
+ public static var INITALLY_STOPPED:Boolean = false;
+
+ /*
+ * Set this property to false if you expect problems with the
+ * External Interface Logger.
+ */
+ public static var USE_EXTERNAL_INTERFACE:Boolean = true;
+
+ /*
+ * Set a handy shortcut to call methods from the FireBug
+ * JavaScript console.
+ *
+ * eg: ThunderBolt.inspect("_root");
+ * TB.inspect("_root");
+ */
+ public static var JAVASCRIPT_CONSOLE_SHORTCUT:String = "TB";
+
+ /*
+ * Increase this property if you want more details about
+ * complex object structures.
+ */
+ public static var COMPLEX_RECURSION_DEPTH:Number = 3;
+
+ /*
+ * Use this filter to trace messages only from specific
+ * classes. To filter classes located in a specific
+ * package simply add the "*" wildcard character.
+ *
+ * You can later change the filter via the console:
+ *
+ * eg: ThunderBolt.filter("org.osflash.thunderbolt.Settings");
+ * ThunderBolt.filter("org.osflash.*");
+ *
+ */
+ public static var CLASS_FILTER:String = "*";
+}
\ No newline at end of file

Added: trunk/as2/source/org/osflash/thunderbolt/data/JSReturn.as
==============================================================================
--- (empty file)
+++ trunk/as2/source/org/osflash/thunderbolt/data/JSReturn.as Sun Apr
13 02:28:07 2008
@@ -0,0 +1 @@
+/**
* Simple JSON wrapper.
* Pass inner function block and wrap it.
*
* @author Martin Kleppe <kle...@gmail.com>
*/
class org.osflash.thunderbolt.data.JSReturn {

public var codeFragment:String;

/**
* Javascript code fragment wrapper.
* @param codeFragment Code block to wrap.
*/
function JSReturn(codeFrament:String){
this.codeFragment = codeFrament;
}

/**
* Returns an self executing function call.
* @return Wrapped function call.
*/
public function toString():String{
return "(function(){" + this.codeFragment + "})()";
}
}
\ No newline at end of file

Added: trunk/as2/source/org/osflash/thunderbolt/data/ObjectType.as
==============================================================================
--- (empty file)
+++ trunk/as2/source/org/osflash/thunderbolt/data/ObjectType.as Sun Apr
13 02:28:07 2008
@@ -0,0 +1,58 @@
+/**
+ * @author Martin Kleppe <kle...@gmail.com>
+ */
+class org.osflash.thunderbolt.data.ObjectType {
+
+ private static var simpleTypes:Array = [
+ "string",
+ "boolean",
+ "number",
+ "undefined",
+ "null"
+ ];
+
+ private static var complexTypes:Object = {
+ xmlnode: XMLNode,
+ xml: XML,
+ textfield: TextField,
+ button: Button,
+ movieclip: MovieClip,
+ array: Array,
+ date: Date
+ };
+
+ /**
+ * Get the "real" type of an object. Possible values are:
+ * undefined, null, number, string, boolean, number,
+ * object, array, date, movieclip, button, textfield,
+ * xml and xmlnode.
+ *
+ * @param target The object to analyse.
+ * @return Object type.
+ */
+ static function get(target:Object):String{
+ for (var i:Number=0; i<ObjectType.simpleTypes.length; i++) {
+ if (ObjectType.simpleTypes[i] == typeof(target)){
+ return ObjectType.simpleTypes[i];
+ }
+ }
+ for (var type:String in ObjectType.complexTypes) {
+ if (target instanceof ObjectType.complexTypes[type]){
+ return type;
+ }
+ }
+ return typeof target;
+ }
+
+
+ /**
+ * Test if the object type is complex. This could be used
+ * to execute recursive code executions.
+ *
+ * @param type The object type
+ * @return True if object type is complex
+ */
+ static function isComplex(type:Object):Boolean{
+ return type == "object" || type == "movieclip";
+ }
+}
\ No newline at end of file

Added: trunk/as2/source/org/osflash/thunderbolt/data/Parser.as
==============================================================================
--- (empty file)
+++ trunk/as2/source/org/osflash/thunderbolt/data/Parser.as Sun Apr 13
02:28:07 2008
@@ -0,0 +1,106 @@
+import org.osflash.thunderbolt.data.ObjectType;
+import org.osflash.thunderbolt.Settings;
+/**
+ * A Parser to convert an object into its JavaScript Object Notation
+ * (JSON) so it could be passed to JavaScipt calls.
+ *
+ * @author Martin Kleppe <kle...@gmail.com>
+ */
+
+class org.osflash.thunderbolt.data.Parser{
+
+ // movieclip properties that should be displayed
+ private static var mcProperties:Array = [
+ "_x",
+ "_y",
+ "_width",
+ "_height",
+ "_xscale",
+ "_yscale",
+ "_alpha"
+ ];
+
+ /**
+ * Converts an object into its JavaScript Object Notation (JSON)
+ * so it could be passed to JavaScipt calls.
+ *
+ * @param target Object to stringify
+ * @param depth Optional paramter specifying the level of recusion
+ * @return Stringified object in JavaScript Object Notation (JSON)
+ *
+ * @see http://www.json.org/json.as
+ */
+ public static function stringify(target:Object, depth:Number,
label:String):String {
+
+ var output:String = '';
+ var type:String = ObjectType.get(target);
+
+ if (depth === undefined){
+ depth = Settings.COMPLEX_RECURSION_DEPTH;
+ }
+
+ // stop execution if depth is equal or less than zero
+ var stopAnalysing:Boolean = depth <= 0;
+ if (stopAnalysing){
+ return ObjectType.isComplex(type) ? Parser.returnString(type, true,
true) : Parser.stringify(target);
+ }
+
+ switch (type) {
+ case 'textfield':
+ return Parser.returnString(type, true, true);
+ output = Parser.returnString("textfield | " + target, false, true);
+ for (var all:String in target) {
+ output += "," + all + ':' + Parser.stringify(target[all].toString());
+ }
+ return "{" + output + "}";
+
+ case 'button':
+ case 'movieclip':
+ output = Parser.returnString(type + " | " + target, false, true);
+ for (var i:Number=0; i< Parser.mcProperties.length; i++) {
+ var property:String = Parser.mcProperties[i];
+ output += "," + property + ":" + target[property];
+ }
+ case 'object':
+ for (var all:String in target) {
+ output += (output ? "," : "") + all + ':' +
Parser.stringify(target[all], depth-1);
+ }
+ if (label) {
+ output += (output ? "," : "") + Parser.returnString(label);
+ }
+ return '{' + output + '}';
+ case 'array':
+ for (var i:Number = 0; i < target.length; i++) {
+ output += (output ? "," : "") +
Parser.stringify(target[i], depth-1);
+ }
+ return '[' + output + ']';
+ case 'number': return isFinite(target) ? String(target) : 'null';
+ case 'string':
+ if (Settings.USE_EXTERNAL_INTERFACE){
+ output = target.split('"').join("''");
+ } else {
+
+ output = target.split('"').join('\\"');
+ }
+ output = output.split('\n').join("");
+ output = output.split('\t').join("");
+ output = output.split('\r').join("");
+ return '"' + output + '"';
+ case 'boolean': return String(target);
+ case 'date': return 'new Date(' + target.valueOf() + ')';
+ case 'xml':
+ case 'xmlnode': return Parser.returnString(type, true, true);
+// case 'xmlnode': return '{xml:%22' +
target.toString().split('"').join('%22') + '%22, ' +
Parser.returnString('xml', false, true) + '}';
+ case 'undefined': return 'undefined';
+ default: return Parser.returnString(type, true, true);
+ }
+ }
+
+ private static function returnString(value:String,
enclose:Boolean, addBrackets:Boolean):String{
+ value = addBrackets ? "[" + value + "]" : value;
+ value = 'toString:function(){return %22' + value + '%22}';
+ value = enclose ? "{" + value + "}" : value;
+
+ return value;
+ }
+}
\ No newline at end of file

Added: trunk/as2/source/org/osflash/thunderbolt/data/StringyfiedObject.as
==============================================================================
--- (empty file)
+++ trunk/as2/source/org/osflash/thunderbolt/data/StringyfiedObject.as
Sun Apr 13 02:28:07 2008
@@ -0,0 +1,30 @@
+import org.osflash.thunderbolt.data.Parser;
+
+/**
+ * Simple wrapper class to store parses object informations
+ *
+ * @author Martin Kleppe <kle...@gmail.com>
+ */
+class org.osflash.thunderbolt.data.StringyfiedObject {
+
+ private var dataString:String;
+
+ /**
+ * Creates a new instance holding the parsed object data.
+ *
+ * @param data The object to be passed
+ * @param depth Level of recursion (optional)
+ * @return A new instance holding the parsed object data
+ */
+ function StringyfiedObject(data:Object, depth:Number, label:String){
+ this.dataString = Parser.stringify(data, depth, label);
+ }
+
+ /**
+ * Returns the parsed information in JavaScript Object Notation (JSON)
+ * @return The parsed JSON string;
+ */
+ public function toString():String{
+ return dataString;
+ }
+}
\ No newline at end of file

Added: trunk/as2/source/org/osflash/thunderbolt/io/Commandline.as
==============================================================================
--- (empty file)
+++ trunk/as2/source/org/osflash/thunderbolt/io/Commandline.as Sun Apr
13 02:28:07 2008
@@ -0,0 +1 @@
+import flash.external.ExternalInterface;
import org.osflash.thunderbolt.io.Console;
import org.osflash.thunderbolt.data.Parser;
import org.osflash.thunderbolt.data.StringyfiedObject;
import org.osflash.thunderbolt.profiling.Profiler;
import org.osflash.thunderbolt.profiling.ProfileHandle;
import org.osflash.thunderbolt.Logger;
import org.osflash.thunderbolt.Settings;
/**
* The Commandline class enables several debugging features
* WHILE the movie is running. You can inspect an element or
* set it's attributes.
*
* @author Martin Kleppe <kle...@gmail.com>
*/
class org.osflash.thunderbolt.io.Commandline {

private static var initialized:Boolean = Commandline.initialize();

/**
* Initializes the Commandline callbacks.
*/
public static function initialize():Boolean{

if (System.capabilities.playerType == "PlugIn"){
// associate external calls
ExternalInterface.addCallback("start", Commandline, Commandline.start);
ExternalInterface.addCallback("pause", Commandline, Commandline.stop);
ExternalInterface.addCallback("filter", Commandline, Commandline.filter);
ExternalInterface.addCallback("inspect", Commandline, Commandline.inspect);
ExternalInterface.addCallback("set", Commandline, Commandline.set);
ExternalInterface.addCallback("run", Commandline, Commandline.run);
ExternalInterface.addCallback("profileStart", Commandline, Commandline.profile);
ExternalInterface.addCallback("profileEnd", Commandline, Commandline.profileEnd);
}

return true;
}

/**
* Start the logger. Messages will be traced to the console.
* Usage: ThunderBolt.stop();
*/
private static function start():Void{
Logger.stopped = false;
}

/**
* Mutes the logger. Messages will no longer traced to the console.
* Usage: ThunderBolt.stop();
*/
private static function stop():Void{
Logger.stopped = true;
}

/**
* Filter output based on class.
* Usage: ThunderBolt.filter(className);
*/
private static function filter(className:String):Void{
Settings.CLASS_FILTER = className;
Console.log("Filter set to: " + className);
}

/**
* Inspects an object.
* Usage: ThunderBolt.inpect(target);
*/
private static function inspect(target:String):Void{
var out:Object = _global[target] || _root[target] || eval(target);
Console.log(new StringyfiedObject(out, 10));
}

/**
* Evaluates an expression.
* Usage: ThunderBolt.run(expression);
*/
private static function run(expression:String):Void{
var parts:Array = expression.split("(");
var info:Object = {
method: parts[0],
arguments: parts[1]
};
if (info.arguments){
var closingBrackets:Number = info.arguments.lastIndexOf(")");
info.arguments = info.arguments.substring(0, closingBrackets);
}
var returnValue = eval(info.method)(info.arguments);
Console.log(info.method + "(" + info.arguments + "); //",
new StringyfiedObject(returnValue, 255, returnValue.toString())
);
}

/**
* Sets an objects attribute.
* Usage: ThunderBolt.set(target, value);
*/
private static function set(target:String, value:String):Void{
var parts = target.split(".");
var property = parts.pop();
target = parts.join(".");

var object:Object = _global[target] || _root[target] || eval(target);
object[property] = value;
Console.log(new StringyfiedObject(object, 10));
}

private static function profile(target:String){

var out:Object = _global[target] || _root[target] || eval(target.toString());

var cache:Array = Profiler.start(out);
Console.log("Monitoring " + cache.length + " methods...");
}

private static function profileEnd(target:String){

var log:Array = Profiler.stop();
if (!log) {
return;
}

Console.group("Profiling results (" + log.length + " methods were monitored):");

for (var i:Number=0; i<log.length; i++) {
var profile:ProfileHandle = log[i];
Console.log(new StringyfiedObject({
count: profile.executionCount,
min: profile.minTime,
max: profile.maxTime,
total: profile.totalTime,
average: profile.averageTime

}, 2, profile.methodName + ": "));
};

Console.groupEnd();
}
}
\ No newline at end of file

Added: trunk/as2/source/org/osflash/thunderbolt/io/Console.as
==============================================================================
--- (empty file)
+++ trunk/as2/source/org/osflash/thunderbolt/io/Console.as Sun Apr 13
02:28:07 2008
@@ -0,0 +1,129 @@
+import flash.external.ExternalInterface;
+import org.osflash.thunderbolt.data.Parser;
+import org.osflash.thunderbolt.data.StringyfiedObject;
+import org.osflash.thunderbolt.data.JSReturn;
+import org.osflash.thunderbolt.Settings;
+import org.osflash.thunderbolt.io.JavaScriptInterface;
+/**
+ * @author Martin Kleppe <kle...@gmail.com>
+ */
+class org.osflash.thunderbolt.io.Console {
+
+ public static var version:Number;
+ private static var _enabled:Boolean;
+
+ private var classImport:Array = [JavaScriptInterface];
+
+ // Writes a message to the console.
+ public static function log(parameters:Object){
+ Console.run("log", arguments);
+ }
+
+ // Writes a message to the console with the visual "info" icon and
color coding.
+ public static function info(parameters:Object){
+ Console.run("info", arguments);
+ }
+
+ // Writes a message to the console with the visual "warning" icon and
color coding.
+ public static function warn(parameters:Object){
+ Console.run("warn", arguments);
+ }
+
+ // Writes a message to the console with the visual "error" icon and
color coding.
+ public static function error(parameters:Object){
+ Console.run("error", arguments);
+ }
+
+ // Prints an interactive listing of all properties of the object.
+ public static function dir(parameters:Object){
+ Console.run("dir", arguments);
+ }
+
+ // Prints the XML source tree of an HTML or XML element.
+ public static function dirxml(node:Object){
+
+ var out = Parser.stringify(node.toString());
+ var returnObject:JSReturn = new JSReturn(
+ "var n = document.createElement('xml');" +
+ "n.innerHTML = \"" + out + "\";" +
+ "return n;"
+ );
+ Console.run("dirxml", [returnObject]);
+ }
+
+ // Writes a message to the console and opens a nested block
+ // to indent all future messages sent to the console.
+ public static function group(parameters:Object):Void{
+ Console.run("group", arguments);
+ }
+
+ // Closes the most recently opened block.
+ public static function groupEnd():Void{
+ Console.run("groupEnd");
+ }
+
+ // Executes JavaScript command
+ private static function run(method:String, parameter:Array):Void{
+ if (System.capabilities.playerType == "PlugIn"){
+ if (parameter){
+ // check if unquoted strings are in cluded in parameters
+ for (var i:Number=0; i < parameter.length; i++) {
+ if (typeof parameter[i] == "string" &&
parameter[i].indexOf('"') != 0){
+ parameter[i] = Parser.stringify(parameter[i]);
+ }
+ parameter[i] = "[" + parameter[i].toString() + "][0]";
+ }
+ } else {
+ parameter = [];
+ }
+
+ if (Console.enabled){
+ if (Settings.USE_EXTERNAL_INTERFACE){
+ // the External Interface is more stable than the
+ // getURL(JavaScript) version
+ var execute =
ExternalInterface.call("thunderbolt_external_interface", method, parameter);
+ if (execute) {
+ return;
+ }
+ }
+ getURL("javascript:console." + method + "(" + parameter + ");");
+ }
+ }
+ }
+
+ // Inject some JavaScript code to pass complex objects to FireBug
+ private static function initExternalInterface():Void{
+/*
+ getURL("javascript:" +
+ " var thunderbolt_external_interface = function(method, parameter){" +
+ " var output = [];" +
+ " try {" +
+ " for(var i=0; i< parameter.length; i++){" +
+ " output[i] = eval(unescape(parameter[i]));" +
+ " };" +
+ " console[method].apply(this, output);" +
+ " } catch(e){" +
+ " console.error(e);"+
+ " };" +
+ " return true;" +
+ " }");
+ */
+ }
+
+ // Check if Firebug is enabled
+ public static function get enabled():Boolean{
+ if (Console._enabled !== undefined){
+ return Console._enabled;
+ } else {
+ Console.version = Number(ExternalInterface.call("function(){ return
window.console && console.firebug}", true));
+ Console._enabled = Console.version > 0;
+ if (Console._enabled){
+ if (Settings.USE_EXTERNAL_INTERFACE){
+ Console.initExternalInterface();
+ }
+ Console.log("Firebug v" + Console.version + " enabled.");
+ return Console._enabled;
+ }
+ }
+ }
+}
\ No newline at end of file

Added: trunk/as2/source/org/osflash/thunderbolt/io/JavaScriptInterface.as
==============================================================================
--- (empty file)
+++ trunk/as2/source/org/osflash/thunderbolt/io/JavaScriptInterface.as
Sun Apr 13 02:28:07 2008
@@ -0,0 +1,108 @@
+import org.osflash.thunderbolt.Settings;
+import org.osflash.thunderbolt.io.Console;
+/**
+ * @author Martin Kleppe <kle...@gmail.com>
+ */
+class org.osflash.thunderbolt.io.JavaScriptInterface {
+
+ private static var codeSnippet:String =
+
+ "var ThunderBolt = {" +
+
+ " storedTarget: null," +
+ " elementID: null," +
+
+ // display structure of flash target
+ " inspect: function(target, id){" +
+ " this.getFlash(id).inspect(this.getFullTarget(target));" +
+ " }," +
+
+ // start the logger
+ " start: function(id){" +
+ " this.getFlash(id).start();" +
+ " }," +
+
+ // stop the logger
+ " stop: function(id){" +
+ " this.getFlash(id).pause();" +
+ " }," +
+
+ // filter output based on class
+ " filter: function(className, id){" +
+ " this.getFlash(id).filter(className);" +
+ " }," +
+
+ // run an expression within flash
+ " run: function(expression, id){" +
+ " this.getFlash(id).run(expression);" +
+ " }," +
+
+ // assign a new value to the target
+ " set: function(target, value, id){" +
+ " this.getFlash(id).set(this.getFullTarget(target), value);" +
+ " }," +
+
+ " profile: function(target, id){" +
+ " this.getFlash(id).profileStart(target);" +
+ " }," +
+
+ " profileEnd: function(target, id){" +
+ " this.getFlash(id).profileEnd();" +
+ " }," +
+
+ // set the target for future actions
+ " cd: function(path, id){" +
+
+ " if (path.indexOf('_root') == 0){" +
+ " this.storedTarget = path; " +
+ " } else if (path){" +
+ " switch(path){" +
+ " case '.': " +
+ " case '/': this.storedTarget = null; break;" +
+ " case '..': this.storedTarget =
this.storedTarget.split('.').slice(0,-1).join('.'); break;" +
+ " default: this.storedTarget = this.storedTarget ?
this.storedTarget + '.' + path : path;" +
+ " }" +
+ " }" +
+ " this.inspect(id);" +
+ " }," +
+
+ " getFlash: function(id){" +
+ // returns a reference of the flash Object or the first flash
movie in document
+ " var d = document; " +
+ " if(id) { " +
+ " this.elementID = id;"+
+ " return d.getElementById(id);"+
+ " } else if(this.elementID){ " +
+ " return d.getElementById(this.elementID);"+
+ " } else { " +
+ " return d.getElementsByTagName('embed')[0];" +
+ " }"+
+ " }," +
+
+ // private method"
+ " getFullTarget: function(target){" +
+ " if (!target){" +
+ " return this.storedTarget;" +
+ " } else {" +
+ " if (target.indexOf('_root') == 0) {" +
+ " return target;" +
+ " } else {" +
+ " return this.storedTarget ? this.storedTarget + '.' + target :
target; " +
+ " }" +
+ " }" +
+ " }" +
+ "};" +
+
+ // add shortcut;
+ "var " + Settings.JAVASCRIPT_CONSOLE_SHORTCUT + " = ThunderBolt;";
+
+ public static function injectCode():Boolean{
+ if (System.capabilities.playerType == "PlugIn"){
+ getURL("javascript:" + JavaScriptInterface.codeSnippet);
+ }
+ return true;
+ // return Console.enabled;
+ };
+
+ private static var enabled:Boolean = JavaScriptInterface.injectCode();
+}
\ No newline at end of file

Added: trunk/as2/source/org/osflash/thunderbolt/logging/LogInfo.as
==============================================================================
--- (empty file)
+++ trunk/as2/source/org/osflash/thunderbolt/logging/LogInfo.as Sun Apr
13 02:28:07 2008
@@ -0,0 +1,136 @@
+import org.osflash.thunderbolt.data.Parser;
+import org.osflash.thunderbolt.io.Console;
+import org.osflash.thunderbolt.Logger;
+import org.osflash.thunderbolt.data.ObjectType;
+import org.osflash.thunderbolt.Settings;
+/**
+ * LogInfo objects are used to parse information provided by the MTASC
trace facility
+ * and provide more detailed information about the current trace action.
+ *
+ * @author Martin Kleppe <kle...@gmail.com>
+ */
+class org.osflash.thunderbolt.logging.LogInfo {
+
+ public var fullClassWithMethodName:String;
+
+ public var fileName:String;
+ public var classParts:Array;
+ public var methodName:String;
+ public var fullClass:String;
+ public var className:String;
+ public var traceObject:Object;
+ public var lineNumber:Number;
+ public var objectType:String;
+
+ public static var frameNumber:Number;
+ private static var lastFrame:Number;
+ private static var _movieUrl:String;
+ private static var frameCounter:MovieClip;
+
+ /**
+ * LogInfo objects are used to parse information provided by the
MTASC trace facility
+ * and provide more detailed information about the current trace action.
+ */
+ function LogInfo(traceObject:Object, fullClassWithMethodName:String,
fileName:String, lineNumber:Number){
+
+ this.traceObject = traceObject;
+ this.fullClassWithMethodName = fullClassWithMethodName || "";
+ this.fileName = fileName.split("\\").join("/") || "";
+ this.lineNumber = lineNumber || 0;
+
+ this.objectType = ObjectType.get(traceObject);
+
+ // retrieve information about current trace action
+ this.classParts = this.fullClassWithMethodName.split("::");
+ this.methodName = classParts[1] || "anonymous";
+ this.fullClass = classParts[0] || "" ;
+ this.className = String(fullClass.split(".").pop()) || "Thunderbolt";
+
+ if (!LogInfo.frameNumber){
+ LogInfo.frameNumber = 1;
+ if (Settings.USE_FRAME_COUNTER){
+ LogInfo.initializeFrameCounter();
+ }
+ }
+ }
+
+ public function matchClassFilter():Boolean {
+
+ if (Settings.CLASS_FILTER == "" || Settings.CLASS_FILTER == "*"){
+ return true;
+ }
+
+ var isPackage:Boolean = Settings.CLASS_FILTER.indexOf("*") > -1;
+
+ if (isPackage){
+ var match:String = Settings.CLASS_FILTER.split("*")[0];
+ return this.fullClass.indexOf(match) == 0;
+ } else {
+ return this.fullClass == Settings.CLASS_FILTER;
+ }
+ }
+
+ /**
+ * Create a new empty movieclip at root level and count running frames.
+ * @return The movieclip that is listening.
+ */
+ private static function initializeFrameCounter():MovieClip{
+ LogInfo.frameCounter =
_root.createEmptyMovieClip("thunderbolt_frame_listener_mc", _root.getNextHighestDepth());
+ LogInfo.frameCounter.onEnterFrame = function(){
+ LogInfo.frameNumber++;
+ };
+ return LogInfo.frameCounter;
+ }
+
+ /**
+ * Returns the object information as a JSON formated string
+ * which may be passed to JavaScript calls.
+ *
+ * @return String in JavaScript object notation (JSON).
+ */
+ public function toString():String{
+ var description:String = this.fullClassWithMethodName + "[" +
this.lineNumber + "] : " + this.objectType + " @ " + this.time;
+ // cunstruct info object
+ return "{" +
+ 'description:"' + description + '",' +
+ 'method:"' + methodName + '",' +
+ 'line:"' + lineNumber + '",' +
+ 'type:"' + objectType + '",' +
+ 'time:"' + time + '",' +
+ 'frame:"' + LogInfo.frameNumber + '",' +
+ 'fullClass:"' + fullClass + '",' +
+ 'file:"' + fileName + '",' +
+ 'toString:' + 'function(){return "' + className + '.' + methodName
+ '"}' +
+ "}";
+ }
+
+ /**
+ * Get well formated current execution.
+ * @return Current time
+ */
+ private function get time():String{
+ return (new Date()).toString().split(" ")[3];
+ }
+
+ /**
+ * Get the name of the current running SWF.
+ * @return Name of the swf.
+ */
+ private static function get movieUrl():String{
+ if (!LogInfo._movieUrl){
+ LogInfo._movieUrl = _root._url.split("\\").pop().split("/").pop();
+ }
+ return LogInfo._movieUrl;
+ }
+
+ /*
+ * Test if there is an open frame group and close it
+ */
+ public function checkFrameGroup():Void{
+ if (LogInfo.frameNumber != LogInfo.lastFrame){
+ Console.groupEnd();
+ Console.group(LogInfo.movieUrl + " [frame " + LogInfo.frameNumber
+ "] @ " + this.time);
+ LogInfo.lastFrame = LogInfo.frameNumber;
+ }
+ }
+}
\ No newline at end of file

Added: trunk/as2/source/org/osflash/thunderbolt/logging/LogLevel.as
==============================================================================
--- (empty file)
+++ trunk/as2/source/org/osflash/thunderbolt/logging/LogLevel.as Sun
Apr 13 02:28:07 2008
@@ -0,0 +1,96 @@
+import org.osflash.thunderbolt.io.Console;
+import org.osflash.thunderbolt.Settings;
+/**
+ * LogLevel class based on message shorcuts:
+ *
+ * e = ERROR
+ * i = INFO
+ * w = WARNING
+ * e = ERROR
+ * f = fatal
+ *
+ * @author Martin Kleppe <kle...@gmail.com>
+ */
+class org.osflash.thunderbolt.logging.LogLevel {
+
+ public static var LOG:String = "LOG";
+ public static var INFO:String = "INFO";
+ public static var WARNING:String = "WARNING";
+ public static var ERROR:String = "ERROR";
+ public static var FATAL:String = "FATAL";
+
+ public var level:String;
+ public var message:String;
+
+ public var messageModified:Boolean;
+
+ /**
+ * Creates an LogLevel element based on a message.
+ *
+ * Examples:
+ * trace("d This is a debug information."); will create a DEBUG LogLevel
+ * trace("i This is an information."); will create a INFO LogLevel
+ * trace("e This is an error."); will create a ERROR LogLevel
+ * trace("w This is a warning."); will create a WARNING LogLevel
+ * trace("f This is a fatal error."); will create a FATAL LogLevel
+ *
+ * @param fullMessage The message to analyse.
+ */
+ function LogLevel(fullMessage:Object){
+ this.level = LogLevel.LOG;
+ this.messageModified = false;
+ if (typeof fullMessage == "string" && fullMessage.charAt(1) == " ") {
+ // TODO: "ERROR:", "INFO:" ... should also be parsed
+ switch (fullMessage.charAt(0).toLowerCase()) {
+
+ case "d": this.level = LogLevel.LOG; break;
+ case "i": this.level = LogLevel.INFO; break;
+ case "w": this.level = LogLevel.WARNING; break;
+ case "e": this.level = LogLevel.ERROR; break;
+ case "f": this.level = LogLevel.FATAL; break;
+ }
+ this.message = String(fullMessage).slice(2);
+ this.messageModified = true;
+ }
+ }
+
+ /**
+ * Match string based level with numeric index.
+ */
+ public static function getLevelIndex(level:String):Number{
+ switch (level){
+ case LogLevel.INFO: return 1;
+ case LogLevel.WARNING: return 2;
+ case LogLevel.ERROR: return 3;
+ case LogLevel.FATAL: return 4;
+ default: return 0;
+ }
+ }
+
+ /**
+ * Check if the log should be send to the output based on
+ * the current and global log level.
+ *
+ * @return true if log should be send to output.
+ */
+ public function get sendToOutput():Boolean {
+ return (LogLevel.getLevelIndex(this.level) >= LogLevel.getLevelIndex(Settings.LOG_LEVEL));
+ }
+
+ /**
+ * Returns the Console method call which is associated
+ * with the current LogLevel.
+
+ * @return Console method call.
+ */
+ public function get console():Function{
+ switch (this.level){
+ case LogLevel.LOG: return Console.log;
+ case LogLevel.INFO: return Console.info;
+ case LogLevel.WARNING: return Console.warn;
+ case LogLevel.ERROR: return Console.error;
+ case LogLevel.FATAL: return Console.error;
+ default: return Console.log;
+ };
+ }
+}
\ No newline at end of file

Added: trunk/as2/source/org/osflash/thunderbolt/profiling/ProfileHandle.as
==============================================================================
--- (empty file)
+++ trunk/as2/source/org/osflash/thunderbolt/profiling/ProfileHandle.as
Sun Apr 13 02:28:07 2008
@@ -0,0 +1,35 @@
+/**
+ * @author Martin Kleppe <kle...@gmail.com>
+ */
+class org.osflash.thunderbolt.profiling.ProfileHandle {
+
+ public var target:Object;
+ public var methodName:String;
+ public var method:Function;
+
+ public var executionCount:Number;
+ public var totalTime:Number;
+ public var minTime:Number;
+ public var maxTime:Number;
+
+ public function ProfileHandle(target:Object, methodName:String){
+ this.target = target;
+ this.methodName = methodName;
+ this.method = target[methodName];
+ this.executionCount = 0;
+ this.totalTime = 0;
+ this.maxTime = 0;
+ this.minTime = 0;
+ }
+
+ public function log(time:Number){
+ this.executionCount++;
+ this.totalTime += time;
+ this.maxTime = Math.max(this.maxTime, time);
+ this.minTime = this.minTime ? Math.min(this.minTime, time) : time;
+ }
+
+ public function get averageTime():Number{
+ return this.totalTime / this.executionCount;
+ }
+}
\ No newline at end of file

Added: trunk/as2/source/org/osflash/thunderbolt/profiling/Profiler.as
==============================================================================
--- (empty file)
+++ trunk/as2/source/org/osflash/thunderbolt/profiling/Profiler.as Sun
Apr 13 02:28:07 2008
@@ -0,0 +1,86 @@
+import org.osflash.thunderbolt.profiling.ProfileHandle;
+import org.osflash.thunderbolt.io.Console;
+import org.osflash.thunderbolt.Logger;
+import org.osflash.thunderbolt.data.StringyfiedObject;
+/**
+ * @author Martin Kleppe <kle...@gmail.com>
+ */
+class org.osflash.thunderbolt.profiling.Profiler {
+
+ private static var cache:Array = [];
+
+ function Profiler(){
+ }
+
+ public static function start(target:Object, method:Object):Array{
+
+ // check if profiler is already running
+ if (Profiler.cache.length > 0){
+ Console.info("Profiler is already runnning.");
+ }
+ // returns name of method
+ var getMethodName = function():String{
+ for (var all:String in target) {
+ // see if given mehods matches expression
+ if (target[all] == method) {
+ return all;
+ }
+ }
+ };
+ // switch profile actions base on method type
+ switch (typeof method){
+ case "undefined": Profiler.profileObject(target); break;
+ case "string": Profiler.profileMethod(target, String(method)); break;
+ case "function": Profiler.profileMethod(target,
getMethodName(method)); break;
+ }
+ return Profiler.cache;
+ }
+
+ private static function profileMethod(target:Object, methodName:String):Void{
+ // check if method is currently profiled
+ if (!target[methodName].profile){
+ // create profile handle
+ var profile:ProfileHandle = new ProfileHandle(target, methodName);
+ // override method
+ target[methodName] = function():Object{
+ var startTime:Number = getTimer();
+ // execute method and store returned value
+ var returnValue = profile.method.apply(target, arguments);
+ // log execution time
+ profile.log(getTimer() - startTime);
+ return returnValue;
+ };
+ // stick reference for later removal
+ target[methodName].profile = profile;
+ // cache reference
+ Profiler.cache.push(target[methodName]);
+ }
+ }
+
+ private static function profileObject(target:Object):Void{
+ // unplug object's methods
+ for (var all:String in target){
+ if (typeof target[all] == "function"){
+ Profiler.profileMethod(target, all);
+ }
+ }
+ }
+
+ public static function stop():Array {
+ if (Profiler.cache.length == 0){
+ Console.error("Please start the profiler first!");
+ return null;
+ }
+ var profileLog = [];
+ for (var i:Number=0; i<Profiler.cache.length; i++) {
+ var method:Function = Profiler.cache[i];
+ var profile:ProfileHandle = method.profile;
+ profile.target[profile.methodName] = profile.method;
+ profileLog.push(profile);
+ delete method;
+ }
+ Console.groupEnd();
+ Profiler.cache = [];
+ return profileLog;
+ }
+}
\ No newline at end of file

Added: trunk/as2/thunderbolt_classes.zip
==============================================================================
Binary file. No diff available.

Modified: trunk/as3/example/flex/bin/AC_OETags.js
==============================================================================
--- trunk/as3/example/flex/bin/AC_OETags.js (original)
+++ trunk/as3/example/flex/bin/AC_OETags.js Sun Apr 13 02:28:07 2008
@@ -1,269 +1,276 @@
-// Flash Player Version Detection - Rev 1.5
-// Detect Client Browser type
-// Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved.
-var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
-var isWin = (navigator.appVersion.toLowerCase().indexOf("win") !=
-1) ? true : false;
-var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
-
-function ControlVersion()
-{
- var version;
- var axo;
- var e;
-
- // NOTE : new ActiveXObject(strFoo) throws an exception if strFoo
isn't in the registry
-
- try {
- // version will be set for 7.X or greater players
- axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
- version = axo.GetVariable("$version");
- } catch (e) {
- }
-
- if (!version)
- {
- try {
- // version will be set for 6.X players only
- axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
-
- // installed player is some revision of 6.0
- // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
- // so we have to be careful.
-
- // default to the first public version
- version = "WIN 6,0,21,0";
-
- // throws if AllowScripAccess does not exist (introduced in 6.0r47)
- axo.AllowScriptAccess = "always";
-
- // safe to call for 6.0r47 or greater
- version = axo.GetVariable("$version");
-
- } catch (e) {
- }
- }
-
- if (!version)
- {
- try {
- // version will be set for 4.X or 5.X player
- axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
- version = axo.GetVariable("$version");
- } catch (e) {
- }
- }
-
- if (!version)
- {
- try {
- // version will be set for 3.X player
- axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
- version = "WIN 3,0,18,0";
- } catch (e) {
- }
- }
-
- if (!version)
- {
- try {
- // version will be set for 2.X player
- axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
- version = "WIN 2,0,0,11";
- } catch (e) {
- version = -1;
- }
- }
-
- return version;
-}
-
-// JavaScript helper required to detect Flash Player PlugIn version information
-function GetSwfVer(){
- // NS/Opera version >= 3 check for Flash plugin in plugin array
- var flashVer = -1;
-
- if (navigator.plugins != null && navigator.plugins.length > 0) {
- if (navigator.plugins["Shockwave Flash 2.0"] ||
navigator.plugins["Shockwave Flash"]) {
- var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
- var flashDescription = navigator.plugins["Shockwave Flash" +
swVer2].description;
- var descArray = flashDescription.split(" ");
- var tempArrayMajor = descArray[2].split(".");
- var versionMajor = tempArrayMajor[0];
- var versionMinor = tempArrayMajor[1];
- if ( descArray[3] != "" ) {
- tempArrayMinor = descArray[3].split("r");
- } else {
- tempArrayMinor = descArray[4].split("r");
- }
- var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
- var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
- }
- }
- // MSN/WebTV 2.6 supports Flash 4
- else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") !=
-1) flashVer = 4;
- // WebTV 2.5 supports Flash 3
- else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") !=
-1) flashVer = 3;
- // older WebTV supports Flash 2
- else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1)
flashVer = 2;
- else if ( isIE && isWin && !isOpera ) {
- flashVer = ControlVersion();
- }
- return flashVer;
-}
-
-// When called with reqMajorVer, reqMinorVer, reqRevision returns true
if that version or greater is available
-function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
-{
- versionStr = GetSwfVer();
- if (versionStr == -1 ) {
- return false;
- } else if (versionStr != 0) {
- if(isIE && isWin && !isOpera) {
- // Given "WIN 2,0,0,11"
- tempArray = versionStr.split(" "); // ["WIN", "2,0,0,11"]
- tempString = tempArray[1]; // "2,0,0,11"
- versionArray = tempString.split(","); // ['2', '0', '0', '11']
- } else {
- versionArray = versionStr.split(".");
- }
- var versionMajor = versionArray[0];
- var versionMinor = versionArray[1];
- var versionRevision = versionArray[2];
-
- // is the major.revision >= requested major.revision AND the
minor version >= requested minor
- if (versionMajor > parseFloat(reqMajorVer)) {
- return true;
- } else if (versionMajor == parseFloat(reqMajorVer)) {
- if (versionMinor > parseFloat(reqMinorVer))
- return true;
- else if (versionMinor == parseFloat(reqMinorVer)) {
- if (versionRevision >= parseFloat(reqRevision))
- return true;
- }
- }
- return false;
- }
-}
-
-function AC_AddExtension(src, ext)
-{
- if (src.indexOf('?') != -1)
- return src.replace(/\?/, ext+'?');
- else
- return src + ext;
-}
-
-function AC_Generateobj(objAttrs, params, embedAttrs)
-{
- var str = '';
- if (isIE && isWin && !isOpera)
- {
- str += '<object ';
- for (var i in objAttrs)
- str += i + '="' + objAttrs[i] + '" ';
- for (var i in params)
- str += '><param name="' + i + '" value="' + params[i] + '" /> ';
- str += '></object>';
- } else {
- str += '<embed ';
- for (var i in embedAttrs)
- str += i + '="' + embedAttrs[i] + '" ';
- str += '> </embed>';
- }
-
- document.write(str);
-}
-
-function AC_FL_RunContent(){
- var ret =
- AC_GetArgs
- ( arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
- , "application/x-shockwave-flash"
- );
- AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
-}
-
-function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
- var ret = new Object();
- ret.embedAttrs = new Object();
- ret.params = new Object();
- ret.objAttrs = new Object();
- for (var i=0; i < args.length; i=i+2){
- var currArg = args[i].toLowerCase();
-
- switch (currArg){
- case "classid":
- break;
- case "pluginspage":
- ret.embedAttrs[args[i]] = args[i+1];
- break;
- case "src":
- case "movie":
- args[i+1] = AC_AddExtension(args[i+1], ext);
- ret.embedAttrs["src"] = args[i+1];
- ret.params[srcParamName] = args[i+1];
- break;
- case "onafterupdate":
- case "onbeforeupdate":
- case "onblur":
- case "oncellchange":
- case "onclick":
- case "ondblClick":
- case "ondrag":
- case "ondragend":
- case "ondragenter":
- case "ondragleave":
- case "ondragover":
- case "ondrop":
- case "onfinish":
- case "onfocus":
- case "onhelp":
- case "onmousedown":
- case "onmouseup":
- case "onmouseover":
- case "onmousemove":
- case "onmouseout":
- case "onkeypress":
- case "onkeydown":
- case "onkeyup":
- case "onload":
- case "onlosecapture":
- case "onpropertychange":
- case "onreadystatechange":
- case "onrowsdelete":
- case "onrowenter":
- case "onrowexit":
- case "onrowsinserted":
- case "onstart":
- case "onscroll":
- case "onbeforeeditfocus":
- case "onactivate":
- case "onbeforedeactivate":
- case "ondeactivate":
- case "type":
- case "codebase":
- ret.objAttrs[args[i]] = args[i+1];
- break;
- case "id":
- case "width":
- case "height":
- case "align":
- case "vspace":
- case "hspace":
- case "class":
- case "title":
- case "accesskey":
- case "name":
- case "tabindex":
- ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
- break;
- default:
- ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
- }
- }
- ret.objAttrs["classid"] = classid;
- if (mimeType) ret.embedAttrs["type"] = mimeType;
- return ret;
-}
-
-
+// Flash Player Version Detection - Rev 1.6
+// Detect Client Browser type
+// Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved.
+var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
+var isWin = (navigator.appVersion.toLowerCase().indexOf("win") !=
-1) ? true : false;
+var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
+
+function ControlVersion()
+{
+ var version;
+ var axo;
+ var e;
+
+ // NOTE : new ActiveXObject(strFoo) throws an exception if strFoo
isn't in the registry
+
+ try {
+ // version will be set for 7.X or greater players
+ axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
+ version = axo.GetVariable("$version");
+ } catch (e) {
+ }
+
+ if (!version)
+ {
+ try {
+ // version will be set for 6.X players only
+ axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
+
+ // installed player is some revision of 6.0
+ // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
+ // so we have to be careful.
+
+ // default to the first public version
+ version = "WIN 6,0,21,0";
+
+ // throws if AllowScripAccess does not exist (introduced in 6.0r47)
+ axo.AllowScriptAccess = "always";
+
+ // safe to call for 6.0r47 or greater
+ version = axo.GetVariable("$version");
+
+ } catch (e) {
+ }
+ }
+
+ if (!version)
+ {
+ try {
+ // version will be set for 4.X or 5.X player
+ axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
+ version = axo.GetVariable("$version");
+ } catch (e) {
+ }
+ }
+
+ if (!version)
+ {
+ try {
+ // version will be set for 3.X player
+ axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
+ version = "WIN 3,0,18,0";
+ } catch (e) {
+ }
+ }
+
+ if (!version)
+ {
+ try {
+ // version will be set for 2.X player
+ axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
+ version = "WIN 2,0,0,11";
+ } catch (e) {
+ version = -1;
+ }
+ }
+
+ return version;
+}
+
+// JavaScript helper required to detect Flash Player PlugIn version information
+function GetSwfVer(){
+ // NS/Opera version >= 3 check for Flash plugin in plugin array
+ var flashVer = -1;
+
+ if (navigator.plugins != null && navigator.plugins.length > 0) {
+ if (navigator.plugins["Shockwave Flash 2.0"] ||
navigator.plugins["Shockwave Flash"]) {
+ var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
+ var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
+ var descArray = flashDescription.split(" ");
+ var tempArrayMajor = descArray[2].split(".");
+ var versionMajor = tempArrayMajor[0];
+ var versionMinor = tempArrayMajor[1];
+ var versionRevision = descArray[3];
+ if (versionRevision == "") {
+ versionRevision = descArray[4];
+ }
+ if (versionRevision[0] == "d") {
+ versionRevision = versionRevision.substring(1);
+ } else if (versionRevision[0] == "r") {
+ versionRevision = versionRevision.substring(1);
+ if (versionRevision.indexOf("d") > 0) {
+ versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
+ }
+ }
+ var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
+ }
+ }
+ // MSN/WebTV 2.6 supports Flash 4
+ else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") !=
-1) flashVer = 4;
+ // WebTV 2.5 supports Flash 3
+ else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") !=
-1) flashVer = 3;
+ // older WebTV supports Flash 2
+ else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1)
flashVer = 2;
+ else if ( isIE && isWin && !isOpera ) {
+ flashVer = ControlVersion();
+ }
+ return flashVer;
+}
+
+// When called with reqMajorVer, reqMinorVer, reqRevision returns true
if that version or greater is available
+function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
+{
+ versionStr = GetSwfVer();
+ if (versionStr == -1 ) {
+ return false;
+ } else if (versionStr != 0) {
+ if(isIE && isWin && !isOpera) {
+ // Given "WIN 2,0,0,11"
+ tempArray = versionStr.split(" "); // ["WIN", "2,0,0,11"]
+ tempString = tempArray[1]; // "2,0,0,11"
+ versionArray = tempString.split(","); // ['2', '0', '0', '11']
+ } else {
+ versionArray = versionStr.split(".");
+ }
+ var versionMajor = versionArray[0];
+ var versionMinor = versionArray[1];
+ var versionRevision = versionArray[2];
+
+ // is the major.revision >= requested major.revision AND the
minor version >= requested minor
+ if (versionMajor > parseFloat(reqMajorVer)) {
+ return true;
+ } else if (versionMajor == parseFloat(reqMajorVer)) {
+ if (versionMinor > parseFloat(reqMinorVer))
+ return true;
+ else if (versionMinor == parseFloat(reqMinorVer)) {
+ if (versionRevision >= parseFloat(reqRevision))
+ return true;
+ }
+ }
+ return false;
+ }
+}
+
+function AC_AddExtension(src, ext)
+{
+ if (src.indexOf('?') != -1)
+ return src.replace(/\?/, ext+'?');
+ else
+ return src + ext;
+}
+
+function AC_Generateobj(objAttrs, params, embedAttrs)
+{
+ var str = '';
+ if (isIE && isWin && !isOpera)
+ {
+ str += '<object ';
+ for (var i in objAttrs)
+ str += i + '="' + objAttrs[i] + '" ';
+ str += '>';
+ for (var i in params)
+ str += '<param name="' + i + '" value="' + params[i] + '" /> ';
+ str += '</object>';
+ } else {
+ str += '<embed ';
+ for (var i in embedAttrs)
+ str += i + '="' + embedAttrs[i] + '" ';
+ str += '> </embed>';
+ }
+
+ document.write(str);
+}
+
+function AC_FL_RunContent(){
+ var ret =
+ AC_GetArgs
+ ( arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
+ , "application/x-shockwave-flash"
+ );
+ AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
+}
+
+function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
+ var ret = new Object();
+ ret.embedAttrs = new Object();
+ ret.params = new Object();
+ ret.objAttrs = new Object();
+ for (var i=0; i < args.length; i=i+2){
+ var currArg = args[i].toLowerCase();
+
+ switch (currArg){
+ case "classid":
+ break;
+ case "pluginspage":
+ ret.embedAttrs[args[i]] = args[i+1];
+ break;
+ case "src":
+ case "movie":
+ args[i+1] = AC_AddExtension(args[i+1], ext);
+ ret.embedAttrs["src"] = args[i+1];
+ ret.params[srcParamName] = args[i+1];
+ break;
+ case "onafterupdate":
+ case "onbeforeupdate":
+ case "onblur":
+ case "oncellchange":
+ case "onclick":
+ case "ondblClick":
+ case "ondrag":
+ case "ondragend":
+ case "ondragenter":
+ case "ondragleave":
+ case "ondragover":
+ case "ondrop":
+ case "onfinish":
+ case "onfocus":
+ case "onhelp":
+ case "onmousedown":
+ case "onmouseup":
+ case "onmouseover":
+ case "onmousemove":
+ case "onmouseout":
+ case "onkeypress":
+ case "onkeydown":
+ case "onkeyup":
+ case "onload":
+ case "onlosecapture":
+ case "onpropertychange":
+ case "onreadystatechange":
+ case "onrowsdelete":
+ case "onrowenter":
+ case "onrowexit":
+ case "onrowsinserted":
+ case "onstart":
+ case "onscroll":
+ case "onbeforeeditfocus":
+ case "onactivate":
+ case "onbeforedeactivate":
+ case "ondeactivate":
+ case "type":
+ case "codebase":
+ ret.objAttrs[args[i]] = args[i+1];
+ break;
+ case "id":
+ case "width":
+ case "height":
+ case "align":
+ case "vspace":
+ case "hspace":
+ case "class":
+ case "title":
+ case "accesskey":
+ case "name":
+ case "tabindex":
+ ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
+ break;
+ default:
+ ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
+ }
+ }
+ ret.objAttrs["classid"] = classid;
+ if (mimeType) ret.embedAttrs["type"] = mimeType;
+ return ret;
+}
+
+

Modified: trunk/as3/example/flex/bin/ThunderBoltFlexExample.html
==============================================================================
--- trunk/as3/example/flex/bin/ThunderBoltFlexExample.html (original)
+++ trunk/as3/example/flex/bin/ThunderBoltFlexExample.html Sun Apr 13
02:28:07 2008
@@ -1,107 +1,121 @@
-<!-- saved from url=(0014)about:internet -->
-<html lang="en">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<title></title>
-<script src="AC_OETags.js" language="javascript"></script>
-<style>
-body { margin: 0px; overflow:hidden }
-</style>
-<script language="JavaScript" type="text/javascript">
-<!--
-// -----------------------------------------------------------------------------
-// Globals
-// Major version of Flash required
-var requiredMajorVersion = 9;
-// Minor version of Flash required
-var requiredMinorVersion = 0;
-// Minor version of Flash required
-var requiredRevision = 0;
-// -----------------------------------------------------------------------------
-// -->
-</script>
-</head>
-
-<body scroll="no">
-<script language="JavaScript" type="text/javascript" src="history.js"></script>
-<script language="JavaScript" type="text/javascript">
-<!--
-// Version check for the Flash Player that has the ability to start
Player Product Install (6.0r65)
-var hasProductInstall = DetectFlashVer(6, 0, 65);
-
-// Version check based upon the values defined in globals
-var hasRequestedVersion = DetectFlashVer(requiredMajorVersion,
requiredMinorVersion, requiredRevision);
-
-
-// Check to see if a player with Flash Product Install is available
and the version does not meet the requirements for playback
-if ( hasProductInstall && !hasRequestedVersion ) {
- // MMdoctitle is the stored document.title value used by the
installation process to close the window that started the process
- // This is necessary in order to close browser windows that are still
utilizing the older version of the player after installation has completed
- // DO NOT MODIFY THE FOLLOWING FOUR LINES
- // Location visited after installation is complete if installation is required
- var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
- var MMredirectURL = window.location;
- document.title = document.title.slice(0, 47) + " - Flash Player Installation";
- var MMdoctitle = document.title;
-
- AC_FL_RunContent(
- "src", "playerProductInstall",
- "FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
- "width", "100%",
- "height", "100%",
- "align", "middle",
- "id", "ThunderBoltFlexExample",
- "quality", "high",
- "bgcolor", "#869ca7",
- "name", "ThunderBoltFlexExample",
- "allowScriptAccess","sameDomain",
- "type", "application/x-shockwave-flash",
- "pluginspage", "http://www.adobe.com/go/getflashplayer"
- );
-} else if (hasRequestedVersion) {
- // if we've detected an acceptable version
- // embed the Flash Content SWF when all tests are passed
- AC_FL_RunContent(
- "src", "ThunderBoltFlexExample",
- "width", "100%",
- "height", "100%",
- "align", "middle",
- "id", "ThunderBoltFlexExample",
- "quality", "high",
- "bgcolor", "#869ca7",
- "name", "ThunderBoltFlexExample",
- "flashvars",'historyUrl=history.htm%3F&lconid=' + lc_id + '',
- "allowScriptAccess","sameDomain",
- "type", "application/x-shockwave-flash",
- "pluginspage", "http://www.adobe.com/go/getflashplayer"
- );
- } else { // flash is too old or we can't detect the plugin
- var alternateContent = 'Alternate HTML content should be placed here. '
- + 'This content requires the Adobe Flash Player. '
- + '<a href=http://www.adobe.com/go/getflash/>Get Flash</a>';
- document.write(alternateContent); // insert non-flash content
- }
-// -->
-</script>
-<noscript>
- <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
- id="ThunderBoltFlexExample" width="100%" height="100%"
- codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
- <param name="movie" value="ThunderBoltFlexExample.swf" />
- <param name="quality" value="high" />
- <param name="bgcolor" value="#869ca7" />
- <param name="allowScriptAccess" value="sameDomain" />
- <embed src="ThunderBoltFlexExample.swf" quality="high" bgcolor="#869ca7"
- width="100%" height="100%" name="ThunderBoltFlexExample" align="middle"
- play="true"
- loop="false"
- quality="high"
- allowScriptAccess="sameDomain"
- type="application/x-shockwave-flash"
- pluginspage="http://www.adobe.com/go/getflashplayer">
- </embed>
- </object>
-</noscript>
-<iframe name="_history" src="history.htm" frameborder="0"
scrolling="no" width="22" height="0"></iframe>
-</body>
-</html>
+<!-- saved from url=(0014)about:internet -->
+<html lang="en">
+
+<!--
+Smart developers always View Source.
+
+This application was built using Adobe Flex, an open source framework
+for building rich Internet applications that get delivered via the
+Flash Player or to desktops via Adobe AIR.
+
+Learn more about Flex at http://flex.org
+// -->
+
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+
+<!-- BEGIN Browser History required section -->
+<link rel="stylesheet" type="text/css" href="history/history.css" />
+<!-- END Browser History required section -->
+
+<title></title>
+<script src="AC_OETags.js" language="javascript"></script>
+
+<!-- BEGIN Browser History required section -->
+<script src="history/history.js" language="javascript"></script>
+<!-- END Browser History required section -->
+
+<style>
+body { margin: 0px; overflow:hidden }
+</style>
+<script language="JavaScript" type="text/javascript">
+<!--
+// -----------------------------------------------------------------------------
+// Globals
+// Major version of Flash required
+var requiredMajorVersion = 9;
+// Minor version of Flash required
+var requiredMinorVersion = 0;
+// Minor version of Flash required
+var requiredRevision = 28;
+// -----------------------------------------------------------------------------
+// -->
+</script>
+</head>
+
+<body scroll="no">
+<script language="JavaScript" type="text/javascript">
+<!--
+// Version check for the Flash Player that has the ability to start
Player Product Install (6.0r65)
+var hasProductInstall = DetectFlashVer(6, 0, 65);
+
+// Version check based upon the values defined in globals
+var hasRequestedVersion = DetectFlashVer(requiredMajorVersion,
requiredMinorVersion, requiredRevision);
+
+if ( hasProductInstall && !hasRequestedVersion ) {
+ // DO NOT MODIFY THE FOLLOWING FOUR LINES
+ // Location visited after installation is complete if installation is required
+ var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
+ var MMredirectURL = window.location;
+ document.title = document.title.slice(0, 47) + " - Flash Player Installation";
+ var MMdoctitle = document.title;
+
+ AC_FL_RunContent(
+ "src", "playerProductInstall",
+ "FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
+ "width", "100%",
+ "height", "100%",
+ "align", "middle",
+ "id", "ThunderBoltFlexExample",
+ "quality", "high",
+ "bgcolor", "#869ca7",
+ "name", "ThunderBoltFlexExample",
+ "allowScriptAccess","sameDomain",
+ "type", "application/x-shockwave-flash",
+ "pluginspage", "http://www.adobe.com/go/getflashplayer"
+ );
+} else if (hasRequestedVersion) {
+ // if we've detected an acceptable version
+ // embed the Flash Content SWF when all tests are passed
+ AC_FL_RunContent(
+ "src", "ThunderBoltFlexExample",
+ "width", "100%",
+ "height", "100%",
+ "align", "middle",
+ "id", "ThunderBoltFlexExample",
+ "quality", "high",
+ "bgcolor", "#869ca7",
+ "name", "ThunderBoltFlexExample",
+ "allowScriptAccess","sameDomain",
+ "type", "application/x-shockwave-flash",
+ "pluginspage", "http://www.adobe.com/go/getflashplayer"
+ );
+ } else { // flash is too old or we can't detect the plugin
+ var alternateContent = 'Alternate HTML content should be placed here. '
+ + 'This content requires the Adobe Flash Player. '
+ + '<a href=http://www.adobe.com/go/getflash/>Get Flash</a>';
+ document.write(alternateContent); // insert non-flash content
+ }
+// -->
+</script>
+<noscript>
+ <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
+ id="ThunderBoltFlexExample" width="100%" height="100%"
+ codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
+ <param name="movie" value="ThunderBoltFlexExample.swf" />
+ <param name="quality" value="high" />
+ <param name="bgcolor" value="#869ca7" />
+ <param name="allowScriptAccess" value="sameDomain" />
+ <embed src="ThunderBoltFlexExample.swf" quality="high" bgcolor="#869ca7"
+ width="100%" height="100%" name="ThunderBoltFlexExample" align="middle"
+ play="true"
+ loop="false"
+ quality="high"
+ allowScriptAccess="sameDomain"
+ type="application/x-shockwave-flash"
+ pluginspage="http://www.adobe.com/go/getflashplayer">
+ </embed>
+ </object>
+</noscript>
+</body>
+</html>

Modified: trunk/as3/example/flex/bin/ThunderBoltFlexExample.swf
==============================================================================
Binary files. No diff available.

Modified: trunk/as3/example/flex/src/ThunderBoltFlexExample.mxml
==============================================================================
--- trunk/as3/example/flex/src/ThunderBoltFlexExample.mxml (original)
+++ trunk/as3/example/flex/src/ThunderBoltFlexExample.mxml Sun Apr 13
02:28:07 2008
@@ -2,9 +2,9 @@
<!--
* Logging Flex projects using Firebug and ThunderBolt AS3
*
-* @version 1.0
+* @version 1.1
* @author Jens Krause [www.websector.de]
-* @date 10/14/07
+* @date 04/12/08
* @see http://www.websector.de/blog/category/thunderbolt/
* @see http://code.google.com/p/flash-thunderbolt/
* @source http://flash-thunderbolt.googlecode.com/svn/trunk/as3/
@@ -55,9 +55,10 @@
Logger.debug ("Flex is calling: An object with a nested object
and nested array", myObject);
break;
case "memButton":
- Logger.info(Logger.memorySnapshot());
+ Logger.info( Logger.memorySnapshot() );
+ break;
default:
- Logger.error ("Flex is calling: No button found with an ID
named " + id);
+ Logger.error ("Flex is calling: A button with an ID named " + id
+ " is not found");

}
}

Modified: trunk/as3/example/flex/src/ThunderBoltTargetExample.mxml
==============================================================================
--- trunk/as3/example/flex/src/ThunderBoltTargetExample.mxml (original)
+++ trunk/as3/example/flex/src/ThunderBoltTargetExample.mxml Sun Apr 13
02:28:07 2008
@@ -2,9 +2,9 @@
<!--
* Logging Flex projects using Firebug and ThunderBolt AS3
*
-* @version 1.0
+* @version 1.1
* @author Jens Krause [www.websector.de]
-* @date 10/14/07
+* @date 04/12/08
* @see http://www.websector.de/blog/category/thunderbolt/
* @see http://code.google.com/p/flash-thunderbolt/
* @source http://flash-thunderbolt.googlecode.com/svn/trunk/as3/
@@ -48,7 +48,7 @@
Log.getLogger("de.websector.playground.ThunderBoltTargetExample").info(Logger.memorySnapshot());
break;
default:
- Logger.error ("No button found with an ID named " + id);
+ Logger.error ("A button with an ID named " + id + " is not found");
}
}

Reply all
Reply to author
Forward
0 new messages