Using Weborb Generated Code in Actionscript

January 19th, 2009

WebOrb has an excellent feature built in which allows you to generate Actionscript/Flex code from you deployed Java or .Net objects.  The example on their website shows you how to use this code in MXML but not in actionscript. However, it is quite simple. Here is an example function I have used below.

//Dashboard Settings

[Bindable]

private var swooshmodel:swooshModel = new swooshModel();

private var swooshProxy:swoosh;

private function LoadUserSettings () : void 

{ 

// Create a Responder for the call 

var responder:mx.rpc.Responder = new mx.rpc.Responder(OnUserSettings,onFault);

this.swooshProxy = new swoosh( swooshmodel ); 

swooshProxy.getUserSettings(responder); 

}

private function OnUserSettings (e:ResultEvent) : void 

{ }

Greg FLEX, WEBORB

PERL MYSQL DBD::mysql::st execute failed: PROCEDURE - can’t return a result set in the given context

August 31st, 2008

So I kept getting this error using DBD-mysql. DBD::mysql::st execute failed: PROCEDURE Data.getToday can’t return a result set in the given context at demo.pl line 15. The problem turned out to be that, I was using version 3.002 of the MySQL driver. I upgraded to 4.005 and all was good! Hope this helps you out…

Greg MySQL

Flex 3 AdvancedDatagrid cannot convert mx.managers::DragManagerImpl to mx.managers.IDragManager

August 5th, 2008

I was getting this error when clicking my AdvancedDatagrid. This only seemed to occur after converting the app to a module.

The answer to the problem was to add the following to your main application.
Hope this helps you spend a lot less time than I did resolving the problem :)

import mx.managers.IDragManager;
private var iDragManager:IDragManager;

Here is the exact error message:
TypeError: Error #1034: Type Coercion failed: cannot convert mx.managers::DragManagerImpl@2256be49 to mx.managers.IDragManager.
at mx.managers::DragManager$/get impl()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\managers\DragManager.as:152]
at mx.managers::DragManager$/get isDragging()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\managers\DragManager.as:187]
at mx.controls.listClasses::AdvancedListBase/dragScroll()[C:\Work\flex\dmv_automation\projects\datavisualisation\src\mx\controls\listClasses\AdvancedListBase.as:6617]
at Function/http://adobe.com/AS3/2006/builtin::apply()
at ()
at SetIntervalTimer/onTimer()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()

Greg FLEX , , , ,

FLEX 3 Catch Browser Exit or Close Event using Javascript and ExternalInterface

July 30th, 2008

Well after doing a bunch of searching and hacking away, I have managed to come up with a solution!

What I wanted was to set a variable when a change was made in my Flex application. (In my case it meant that a new module was loaded to my dashboard application) This way if a user loaded or deleted a module, the app would save their environment to a Shared Object.
Originally I had it was saving automatically, but user feedback said, only if I want to. This led me to prompting them when the close, but only if something has changed.

Here is how I did it:

First I declare a Bindable variable up at the top of my code (oh also import ExternalInterface)

import flash.external.ExternalInterface;
[Bindable] private var saveRequired:Boolean;

Second in my creationcomplete Event called init(), I add a callback to the ExternalInterface like so:

 private function init():void
		 {
          		if ( ExternalInterface.available ) {       			

          			ExternalInterface.addCallback("checkForUnsavedData",function():String {
          				if (saveRequired ) {
          					unsavedAlert();
          					return UNSAVED_DATA_WARNING;
          				}
						else return "";
					});
          		}
		 }

The following 2 functions are added to handle the Alert when the Javascript kicks off

private function unsavedAlert():void {
           Alert.show("Save?", "Save Alert", Alert.YES|Alert.NO ,this,SaveAlertHandler,null,Alert.YES);
          }

		private function SaveAlertHandler(e:CloseEvent):void {
		  	    if (e.detail == Alert.YES) {
		  	   		 setLSO();
		  	    }
		  	    saveRequired = new Boolean;
		  }

When you determine that a save is required set the variable saveRequired to anything. I wanted it to be a reminder when I went back to debug, so mine look like this…

saveRequired = "Popup on Browser Exit";

Finally….add this code between in your ./html-template/index.template.html

 <script language="JavaScript" type="text/javascript">
<!--
//alert(navigator.appName);
// Give user a chance to save modified data
window.onbeforeunload = function () {

	var warning = getFlexApp('SharedObjectBoard').checkForUnsavedData();
	if (warning != "")
		return warning;
	else
	return;
}

function getFlexApp(appName) {
  if (navigator.appName.indexOf ("Microsoft") !=-1) {
    return window[appName];
	alert(appName);
  }
  else {
    return document[appName];
	}
}
 -->
</script>

Greg FLEX

Archiving Perl PHP RUBY Scripts to Evernote using File Auto Import and Some Perl Scripting

July 25th, 2008
Archiving Perl PHP RUBY Scripts to Evernote using File Auto Import and Some Perl Scripting
Today Evernote released a new version which added the ability to drag and drop pictures or text files directly to evernote.
For a while I’ve been thinking about putting all my perl scripts in evernote, but was not in the mood to
1) Open each file
2) Copy the text
3) Paste It to Evernote
Thats also repetiteve and I don’t do Repetitive without Perl!
Evernote Offers a nice little feature File Auto Import which can be found in the menus under
Account > Properties.
The problem is, It will not import .pl file or .cgi or .php for that matter. Only .txt and images, and maybe a few others but
definitely not .pl
So, I wrote a perl script that goes through my perl script parent directory.
NOTE:(I store all my scripts for the most part in one dir, and create sub directories under it. So It was quite easy for me.)
And then makes a copy of the file in the Evernote AutoImport directory with a nice Title and the .txt extension.
##This is the path to your Evernote Import Directory
$outdir = "C:\\temp\\EvernoteScripts";
# look in current directory
$dir = `pwd`;
chop($dir);
my @files = `find | grep ".pl" | grep -v ".swp" | grep -v ".doc"`;
 
 
foreach my $f (@files) {
	chop($f);
	$filenameOnly = `basename $f`;
	$directoryOnly = `dirname $f`;
	$newfile = substr($filenameOnly,0,index($filenameOnly,"."));
	print "$filenameOnly\n";
	$text = "\# Script : $filenameOnly\n"; ### Creates a title for the script which will be seen in Evernote!
	$text = $text . `cat $f`;
	$nf = "$outdir\\$newfile\.txt";
 
	open FILE, ">", $nf or die $!;
	print FILE "$text";	
	close FILE;
	sleep 2; ###Evernote basically exploded when it tried to read from the directory without a slight delay.	
}

Greg Perl

Jury Duty Phone Scam

July 23rd, 2008

All, I just recieved an email which circulated from a senior VP at my company. Here is the exact email.

DO NOT DELETE WITHOUT READING!

Jury Duty Scam

This has been verified by the FBI (their link is also included below). Please pass this on to everyone in your email address book. It is spreading fast so be prepared should you get this call. Most of us take those summonses for jury duty seriously, but enough people skip out on their civic duty, that a new and ominous kind of fraud has surfaced.

The caller claims to be a jury coordinator. If you protest that you never received a summons for jury duty, the scammer asks you for your Social Security number and date of birth so he or she can verify the information and cancel the arrest warrant. Give out any of this information and bingo; your identity was just stolen.

The fraud has been reported so far in 11 states, including Oklahoma, Illinois, and C olorado. This (swindle) is particularly insidious because they use intimidation over the phone to try to bully people into giving information by pretending they are with the court system. The FBI and the federal court system have issued nationwide alerts on their web sites, warning consumers about the fraud.

Check it out here: <http://www.fbi.gov/page2/june06/jury_scams060206.htm>

And here:  <http://www.snopes.com/crime/fraud/juryduty.asp><http://www.snopes.com/crime/fraud/juryduty.asp>

 

Greg Uncategorized

Smoked Pepper Halibut

July 19th, 2008

 

Smoked Pepper Halibut

Smoked Pepper Halibut
Rated  by 3 people
Rate This   
100s of main-dish recipes plus suggestions for simple go-with dishes to make a meal complete.
 
4 servings
Prep: 15 minutes
Marinate: 30 minutes
Grill: 8 minutes
 

Ingredients

Directions

Thaw fish, if frozen. Rinse fish; pat dry with paper towels. If necessary, cut fish into 4 serving-size pieces. For marinade, in a blender container combine chipotle peppers, adobo sauce, sweet pepper, lime juice, oregano, and garlic. Cover and blend until pureed. Transfer half of the marinade to a shallow dish; set aside remaining marinade.

Add fish steaks to dish, spooning some of the marinade over fish. Cover and marinate at room temperature for 30 minutes.

Drain fish, discarding marinade. Sprinkle fish with salt. Grill fish on the greased rack of an uncovered grill directly over medium coals for 8 to 12 minutes or until fish flakes easily when tested with a fork, turning once halfway through grilling. Heat reserved marinade and serve as sauce with fish. Makes 4 servings.

 

Greg Uncategorized

How Do I import and iCal .ics file into Outlook

July 18th, 2008
In outlook….Go To
File > Import and Export
 
 
Choose Import and iCalendar or vCalendar file (.vcs)
 
 
 
Now Browse to your .ics file and Click OK!
 

Greg How-To

How Do I Import a CSV File into Outlook Caledar

July 17th, 2008

 

Import CSV Caledar into Outlook
 
For this example I am using Outook 2003. You can get your version by going to the outlook menu
Help > About
 
However it should not matter.
 
 
Go to File > Import and Export
 
 
You will get a menu that looks like this. Choose “Import from another program or file”
 
 
choose Comma Seperated Value (Windows)
 
 
 
Now Browse to your download schedule and Click Next!
 
 
 
Choose Calendar
 
 
Click Finish!
 

Greg How-To

Test of SyntaxHylighter

July 17th, 2008
#!c:\\perl\\bin
#use strict;
use WWW::Mechanize;
use HTTP::Cookies;
use HTML::TableExtract;
use Net::Whois::IP qw(whoisip_query);
use chilkat;
our $count = 0;
my %Whitelist =
(
'67.228.182.163' =&amp;amp;amp;amp;gt; 'Xoopit',
'ip.ip.ip.ip' =&amp;amp;amp;amp;gt; 'Work'
&amp;amp;lt;code&amp;amp;gt;);

Greg Uncategorized