<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.3" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>Flog! &#62;</title>
	<link>http://greencollective.nl/blog</link>
	<description>Flog till you drop &#124;&#124; if you can't flog it then hog it!</description>
	<pubDate>Fri, 27 Apr 2012 02:07:32 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
	<language>en</language>
			<item>
		<title>Manage Windows Advanced Firewall ports with PHP trough COM class</title>
		<link>http://greencollective.nl/blog/windows-firewall-with-advance-security-manageable-trough-php-com-function/</link>
		<comments>http://greencollective.nl/blog/windows-firewall-with-advance-security-manageable-trough-php-com-function/#comments</comments>
		<pubDate>Thu, 15 Mar 2012 10:38:52 +0000</pubDate>
		<dc:creator>latcho</dc:creator>
		
		<category><![CDATA[php]]></category>

		<category><![CDATA[advanced security]]></category>

		<category><![CDATA[allow]]></category>

		<category><![CDATA[apache]]></category>

		<category><![CDATA[block]]></category>

		<category><![CDATA[COM]]></category>

		<category><![CDATA[firewall]]></category>

		<category><![CDATA[FwPolicy2]]></category>

		<category><![CDATA[hack]]></category>

		<category><![CDATA[plesk]]></category>

		<category><![CDATA[ports]]></category>

		<category><![CDATA[server]]></category>

		<category><![CDATA[windows]]></category>

		<category><![CDATA[windows server]]></category>

		<category><![CDATA[wscript.shell]]></category>

		<guid isPermaLink="false">http://greencollective.nl/blog/?p=46</guid>
		<description><![CDATA[One day you want to be able to quickly open and close a port for a certain service running on your windows server.
I agree most security preachers would be amazed what you can do with a default installation of Apache and PHP and would simply disable COM objects in php or simply rule out such [...]]]></description>
			<content:encoded><![CDATA[<p>One day you want to be able to quickly open and close a port for a certain service running on your windows server.<br />
I agree most security preachers would be amazed what you can do with a default installation of Apache and PHP and would simply disable COM objects in php or simply rule out such a functionalities by editing process rights on the Apache or PHP instances, but my machine  isn't the one where the whole world hangs on to so I have the liberty to do some fun proto POC stuff.</p>
<p>As such I wrote a simple script that allows you to load the Microsoft Advanced Firewall as a COM object and edit it's rules.<br />
With 'editing' I mean allowing or blocking a certain port / process rule or enabling / disabling a rule completely.<br />
Simply said this script allows you to alter existing rules but not to edit or add ports.</p>
<p>You can give the script a set of ports that it has to list, or you can switch a config boolean and list all configurable ports.<br />
If it is a remote server I advice you not to list port 80 <img src='http://greencollective.nl/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
You can leave out the the authentication block if you like, because most of the time people have setup htaccess themselves.</p>
<p><strong>Code preview below image </strong></p>
<p>or <strong>DOWNLOAD </strong>here: <a href="http://greencollective.nl/blog/wp-content/uploads/2012/03/firewalldemo._php_" title="source code firewall demo">source code firewall demo<br />
</a></p>
<p><a href="http://greencollective.nl/blog/wp-content/uploads/2012/03/windows_firewall_controller_php_com.png" title="demo: windows firewall controller in php with COM"><img src="http://greencollective.nl/blog/wp-content/uploads/2012/03/windows_firewall_controller_php_com.png" alt="demo: windows firewall controller in php with COM" /></a></p>
<p><code>*****<br />
PHP:<br />
*****</code></p>
<p><code>session_start();<br />
header("Cache-Control: no-cache, must-revalidate");<br />
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");<br />
header("Content-Type: text/html; charset=ansi");</code></p>
<p><code>/**<br />
* Windows Firewall with Advanced Security browser editor: enable / disable or block / allow existing rules.<br />
* @license Use, modify, destroy, improve and glue any license on this as long as I can keep using it myself <img src='http://greencollective.nl/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
* @author Stijn De Ryck<br />
*/</code></p>
<p><code>/******* ************* ********/<br />
/******* USER SETTINGS ********/<br />
/******* ************* ********/</code></p>
<p><code>//WWW-Auth<br />
const USERNAME = 'admin';<br />
const PASSWORD = 'password';<br />
//CHANGE this to ANY STRING of choice!<br />
const HASH_SECRET = "VPS_LATCHO_SECRET";<br />
//if MANAGE_ALL_PORTS is set to TRUE then the application wil ignore the compacted lists:<br />
// ( MANAGE_EXISTING_INBOUND_PORTS and MANAGE_EXISTING_OUTBOUND_PORTS ) and manage all ports that are found in existing rules<br />
const MANAGE_ALL_PORTS = FALSE;<br />
//The in the firewall existing predefined rules whereof you want to display the following INBOUND ports, "*" is also a valid option<br />
static $MANAGE_EXISTING_INBOUND_PORTS = array(80,21,23,3306,110,25,443,465,993,3389,6900,6800,8080,4389,81,9696);<br />
//The in the firewall existing predefined rules whereof you want to display the following OUTBOUND ports, "*" is also a valid option<br />
static $MANAGE_EXISTING_OUTBOUND_PORTS = array(110,25,443,465,993,3389,6900,8080,23,80,"*");</code></p>
<p><code>/******* **** ********/<br />
/******* AUTH ********/<br />
/******* **** ********/<br />
//improvable.... TODO post ?logout ?login with href</code></p>
<p><code>$authorized = false;<br />
if(isset($_GET['logout']) &amp;&amp; ($_SESSION['auth'])) {<br />
$_SESSION['auth'] = null;<br />
session_destroy();<br />
}<br />
if(isset($_SERVER['PHP_AUTH_USER']) &amp;&amp; isset($_SERVER['PHP_AUTH_PW'])) {<br />
$authuser = strtolower($_SERVER['PHP_AUTH_USER']);<br />
if (	(strtolower(USERNAME) == $authuser)<br />
&amp;&amp; (strtolower(PASSWORD) == strtolower($_SERVER['PHP_AUTH_PW']))<br />
&amp;&amp; (!empty($_SESSION['auth']))<br />
){		$authorized = true; }<br />
}<br />
if ( ! $authorized ) {<br />
if (!isset($_GET['logout']))<br />
{<br />
header('WWW-Authenticate: Basic Realm="Login please"');<br />
header('HTTP/1.0 401 Unauthorized');<br />
$_SESSION['auth'] = true;<br />
}<br />
exit;<br />
return;<br />
}</code></p>
<p><code>/******* ********* ********/<br />
/******* FW CONSTS ********/<br />
/******* ********* ********/</code></p>
<p><code>//Domain<br />
const NET_FW_PROFILE2_DOMAIN = 1;<br />
const NET_FW_PROFILE2_PRIVATE = 2;<br />
const NET_FW_PROFILE2_PUBLIC = 4;<br />
//Enabled rule<br />
const NET_FW_RULE_ENABLED = TRUE;<br />
const NET_FW_RULE_DISABLED = FALSE;<br />
//Direction<br />
const NET_FW_RULE_DIR_IN = 1;<br />
const NET_FW_RULE_DIR_OUT = 2;<br />
//Action<br />
const NET_FW_ACTION_ALLOW = 1;<br />
const NET_FW_ACTION_BLOCK = 0;<br />
//Protocol<br />
const NET_FW_IP_PROTOCOL_TCP = 6;<br />
const NET_FW_IP_PROTOCOL_UDP = 17;<br />
const NET_FW_IP_PROTOCOL_ICMPv4 = 1;<br />
const NET_FW_IP_PROTOCOL_ICMPv6 = 58;<br />
//human readable protocols<br />
$protoLabels  = array(NET_FW_IP_PROTOCOL_TCP =&gt; 'TCP', NET_FW_IP_PROTOCOL_UDP =&gt; 'UDP', NET_FW_IP_PROTOCOL_ICMPv4=&gt;'ICMPv4',NET_FW_IP_PROTOCOL_ICMPv6=&gt;'ICMPv6' );<br />
//human readable profiles ( public, private,...)<br />
$profileLabels  = array(1=&gt; 'Domain',2=&gt;'Private',4=&gt;'Public',3=&gt;'Dom+Priv',5=&gt;'Dom+Pub',6=&gt;'Priv+Pub',7=&gt;'Dom+Priv+Pub',2147483647=&gt;'All Profiles');</p>
<p>/******* ******************* ********/<br />
/******* RULES ENUM &amp; EDITOR ********/<br />
/******* ******************* ********/</p>
<p>$objFirewall =  new COM("HNetCfg.FwPolicy2");<br />
$inboundForm="";<br />
$outboundForm="";</p>
<p>foreach($objFirewall-&gt;Rules as $key =&gt; $rule) {</p>
<p>//NOTE: http://msdn.microsoft.com/en-us/library/windows/desktop/aa364724%28v=vs.85%29.aspx<br />
//rule's current settings:<br />
$name = $rule-&gt;Name;<br />
$appname = $rule-&gt;ApplicationName ;<br />
$svcname = $rule-&gt;ServiceName ;<br />
$desc = $rule-&gt;Description;<br />
$direction = $rule-&gt;Direction;<br />
$proto = $rule-&gt;Protocol;<br />
$action = $rule-&gt;Action;<br />
$profile = $rule-&gt;Profiles;<br />
$enabled = $rule-&gt;Enabled;</p>
<p>$localPorts = $rule-&gt;LocalPorts;<br />
$remotePorts = $rule-&gt;RemotePorts;<br />
//the local ports that are managed by this rule as array<br />
$aRuleLocalPorts = explode(',',$localPorts);<br />
$aRuleRemotePorts = explode(',',$remotePorts);<br />
//the md5 identifier that enables us to filter a rule.<br />
$identifier = md5(HASH_SECRET.$name.$appname.$svcname.$desc.$direction.$proto.$profile.$localPorts.$remotePorts);</p>
<p>if(  !	in_array( $proto , array( NET_FW_IP_PROTOCOL_TCP<br />
, NET_FW_IP_PROTOCOL_UDP<br />
, NET_FW_IP_PROTOCOL_ICMPv4<br />
, NET_FW_IP_PROTOCOL_ICMPv6<br />
)<br />
)<br />
||<br />
( 	! (MANAGE_ALL_PORTS)<br />
&amp;&amp;<br />
count(array_intersect($MANAGE_EXISTING_INBOUND_PORTS, $aRuleLocalPorts)) == 0<br />
&amp;&amp;<br />
count(array_intersect($MANAGE_EXISTING_OUTBOUND_PORTS, $aRuleRemotePorts)) == 0<br />
)<br />
) { continue; };</p>
<p>//if we received the md5 rule identifier as variable 'ToggleBlockAllow', toggle block/allow state<br />
if(	isset($_POST['ToggleBlockAllow']) &amp;&amp; $_POST['ToggleBlockAllow'] === $identifier ) {<br />
$action = ($rule-&gt;Action == NET_FW_ACTION_ALLOW) ?  NET_FW_ACTION_BLOCK : NET_FW_ACTION_ALLOW;<br />
$rule-&gt;Action = $action ;<br />
};<br />
//if we received the md5 rule identifier as variable 'ToggleEnabled', toggle enabled/disabled state<br />
if(	isset($_POST['ToggleEnabled']) &amp;&amp; $_POST['ToggleEnabled'] === $identifier ) {<br />
$enabled = ($rule-&gt;Enabled == NET_FW_RULE_ENABLED) ?  NET_FW_RULE_DISABLED : NET_FW_RULE_ENABLED;<br />
$rule-&gt;Enabled = $enabled ;<br />
};</p>
<p>//rule allowed/blocked state settings<br />
$allowChecked = ($action == NET_FW_ACTION_ALLOW) ? "checked=\"checked\"" : "";<br />
$allowLabel = ($action == NET_FW_ACTION_ALLOW) ? "&lt;b&gt;Allowed &lt;/b&gt;" : "&lt;u&gt;Blocked &lt;/u&gt;";<br />
//rule enabled state settings<br />
$enableChecked = ($enabled == NET_FW_RULE_ENABLED) ? "checked=\"checked\"" : "";<br />
$enableLabel = ($enabled == NET_FW_RULE_ENABLED) ? "&lt;b&gt;Rule enabled&lt;/b&gt;" : "&lt;u&gt;Rule disabled&lt;/u&gt;";<br />
$portListByDirection = ($direction == NET_FW_RULE_DIR_IN) ? $localPorts : $remotePorts ;<br />
$portListByDirection = str_replace(',',', ',$portListByDirection) ;<br />
//form color based on enabled/disabled rule, allowed/blocked state<br />
$col = ($enabled == NET_FW_RULE_ENABLED) ? (($action == NET_FW_ACTION_ALLOW) ? "#009922" : "#992200") : "#aaaaaF";<br />
//human readable protocol<br />
$protoLabel = $protoLabels[$proto];<br />
//human readable profile ( public, private,...)<br />
$profileLabel = $profileLabels[$profile];<br />
//messy form-item html for this rule<br />
$formItem ="&lt;tr&gt;";<br />
$formItem .="&lt;td valign='top'&gt;".$protoLabel."&lt;/td&gt;";<br />
$formItem .="&lt;td width='100' valign='top'&gt; &lt;font color='".$col."'&gt;[&lt;b&gt; $portListByDirection &lt;/b&gt;]&lt;/font&gt;&lt;/td&gt;";<br />
$formItem .="&lt;td  width='100' valign='top'&gt;  $profileLabel&lt;/td&gt;";<br />
$formItem .="&lt;td width='100' valign='top'&gt;&lt;font color='".$col."'&gt;  ".$allowLabel."&lt;/font&gt;&lt;input type=\"checkbox\" id=\"".$identifier."\" name=\"allowcheck\" onChange=\"toggle(this.id,'ToggleBlockAllow')\" ".$allowChecked." /&gt;&lt;/td&gt;";<br />
$formItem .="&lt;td width='120' valign='top'&gt;  ".$enableLabel."&lt;input type=\"checkbox\" id=\"".$identifier."\" name=\"enablecheck\" onChange=\"toggle(this.id,'ToggleEnabled')\" ".$enableChecked." /&gt;&lt;/td&gt;";<br />
$formItem .="&lt;td  valign='top'&gt;&lt;font color='".$col."'&gt;   ".$name."&lt;/font&gt;";<br />
$formItem .="&lt;i&gt;  &lt;font size=2&gt;".( strpos(strtoupper($appname),"SVCHOST") ? "SVCHOST: ":strtoupper($appname) ) .' '.strtoupper($svcname)."&lt;/font&gt;&lt;/i&gt;&lt;/label&gt;&lt;/td&gt;\n";<br />
$formItem ."&lt;/tr&gt;\n";</p>
<p>if( $direction == NET_FW_RULE_DIR_IN &amp;&amp; ( count(array_intersect($MANAGE_EXISTING_INBOUND_PORTS, $aRuleLocalPorts)) &gt; 0 || MANAGE_ALL_PORTS == TRUE ) ) {<br />
//attach inbound form item if we manage this port (MANAGE_INBOUND_PORTS)<br />
$inboundForm .= $formItem;<br />
}else if( $direction == NET_FW_RULE_DIR_OUT &amp;&amp; count(array_intersect($MANAGE_EXISTING_OUTBOUND_PORTS, $aRuleRemotePorts)) &gt; 0   || MANAGE_ALL_PORTS == TRUE) {<br />
//attach outbound form item if we manage this port (MANAGE_OUTBOUND_PORTS)<br />
$outboundForm .= $formItem;<br />
}<br />
}</p>
<p>$html = "&lt;html&gt;\n&lt;head&gt;\n";<br />
$toggleRuleScript = "&lt;script&gt;\n";<br />
$toggleRuleScript .= "function toggle(identifier,switchOption){\n";<br />
$toggleRuleScript .= "document.body.innerHTML += '&lt;form id=\"dynForm\" action=\"\" method=\"post\"&gt;&lt;input type=\"hidden\" name=\"'+switchOption+'\" value=\"'+identifier+'\"/&gt;&lt;/form&gt;'; \n";<br />
$toggleRuleScript .= "document.getElementById(\"dynForm\").submit(); \n}\n";<br />
$toggleRuleScript .= "&lt;/script&gt;\n";<br />
$html .=$toggleRuleScript;<br />
$html .="&lt;/head&gt;\n&lt;body&gt;\n";<br />
$html .="&lt;h3&gt;Inbound Rules&lt;/h3&gt;";<br />
$html .= "&lt;table border=1 bordercolor=#aaaaaa&gt;".$inboundForm."&lt;/table&gt;";<br />
$html .="&lt;h3&gt;Outbound Rules&lt;/h3&gt;";<br />
$html .= "&lt;table border=1 bordercolor=#aaaaaa&gt;".$outboundForm."&lt;/table&gt;";<br />
$html .="&lt;/body&gt;&lt;/html&gt;";<br />
echo $html;</p>
<p></code><code></code><code></code><code></code><code></code><code></code><code></code><code></code><code></code></p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://greencollective.nl/blog/windows-firewall-with-advance-security-manageable-trough-php-com-function/feed/</wfw:commentRss>
		</item>
		<item>
		<title>getting the xpath of a domNode element in javascript (within Air&#8217;s htmlComponent)</title>
		<link>http://greencollective.nl/blog/getting-the-xpath-of-a-domnode-element-in-javascript/</link>
		<comments>http://greencollective.nl/blog/getting-the-xpath-of-a-domnode-element-in-javascript/#comments</comments>
		<pubDate>Tue, 08 Mar 2011 20:22:23 +0000</pubDate>
		<dc:creator>latcho</dc:creator>
		
		<category><![CDATA[AS3]]></category>

		<category><![CDATA[Air]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[dhtml]]></category>

		<category><![CDATA[js]]></category>

		<category><![CDATA[xpath]]></category>

		<guid isPermaLink="false">http://greencollective.nl/blog/?p=44</guid>
		<description><![CDATA[I wanted to store references to certain html nodes and there info in a html document that was loaded in air's htmlcomponent.
It's reaonably easy to inject javascript into any loaded document.
The function I came up with is adapted from another example that I found online, but it is improved so that it takes care of [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted to store references to certain html nodes and there info in a html document that was loaded in air's htmlcomponent.</p>
<p>It's reaonably easy to inject javascript into any loaded document.</p>
<p>The function I came up with is adapted from another example that I found online, but it is improved so that it takes care of duplicate id's if any are found.</p>
<p>So here al little piece of JavaScript that will get you the xpath of a node in an html doument and a little helder function to check the validity of the generated xpath.</p>
<pre class="lang-xml prettyprint"><code><span class="pln">function createXPathFromElement(elm) {
    var allNodes = document.getElementsByTagName('*');
    for (segs = []; elm &amp;&amp; elm.nodeType == 1; elm = elm.parentNode)
    {
        if (elm.hasAttribute('id')) {
                var uniqueIdCount = 0;
                for (var n=0;n &lt; allNodes.length;n++) {
                    if (allNodes[n].hasAttribute('id') &amp;&amp; allNodes[n].id == elm.id) uniqueIdCount++;
                    if (uniqueIdCount &gt; 1) break;
                };
                if ( uniqueIdCount == 1) {
                    segs.unshift('id("' + elm.getAttribute('id') + '")');
                    return segs.join('/');
                } else {
                    segs.unshift(elm.localName.toLowerCase() + '[@id="' + elm.getAttribute('id') + '"]');
                }
        } else if (elm.hasAttribute('class')) {
            segs.unshift(elm.localName.toLowerCase() + '[@class="' + elm.getAttribute('class') + '"]');
        } else {
            for (i = 1, sib = elm.previousSibling; sib; sib = sib.previousSibling) {
                if (sib.localName == elm.localName)  i++; };
                segs.unshift(elm.localName.toLowerCase() + '[' + i + ']');
        };
    };
    return segs.length ? '/' + segs.join('/') : null;
}; 

function lookupElementByXPath(path) {
    var evaluator = new XPathEvaluator();
    var result = evaluator.evaluate(path, document.documentElement, null,XPathResult.FIRST_ORDERED_NODE_TYPE, null);
    return  result.singleNodeValue;
} </span></code></pre>
<p>in Air's htmlcomponent I wnated to have the javascript in the code without having to load an exteral js file (not tested) and maybe risking security sandbox errors.<br />
So In the onComplete handler of the htmlComponent I did this to inject the extra javascript in the document:<em> (Make sure to carefully escape double quotes \" and \&gt;\&lt; signs !)</em><br />
Again the same code, but now inline:<br />
handling the htmlComponent listener: this.addEventListener(Event.COMPLETE, onComplete);</p>
<pre class="lang-xml prettyprint"><code><span class="pln">
private function onComplete(e:Event):void
{
	var container:Object = this.window.document.createElement('div');
	this.window.onunload = cleanup;
	container.id = 'scriptContainer';
	this.window.document.body.appendChild(container);
	var script:Object = this.window.document.createElement("script");
	script.type = 'text/javascript';

	script.innerHTML = 	" function createXPathFromElement(elm) { \n"
		+"		var allNodes = document.getElementsByTagName('\*'); \n"
		+"		for (segs = []; elm &amp;&amp; elm.nodeType == 1; elm = elm.parentNode) \n"
		+"		{ \n"
		+"			if (elm.hasAttribute('id')) { \n"
		+"					var uniqueIdCount = 0; \n"
		+"					for (var n=0;n \&lt; allNodes.length;n++) { \n"
		+"						if (allNodes[n].hasAttribute('id') &amp;&amp; allNodes[n].id == elm.id) uniqueIdCount++; \n"
		+"						if (uniqueIdCount \&gt; 1) break; \n"
		+"					}; \n"
		+"					if ( uniqueIdCount == 1) { \n"
		+"						segs.unshift('id(\"' + elm.getAttribute('id') + '\")'); \n"
		+"						return segs.join('/'); \n"
		+"					} else { \n"
		+"						segs.unshift(elm.localName.toLowerCase() + '[@id=\"' + elm.getAttribute('id') + '\"]'); \n"
		+"					} \n"
		+"			} else if (elm.hasAttribute('class')) { \n"
		+"				segs.unshift(elm.localName.toLowerCase() + '[@class=\"' + elm.getAttribute('class') + '\"]'); \n"
		+"			} else { \n"
		+"				for (i = 1, sib = elm.previousSibling; sib; sib = sib.previousSibling) { \n"
		+"					if (sib.localName == elm.localName)  i++; }; \n"
		+"					segs.unshift(elm.localName.toLowerCase() + '[' + i + ']'); \n"
		+"			}; \n"
		+"		}; \n"
		+"		return segs.length ? '/' + segs.join('/') : null; \n"
		+"	}; \n"
		+"	\n"
		+"	function lookupElementByXPath(path) { \n"
		+"		var evaluator = new XPathEvaluator(); \n"
		+"		var result = evaluator.evaluate(path, document.documentElement, null,XPathResult.FIRST_ORDERED_NODE_TYPE, null); \n"
		+"		return  result.singleNodeValue; \n"
						+"	} \n";

	container.appendChild(script);
}
</span></code></pre>
<p>Within the htmlComponent (AS3) you can add code to listen for javascript mouse events and trace / store the xpath like this:</p>
<pre class="lang-xml prettyprint"><code><span class="pln">
public function onClick(el:Object):String
{
    var targ:Object = el.srcElement || el.target;
    return this.window.createXPathFromElement(targ);
}
</span></code></pre>
]]></content:encoded>
			<wfw:commentRss>http://greencollective.nl/blog/getting-the-xpath-of-a-domnode-element-in-javascript/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Adobe Air HtmlComponent full content to (png) Image: Problems and solutions</title>
		<link>http://greencollective.nl/blog/adobe-air-htmlcomponent-content-to-image-problems-and-solutions/</link>
		<comments>http://greencollective.nl/blog/adobe-air-htmlcomponent-content-to-image-problems-and-solutions/#comments</comments>
		<pubDate>Thu, 10 Feb 2011 16:10:28 +0000</pubDate>
		<dc:creator>latcho</dc:creator>
		
		<category><![CDATA[AS3]]></category>

		<category><![CDATA[Air]]></category>

		<category><![CDATA[BitmapData]]></category>

		<category><![CDATA[HtmlComponent]]></category>

		<category><![CDATA[HtmlToPng]]></category>

		<category><![CDATA[image]]></category>

		<category><![CDATA[png transform]]></category>

		<category><![CDATA[PngEncoder]]></category>

		<category><![CDATA[PngStackEncoder]]></category>

		<guid isPermaLink="false">http://greencollective.nl/blog/?p=34</guid>
		<description><![CDATA[I try to make this a comprehendable compact story post.
Html to image transformation in air has three difficulties:
1) BitmapData has size limitations
2) the HtmlComponent's horizontal or vertical size can't be larger then 2880 or 4096 px depending on the Air version so we can't grab the content in one time, and even if we could [...]]]></description>
			<content:encoded><![CDATA[<p>I try to make this a comprehendable compact story post.<br />
Html to image transformation in air has three difficulties:</p>
<p><strong>1)</strong> BitmapData has size limitations<br />
<strong>2) </strong>the HtmlComponent's horizontal or vertical size can't be larger then 2880 or 4096 px depending on the Air version so we can't grab the content in one time, and even if we could we still had problem 1)<br />
<strong>3) </strong>if we scroll the content of the html component to capture the content in multiple blocks then we hit upon a display invalidate / update problem; The scrolled display isn't updated yet when we draw it to BitmapData. If we would succeed in the capturing of multiple blocks, still we would have a problem tocombine them into 1)</p>
<p>My <strong>workaround </strong>is to scroll the content and grab it in multiple blocks.<br />
Every scroll I implemented a little timeout.<br />
To tackle the maximum BitmapData size problem of 1) without going into special compiler / expanded memory / C++ tricks, was to write the BitmapData of all blocks at once into a PNG. This way we prevent  that we have to combine them first into a (possible too) large BitmapData object.<br />
Therefore I took the adobe PngEncoder class and altered it so that instead of providing it with 1 BitmapData object, you can feed it a Vector-array of multiple BitmapData blocks and tell it how to write them away ( stacked vertically or horizontally). And so PngStackEncoder was born next to HtmlToPng.<br />
I chose to go with PNG, because it encodes faster then jpg.</p>
<p>Source files for grab here:  <a href="http://greencollective.nl/blog/wp-content/uploads/2011/02/htmltopng.zip" title="htmlToPng Source and Demo zip">htmlToPng Source and Demo zip</a></p>
<p><strong>HtmlToPng </strong>result in an easy workable interface:</p>
<p><a href="http://greencollective.nl/blog/wp-content/uploads/2011/02/html2png.png" title="html 2 png demo"><img src="http://greencollective.nl/blog/wp-content/uploads/2011/02/html2png.png" alt="html 2 png demo" /></a></p>
<p>The HtmlToPng class uses the altered PngEncoder: <strong>PngStackEncoder,</strong> used like this:</p>
<p><img src="http://greencollective.nl/blog/wp-content/uploads/2011/02/pngstackencoder.png" alt="PngStackEncoder usage" /></p>
<p>Above Demo html to png example will produce this images: (scalled down to 20% for this post).</p>
<p><a href="http://greencollective.nl/blog/wp-content/uploads/2011/02/html2png_1.png" title="html2png_1.png"><img src="http://greencollective.nl/blog/wp-content/uploads/2011/02/html2png_1.png" alt="html2png_1.png" /></a></p>
<p><a href="http://greencollective.nl/blog/wp-content/uploads/2011/02/html2png_2.png" title="html2png_2.png"><img src="http://greencollective.nl/blog/wp-content/uploads/2011/02/html2png_2.png" alt="html2png_2.png" /></a></p>
<p><a href="http://greencollective.nl/blog/wp-content/uploads/2011/02/html2png_3.png" title="html2png_3.png"><img src="http://greencollective.nl/blog/wp-content/uploads/2011/02/html2png_3.png" alt="html2png_3.png" /></a></p>
<p><a href="http://greencollective.nl/blog/wp-content/uploads/2011/02/html2png_4.png" title="html2png_4.png"><img src="http://greencollective.nl/blog/wp-content/uploads/2011/02/html2png_4.png" alt="html2png_4.png" /></a></p>
<p>where the black blocks are actually transparent or any other color you can provide with th the PngStackEncoder.encode fuction.</p>
]]></content:encoded>
			<wfw:commentRss>http://greencollective.nl/blog/adobe-air-htmlcomponent-content-to-image-problems-and-solutions/feed/</wfw:commentRss>
		</item>
		<item>
		<title>FlashDevelop Dark Theme As3 Syntax Colors (updated FD4)</title>
		<link>http://greencollective.nl/blog/flashdevelop-dark-theme-as3-syntax-colors/</link>
		<comments>http://greencollective.nl/blog/flashdevelop-dark-theme-as3-syntax-colors/#comments</comments>
		<pubDate>Thu, 10 Feb 2011 14:40:15 +0000</pubDate>
		<dc:creator>latcho</dc:creator>
		
		<category><![CDATA[AS3]]></category>

		<category><![CDATA[flashdevelop]]></category>

		<category><![CDATA[theme]]></category>

		<guid isPermaLink="false">http://greencollective.nl/blog/?p=31</guid>
		<description><![CDATA[UPDATE 26 October 2011:
New download for Flashdevelop 4 because the color scheme installer of FD3 didn't seemd to do the trick.
Download here for &#62;FD4:
Flashdevelop4_Dark_Theme_Latcho_v2.fdz
I updated my dark theme a bit to be even lighter on the eyes. Minor changes.
The method description block's green color has now less contrast with the background.
The brown color for class [...]]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE 26 October 2011</strong>:</p>
<p>New download for <strong>Flashdevelop 4</strong> because the color scheme installer of FD3 didn't seemd to do the trick.</p>
<p>Download here for &gt;FD4:</p>
<p><a href="http://greencollective.nl/blog/wp-content/uploads/2011/10/flashdevelop4_dark_theme_latcho_v2.fdz" title="Flashdevelop4_Dark_Theme_Latcho_v2.fdz">Flashdevelop4_Dark_Theme_Latcho_v2.fdz</a></p>
<p>I updated my dark theme a bit to be even lighter on the eyes. Minor changes.</p>
<p>The method description block's green color has now less contrast with the background.</p>
<p>The brown color for class / function names is now a bit altered.</p>
<p>Download the modified theme here (<strong>&lt;=FD3</strong>):<a href="http://greencollective.nl/blog/wp-content/uploads/2011/02/flashdevelop_dark_theme_latcho_v2.fdz" title="Flashdevelop_Dark_Theme_Latcho_v2.fdz"> Flashdevelop_Dark_Theme_Latcho_v2.fdz</a></p>
<p>updated Style:</p>
<p><a href="http://greencollective.nl/blog/wp-content/uploads/2011/02/flashdevelop-dark-as3-syntax-theme-v2-latcho.png" title="Flashdevelop-Dark-As3-Syntax-Theme-v2-Latcho"><img src="http://greencollective.nl/blog/wp-content/uploads/2011/02/flashdevelop-dark-as3-syntax-theme-v2-latcho.png" alt="Flashdevelop-Dark-As3-Syntax-Theme-v2-Latcho" /></a></p>
<p>The font used before was inconsolata, but that doesn't renders nice in FD3 anymore so I now advice to use Consolas from M$.</p>
<p>You can download the Consolas font pack here for free: <a href="http://www.microsoft.com/downloads/details.aspx?familyid=22e69ae4-7e40-4807-8a86-b3d36fab68d3" title="Consolas Font Download">Consolas Download </a></p>
<p>Cheers,</p>
<p>Latcho</p>
]]></content:encoded>
			<wfw:commentRss>http://greencollective.nl/blog/flashdevelop-dark-theme-as3-syntax-colors/feed/</wfw:commentRss>
		</item>
		<item>
		<title>(Obsfucate data) embed an swf as a hexadecimal string in your &#8230;swf</title>
		<link>http://greencollective.nl/blog/obsfucate-swf-data-by-embedding-it-as-a-hex-string/</link>
		<comments>http://greencollective.nl/blog/obsfucate-swf-data-by-embedding-it-as-a-hex-string/#comments</comments>
		<pubDate>Sat, 26 Sep 2009 01:47:40 +0000</pubDate>
		<dc:creator>latcho</dc:creator>
		
		<category><![CDATA[AS3]]></category>

		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[binary]]></category>

		<category><![CDATA[bintohex]]></category>

		<category><![CDATA[embed swf]]></category>

		<category><![CDATA[hex]]></category>

		<category><![CDATA[hexToBin]]></category>

		<category><![CDATA[loadbytes]]></category>

		<category><![CDATA[Obsfucate]]></category>

		<category><![CDATA[swf]]></category>

		<guid isPermaLink="false">http://greencollective.nl/blog/?p=28</guid>
		<description><![CDATA[You can embed an swf, or any other binary octet stream, containing -harder to get to- data as a hexadecimal string into your project.
Note: This is not true  data security.  Nothing is securable in actionscript, but you CAN make it hard(er) to get to.

So to describe my last attempt to hide some game [...]]]></description>
			<content:encoded><![CDATA[<p>You can embed an swf, or any other binary octet stream, containing -harder to get to- data as a hexadecimal string into your project.</p>
<p>Note: This is not true  data security.  Nothing is securable in actionscript, but you CAN make it hard(er) to get to.<br />
<br />
So to describe my last attempt to hide some game xml data that I embedded in an second swf i went ahead like this to embed that swf as a hex string in my main project like this:</p>
<li><strong>1)</strong> Create a seperate empty project along your main project and create a simple swf containing the protectable data.</li>
<p></p>
<li><strong>2)</strong> I'm not a smoker but let's say you want secure the class <code>"SensimillaPlantagesXml.as"</code> containing your sensitive sensimilla location xml data. Compile that class into "sensitive.swf" (uhum). Make sure that that class is embedded into the swf by including a reference to it in your document's main class <code>new SensimillaPlantagesXml()</code> or just put 'SensimillaPlantagesXml' as a word in your documentclass's constructor</li>
<p></p>
<li><strong>3)</strong>Create a second project along your main project that will serve as a hexadecimal tracer: Embed the swf in it with the Embed tag. We will now convert the binary application octet stream from 'sensitive.swf' to a hexadecimal string:</li>
<p>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="600" height="300" id="ftf_wp" align="middle">
		  <param name="movie" value="/blog/wp-content/plugins/FlashTextFormatter/ftf_wp.swf" />
		  <param name="quality" value="high" />
		  <param name="scale" value="noscale" />
		  <param name="bgcolor" value="#ffffff" />
		  <param name="flashvars" value="w=600&h=300&file=index.php&ftf=true&postID=28&no=0&def=/blog/wp-content/plugins/FlashTextFormatter/definitions/as2.xml&auto=true&" />
		  <embed src="/blog/wp-content/plugins/FlashTextFormatter/ftf_wp.swf" quality="high" scale="noscale" bgcolor="#ffffff" width="600" height="300" name="ftf_wp" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="w=600&h=300&file=index.php&ftf=true&postID=28&no=0&def=/blog/wp-content/plugins/FlashTextFormatter/definitions/as2.xml&auto=true&" />
		</object></p>
<p></p>
<li>4) This will leave us with a long hexadecimal string in the trace output window, representing your swf as hexadecimal data.<br />
The class to do the Binary to Hexadecimal conversion I will include later, below in this post. </li>
<p><code>Trace Output: 4357530a2a60000078dad55c4d6cdbd87626f547cbffae6399444f9274a3d4a642b4e9cc4719eedb.........</code></p>
<li>5)Copy that string without additional spaces and paste it in a 'Data' class under a variable, called var _hexData here.
<li>6)So let me show you now how you load this hexadcimal string, and parse it as an accessible swf within you main project:</li>
<p>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="700" height="800" id="ftf_wp" align="middle">
		  <param name="movie" value="/blog/wp-content/plugins/FlashTextFormatter/ftf_wp.swf" />
		  <param name="quality" value="high" />
		  <param name="scale" value="noscale" />
		  <param name="bgcolor" value="#ffffff" />
		  <param name="flashvars" value="w=700&h=800&file=index.php&ftf=true&postID=28&no=1&def=/blog/wp-content/plugins/FlashTextFormatter/definitions/as2.xml&auto=true&" />
		  <embed src="/blog/wp-content/plugins/FlashTextFormatter/ftf_wp.swf" quality="high" scale="noscale" bgcolor="#ffffff" width="700" height="800" name="ftf_wp" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="w=700&h=800&file=index.php&ftf=true&postID=28&no=1&def=/blog/wp-content/plugins/FlashTextFormatter/definitions/as2.xml&auto=true&" />
		</object><br />
<br />
The only easy way to get to ALL the data of the embedded-hex-swf is (including bitmaps) is<br />
making an swf file from it; Now be my guest and write me a short (AIR?) tutorial please :).</p>
<p>This procedure is not super secure but discourages our fast'n easy decompiler friends.<br />
Still better then posting the data over http.<br />
If the process is not clear by now, please let me know, so I can improve above instructions.</p>
<p>Here you can see the transformation <a href="http://greencollective.nl/blog/wp-content/uploads/2009/09/binhex.as" title="View BinHex.as">class</a> that contains the two static functions binToHex() and hexToBin();</p>
<p>
And here you can see BinHex.as:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="600" height="675" id="ftf_wp" align="middle">
		  <param name="movie" value="/blog/wp-content/plugins/FlashTextFormatter/ftf_wp.swf" />
		  <param name="quality" value="high" />
		  <param name="scale" value="noscale" />
		  <param name="bgcolor" value="#ffffff" />
		  <param name="flashvars" value="w=600&h=675&file=index.php&ftf=true&postID=28&no=2&def=/blog/wp-content/plugins/FlashTextFormatter/definitions/as2.xml&auto=true&" />
		  <embed src="/blog/wp-content/plugins/FlashTextFormatter/ftf_wp.swf" quality="high" scale="noscale" bgcolor="#ffffff" width="600" height="675" name="ftf_wp" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="w=600&h=675&file=index.php&ftf=true&postID=28&no=2&def=/blog/wp-content/plugins/FlashTextFormatter/definitions/as2.xml&auto=true&" />
		</object></p>
<p><a href="http://greencollective.nl/blog/wp-content/uploads/2009/09/binhex.as" title="Download/View BinHex.as">Download BinHex.as</a></li>
<p>Ciao !</p>
<p><a href="http://greencollective.nl/blog/wp-content/uploads/2009/09/swfembedashexadecimalstring_post.txt" title="Swf">See this post as raw text</a></p>
]]></content:encoded>
			<wfw:commentRss>http://greencollective.nl/blog/obsfucate-swf-data-by-embedding-it-as-a-hex-string/feed/</wfw:commentRss>
		</item>
		<item>
		<title>FlashDevelop: duplicate a text selection block with a shortcut</title>
		<link>http://greencollective.nl/blog/flashdevelop-duplicate-a-text-selection-block-with-a-shortcut/</link>
		<comments>http://greencollective.nl/blog/flashdevelop-duplicate-a-text-selection-block-with-a-shortcut/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 19:14:10 +0000</pubDate>
		<dc:creator>latcho</dc:creator>
		
		<category><![CDATA[flashdevelop]]></category>

		<category><![CDATA[block]]></category>

		<category><![CDATA[duplication]]></category>

		<category><![CDATA[macro]]></category>

		<category><![CDATA[selection]]></category>

		<category><![CDATA[shortcut]]></category>

		<category><![CDATA[text]]></category>

		<guid isPermaLink="false">http://greencollective.nl/blog/?p=24</guid>
		<description><![CDATA[Want to duplicate multiple lines of code with a keyboard shortcut in flashdevelop ?
FlashDevelop-&#62;Tools-&#62;Macros-&#62;Add-&#62; Entries-&#62;... :

ScintillaCommand&#124;SelectionDuplicate
Label: &#38;BlockDupe
Shortcut: Alt+DOWN (my own choice)


Dupe'm 
Cheers to Joel Stransky 
]]></description>
			<content:encoded><![CDATA[<p>Want to duplicate multiple lines of code with a keyboard shortcut in flashdevelop ?<br />
FlashDevelop-&gt;Tools-&gt;Macros-&gt;Add-&gt; <strong>Entries-&gt;... </strong>:</p>
<pre></pre>
<pre><font color="#339966"><strong>ScintillaCommand|SelectionDuplicate</strong></font></pre>
<p><strong>Label: </strong>&amp;BlockDupe<br />
<strong>Shortcut:</strong> Alt+DOWN (my own choice)</p>
<pre></pre>
<p><a href="http://greencollective.nl/blog/wp-content/uploads/2009/08/dupeme.gif" title="text block duplication trough flashdevelop macro"><img src="http://greencollective.nl/blog/wp-content/uploads/2009/08/dupeme.gif" alt="text block duplication trough flashdevelop macro" /></a></p>
<p>Dupe'm <img src='http://greencollective.nl/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
Cheers to Joel Stransky <img src='http://greencollective.nl/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://greencollective.nl/blog/flashdevelop-duplicate-a-text-selection-block-with-a-shortcut/feed/</wfw:commentRss>
		</item>
		<item>
		<title>FlashDevelop Syntax Coloring: Dark Theme</title>
		<link>http://greencollective.nl/blog/flashdevelop-syntax-coloring-dark-template/</link>
		<comments>http://greencollective.nl/blog/flashdevelop-syntax-coloring-dark-template/#comments</comments>
		<pubDate>Sat, 15 Aug 2009 00:47:38 +0000</pubDate>
		<dc:creator>latcho</dc:creator>
		
		<category><![CDATA[AS3]]></category>

		<category><![CDATA[flashdevelop]]></category>

		<category><![CDATA[fd]]></category>

		<category><![CDATA[flahdevelop]]></category>

		<category><![CDATA[inconsolata]]></category>

		<category><![CDATA[syntax coloring]]></category>

		<guid isPermaLink="false">http://greencollective.nl/blog/?p=19</guid>
		<description><![CDATA[----
See for UPDATE (oktober 2011) and flashdevelop 4 compatible installert his post:
http://greencollective.nl/blog/?p=31
----
Back in time I used Sepy as a texteditor as an alternative to the Flash IDE Non-Code-Editor.
Now my snappy editor of choice is FlashDevelop, totally tailored towards Flex SDK publishing.
In Sepy I had a nice dark background theme, but since the switch to FD [...]]]></description>
			<content:encoded><![CDATA[<p>----</p>
<p>See for UPDATE (oktober 2011) and <strong>flashdevelop <u>4</u></strong> compatible installert his post:</p>
<p><a href="http://greencollective.nl/blog//?p=31" rel="nofollow">http://greencollective.nl/blog/?p=31</a><br />
----</p>
<p>Back in time I used Sepy as a texteditor as an alternative to the Flash IDE Non-Code-Editor.<br />
Now my snappy editor of choice is FlashDevelop, totally tailored towards Flex SDK publishing.</p>
<p>In Sepy I had a nice dark background theme, but since the switch to FD I never took the time to configure colors in FD.<br />
It really can make a difference for your eyes, a darker background; Less radiation or flickerHz effects I 'd say.</p>
<p>For everybody who wants to get AS3 coding  'darker', here is my theme for you to grab. It's a flash develop zip file, and should install by just running it after download and answer the dialog with..YES! . <em>(  A restart of FD might be necessary ? )<br />
</em>If you're not sure yet, backup your current brightwhite scheme first.<em><br />
</em> <strong>Grab here</strong>: <strong><a href="http://greencollective.nl/blog/wp-content/uploads/2009/08/syntaxcoloras3_fd_latcho.fdz" title="SyntaxColorAS3_FD_Latcho.fdz">SyntaxColorAS3_FD_Latcho.fdz</a></strong></p>
<p>[[ UPDATE: there is a minor update on this the with minimal changes available here: http://greencollective.nl/blog/?p=31  ]]</p>
<p>You can alter and save your settings by opening the menu Tools&gt;Syntax Coloring:AS3.</p>
<p>The font I just started using is named 'Inconsolata'  (as seen in the screenshot);<br />
Seems to be  a 1st choice of a bunch-a-folks. Looks peacefull to me on first sight.<br />
The original Inconsolata Open Type font wasn't received by FD's font enumerator, but I found a ported TTF that does well.<br />
<strong>Grab here:  <a href="http://greencollective.nl/blog/wp-content/uploads/2009/08/inconsolata.ttf" title="Inconsolata.ttf">Inconsolata.ttf</a></strong></p>
<p>Enjoy.</p>
<p><img src="http://greencollective.nl/blog/wp-content/uploads/2009/08/colorscheme.png" alt="preview SyntaxColorAS3_FD_Latcho" /></p>
<p>Why wouldn't I be a</p>
<p><a href="http://www.flashdevelop.org/wikidocs/index.php?title=FlashDevelop:Site_support" title="and you ?"><img src="http://www.flashdevelop.org/downloads/support/flashdevelop_sponsor.png" alt="sponsor" height="50" hspace="2" width="120" align="left" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://greencollective.nl/blog/flashdevelop-syntax-coloring-dark-template/feed/</wfw:commentRss>
		</item>
		<item>
		<title>setting breakpoints, debug swf via console / terminal /prompt with fdb</title>
		<link>http://greencollective.nl/blog/debug-swf-via-console-terminal-prompt/</link>
		<comments>http://greencollective.nl/blog/debug-swf-via-console-terminal-prompt/#comments</comments>
		<pubDate>Wed, 12 Aug 2009 23:00:35 +0000</pubDate>
		<dc:creator>latcho</dc:creator>
		
		<category><![CDATA[AS3]]></category>

		<category><![CDATA[mxmlc - flex sdk]]></category>

		<category><![CDATA[breakpoint]]></category>

		<category><![CDATA[debug]]></category>

		<category><![CDATA[fdb]]></category>

		<category><![CDATA[prompt]]></category>

		<category><![CDATA[step]]></category>

		<category><![CDATA[terminal]]></category>

		<guid isPermaLink="false">http://greencollective.nl/blog/?p=18</guid>
		<description><![CDATA[Finally found a nice article that explains how flex sdk's fdb command line debug tool works  
Reminder for myself:
http://installingcats.com/2007/12/07/how-to-use-command-line-debugger-fdb-to-debug-flex-flash-on-mac-os-x/
Got into it for a moment ----&#62; this will be a messy post  
found some extra info / commands within fdb now:
New to fdb? Do 'tutorial' for basic info.
List of fdb commands:
bt (bt)             Print backtrace [...]]]></description>
			<content:encoded><![CDATA[<p>Finally found a nice article that explains how flex sdk's fdb command line debug tool works <img src='http://greencollective.nl/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Reminder for myself:</p>
<p><a href="http://installingcats.com/2007/12/07/how-to-use-command-line-debugger-fdb-to-debug-flex-flash-on-mac-os-x/" title="http://installingcats.com/2007/12/07/how-to-use-command-line-debugger-fdb-to-debug-flex-flash-on-mac-os-x/">http://installingcats.com/2007/12/07/how-to-use-command-line-debugger-fdb-to-debug-flex-flash-on-mac-os-x/</a></p>
<p>Got into it for a moment ----&gt; this will be a messy post <img src='http://greencollective.nl/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>found some extra info / commands within fdb now:</p>
<p>New to fdb? Do 'tutorial' for basic info.<br />
List of fdb commands:<br />
bt (bt)             Print backtrace of all stack frames<br />
break (b)           Set breakpoint at specified line or function<br />
cf (cf)             Display the name and number of the current file<br />
clear (cl)          Clear breakpoint at specified line or function<br />
condition (cond)    Apply/remove conditional expression to a breakpoint<br />
continue (c)        Continue execution after stopping at breakpoint<br />
commands (com)      Sets commands to execute when breakpoint hit<br />
delete (d)          Delete breakpoints or auto-display expressions<br />
directory (dir)     Add a directory to the search path for source files<br />
disable (disab)     Disable breakpoints or auto-display expressions<br />
disassemble (disas) Disassemble source lines or functions<br />
display (disp)      Add an auto-display expressions<br />
enable (e)          Enable breakpoints or auto-display expressions<br />
file (fil)          Specify application to be debugged.<br />
finish (f)          Execute until current function returns<br />
handle (han)        Specify how to handle a fault<br />
help (h)            Display help on fdb commands<br />
home (ho)           Set listing location to where execution is halted<br />
info (i)            Display information about the program being debugged<br />
kill (k)            Kill execution of program being debugged<br />
list (l)            List specified function or line<br />
next (n)            Step program<br />
print (p)           Print value of variable EXP<br />
pwd (pw)            Print working directory<br />
quit (q)            Exit fdb<br />
run (r)             Start debugged program<br />
set (se)            Set the value of a variable<br />
source (so)         Read fdb commands from a file<br />
step (s)            Step program until it reaches a different source line<br />
tutorial (t)        Display a tutorial on how to use fdb<br />
undisplay (u)       Remove an auto-display expression<br />
viewswf (v)         Set or clear filter for file listing based on swf<br />
what (wh)           Displays the context of a variable<br />
where (w)           Same as bt<br />
Type 'help' followed by command name for full documentation.<br />
(fdb)</p>
<p>Start an application with 'run'.<br />
View file names with 'info sources'.<br />
List a file with 'list'.<br />
Set breakpoints with 'break'.<br />
Execute program with 'continue' until a breakpoint is hit.<br />
Examine state of program with 'where', 'print', 'info locals'.<br />
Execute individual statements with 'next', 'step', and 'finish'.<br />
Resume execution with 'continue'.<br />
Quit fdb with 'quit'.</p>
<p>It boils down to launching FDB.EXE in your flexsdk's 'bin' dir.<br />
- Typing run:<br />
(fdb) <strong>run</strong></p>
<p>- Open a debug-enabled swf (preferably on http in your browser since that ads-in network access if you don't have security configured for that local swf path)<br />
- set a breakpoint via a functionname (even if it is in another file, the name will match when fdb hits it), so for example type:<br />
(fdb) <strong>b registerModule</strong><strong>&lt;enter&gt;</strong><br />
<em>You have now set a breakpoint for that function name that will be resolved later, linenumbers / filenames must be possible too.</em><br />
And then type <strong>continue + &lt;enter&gt;</strong> ( add more breakpoints if you like) and again<strong> continue + &lt;enter&gt;<br />
</strong><em>The swf will now run until it hits the breakpoint marked functionname 'registerModule':</em><strong><br />
Resolved breakpoint 1 to registerModule() at ModuleManager.as:23<br />
</strong>(fdb) <strong>continue + &lt;enter&gt;</strong><br />
<strong>Breakpoint 1, registerModule() at ModuleManager.as:23   (yeahaa!)<br />
23             public function registerModule(modRegName:String,instance:IModule):void {<br />
</strong>now by command <strong>p</strong> we want to know what the variable  'instance' holds<br />
<em>( note (!) if you end the variable name with  a dot (<strong>.</strong>) you get more info) !</em>:<br />
(fdb) <strong>p instance.</strong></p>
<p>outputs:<strong><br />
$7 = instance = [Object 758409729, class='nl.greenberry.gogeo.app::App']<br />
_appController = [Object 757300145, class='nl.greenberry.gogeo.app::AppController']<br />
_appDisplayModel = null<br />
_appEventModel = null<br />
_appModuleManager = null<br />
_appSoundModel = null<br />
_eventModel = [Object 758625729, class='nl.greenberry.gogeo.app::EventModel']<br />
_modelLocator = [Object 758703937, class='nl.greenberry.gogeo.app::ModelLocator']<br />
_moduleManager = [Object 760443361, class='nl.greenberry.gogeo.app::ModuleManager']<br />
_moduleName = null<br />
_stage = [Object 756722513, class='flash.display::Stage']<br />
displayModel = [Object 757301009, class='nl.greenberry.gogeo.app::DisplayModel']<br />
eventModel = [Object 758625729, class='nl.greenberry.gogeo.app::EventModel']<br />
moduleManager = [Object 760443361, class='nl.greenberry.gogeo.app::ModuleManager']<br />
moduleName = null<br />
NAME = "Go-Geo"<br />
soundModel = [Object 758409793, class='nl.greenberry.gogeo.app::SoundModel']<br />
stage = [Object 756722513, class='flash.display::Stage']<br />
VERSION = "0.0.1"</strong></p>
<p>and the rest you will find out !</p>
<p>by the way<strong> you can alter variables</strong> realtime, and it displays your traces too:<br />
<strong>[trace] sayHello</strong></p>
<p>cheers !<br />
Flashdevelop now complete for me <img src='http://greencollective.nl/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://greencollective.nl/blog/debug-swf-via-console-terminal-prompt/feed/</wfw:commentRss>
		</item>
		<item>
		<title>flex sdk compile time variables, switches and resources Hacks</title>
		<link>http://greencollective.nl/blog/flex-sdk-compile-time-variables-switches-and-resources-hacks/</link>
		<comments>http://greencollective.nl/blog/flex-sdk-compile-time-variables-switches-and-resources-hacks/#comments</comments>
		<pubDate>Tue, 09 Dec 2008 01:51:27 +0000</pubDate>
		<dc:creator>latcho</dc:creator>
		
		<category><![CDATA[AS3]]></category>

		<category><![CDATA[mxmlc - flex sdk]]></category>

		<category><![CDATA[flex sdk]]></category>

		<category><![CDATA[mxmlc]]></category>

		<guid isPermaLink="false">http://greencollective.nl/blog/?p=17</guid>
		<description><![CDATA[Super nice article on how to create a compiletime conditional switch for for ex. calling an alternate version of the same function or adding compiletime var-values at  with the flex sdk command line
http://code.awenmedia.com/node/34
Code examples from his site:
ADDING COMPILETIME VARS:


mxmlc MyConfigClass.as -define+=CONFIG::someSetting,true
or
...-define+=CONFIG::myString,"'Hello!'" -define+=CONFIG::myNumber,"7"
for someSetting the AS3 class would be:

package {
public class MyConfigClass
{
   public static [...]]]></description>
			<content:encoded><![CDATA[<p>Super nice article on how to create a compiletime conditional switch for for ex. calling an alternate version of the same function or adding compiletime var-values at  with the flex sdk command line<br />
http://code.awenmedia.com/node/34</p>
<p>Code examples from his site:</p>
<pre class="geshifilter-javascript"><strong><strong>ADDING COMPILETIME VARS:

</strong></strong></pre>
<pre class="geshifilter-actionscript"><strong>mxmlc MyConfigClass.<span style="color: #006600">as</span> -define+=CONFIG::someSetting,<span style="color: #000000; font-weight: bold">true
or
</span>...-define+=CONFIG::myString,<span style="color: #ff0000">"'Hello!'"</span> -define+=CONFIG::myNumber,<span style="color: #ff0000">"7"</span></strong></pre>
<p>for someSetting the AS3 class would be:</p>
<p class="geshifilter">
<pre class="geshifilter-javascript"><span style="color: #003366; font-weight: bold">package</span> <span style="color: #66cc66">{</span>
<span style="color: #003366; font-weight: bold">public</span> <span style="color: #003366; font-weight: bold">class</span> MyConfigClass
<span style="color: #66cc66">{</span>
   <span style="color: #003366; font-weight: bold">public</span> static <span style="color: #003366; font-weight: bold">const</span> SOME_SETTING:Boolean=CONFIG::someSetting;  <span style="color: #009900; font-style: italic">// Actual AS3 this time</span>

   <span style="color: #003366; font-weight: bold">public</span> <span style="color: #003366; font-weight: bold">function</span> doSomething<span style="color: #66cc66">(</span><span style="color: #66cc66">)</span>:<span style="color: #000066; font-weight: bold">void</span>
   <span style="color: #66cc66">{</span>
      <span style="color: #000066; font-weight: bold">if</span> <span style="color: #66cc66">(</span>SOME_SETTING<span style="color: #66cc66">)</span>
      <span style="color: #66cc66">{</span>
          <span style="color: #009900; font-style: italic">// Do it!</span>
      <span style="color: #66cc66">}</span>
   <span style="color: #66cc66">}</span>
<span style="color: #66cc66">}</span>
<span style="color: #66cc66">}</span></pre>
<pre class="geshifilter-javascript"></pre>
<pre class="geshifilter-javascript"><strong>CONDITIONAL FUNCTION SWITCH:
</strong>
mxmlc MyClass.<span style="color: #006600">as</span> -define+=CONFIG::isDebug,<span style="color: #000000; font-weight: bold">true</span>  -define+=CONFIG::isRelease,<span style="color: #000000; font-weight: bold">false

</span>//AS3
package
<span style="color: #66cc66">{</span>
<span style="color: #0066cc">public</span> <span style="color: #000000; font-weight: bold">class</span> MyClass
<span style="color: #66cc66">{</span>
    CONFIG::isDebug
    <span style="color: #0066cc">public</span> <span style="color: #000000; font-weight: bold">function</span> doSomething<span style="color: #66cc66">(</span><span style="color: #66cc66">)</span>:<span style="color: #0066cc">void</span>
    <span style="color: #66cc66">{</span>
        <span style="color: #0066cc">trace</span><span style="color: #66cc66">(</span><span style="color: #ff0000">"This is a debug build!"</span><span style="color: #66cc66">)</span>;
    <span style="color: #66cc66">}</span>

    CONFIG::isRelease
    <span style="color: #0066cc">public</span> <span style="color: #000000; font-weight: bold">function</span> doSomething<span style="color: #66cc66">(</span><span style="color: #66cc66">)</span>:<span style="color: #0066cc">void</span>
    <span style="color: #66cc66">{</span>
        <span style="color: #0066cc">trace</span><span style="color: #66cc66">(</span><span style="color: #ff0000">"This is a release build!"</span><span style="color: #66cc66">)</span>;
    <span style="color: #66cc66">}</span>
<span style="color: #66cc66">}</span>
<span style="color: #66cc66">}</span></pre>
<pre class="geshifilter-javascript"></pre>
<pre class="geshifilter-javascript"></pre>
<p>Another from usefull tip-set from awen on adding resources and css files at compiletime by abusing some flex buildin hacks:</p>
<p>http://code.awenmedia.com/node/33</p>
<pre class="geshifilter-actionscript">
<strong>
</strong></pre>
]]></content:encoded>
			<wfw:commentRss>http://greencollective.nl/blog/flex-sdk-compile-time-variables-switches-and-resources-hacks/feed/</wfw:commentRss>
		</item>
		<item>
		<title>AS3 textfield blinking caret after textfield focus / tabbing ? Solved!</title>
		<link>http://greencollective.nl/blog/as3-caret-textfieldstagefocus-setselection-bugginess/</link>
		<comments>http://greencollective.nl/blog/as3-caret-textfieldstagefocus-setselection-bugginess/#comments</comments>
		<pubDate>Sat, 19 Jul 2008 01:21:05 +0000</pubDate>
		<dc:creator>latcho</dc:creator>
		
		<category><![CDATA[AS3]]></category>

		<guid isPermaLink="false">http://greencollective.nl/blog/?p=16</guid>
		<description><![CDATA[2011 note: This is only tested and works with normal textfields and not with the new extended TLF textfield.
To obtain focus on a textfield with a custom textformat on it can give you headaches:
From wrong caret color to disapaering textcontent when you use tab button  to unselectable text content.
You just keep fumbling around with [...]]]></description>
			<content:encoded><![CDATA[<p><em>2011 note: This is only tested and works with normal textfields and not with the new extended TLF textfield.</em></p>
<p>To obtain focus on a textfield with a custom textformat on it can give you headaches:<br />
From wrong caret color to disapaering textcontent when you use tab button  to unselectable text content.<br />
You just keep fumbling around with _Textfield.stage.focus = _Textfield without joy.<br />
I lost several hours to get the caret blinking where I wanted it.</p>
<p>It is so simple if you just had known that you NEED TO SET THE<br />
<code>Textfield.<strong>defaultText<font color="#008000">F</font>ormat </strong>= myFormat </code>wright before you had the line <code>textfield.setTextformat(myFormat)</code>.</p>
<p>It seems that focussing or unfocussing or tabbbing resets your textformat with the default textformat,<br />
and since that didn't exist... flash defaults to a STATIC textfield. YipiYoYO....<br />
Figure that, especially after the tab first killed your textcontent and then makes your field unselectable.</p>
<p>But hey when you apply the defaulTextformat wright before you start playing,<br />
suddenly the focussing and caret'ing works like a charm.<br />
Hope you are happy to find this post ! I would have been <img src='http://greencollective.nl/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
Here a little helper boyie class :</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="700" height="1150" id="ftf_wp" align="middle">
		  <param name="movie" value="/blog/wp-content/plugins/FlashTextFormatter/ftf_wp.swf" />
		  <param name="quality" value="high" />
		  <param name="scale" value="noscale" />
		  <param name="bgcolor" value="#ffffff" />
		  <param name="flashvars" value="w=700&h=1150&file=index.php&ftf=true&postID=16&no=0&def=/blog/wp-content/plugins/FlashTextFormatter/definitions/as2.xml&auto=true&" />
		  <embed src="/blog/wp-content/plugins/FlashTextFormatter/ftf_wp.swf" quality="high" scale="noscale" bgcolor="#ffffff" width="700" height="1150" name="ftf_wp" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="w=700&h=1150&file=index.php&ftf=true&postID=16&no=0&def=/blog/wp-content/plugins/FlashTextFormatter/definitions/as2.xml&auto=true&" />
		</object></p>
<p>use it like this after import CaretFocus;<br />
<code>CaretFocus.atBegin(TField)<br />
CaretFocus.atEnd(TField)<br />
CaretFocus.atIndex(TField,5)<br />
CaretFocus.unfocus(TField)<br />
CaretFocus.focus(TField)<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://greencollective.nl/blog/as3-caret-textfieldstagefocus-setselection-bugginess/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

