Instantiation attempted of a non-constructor

October 28th, 2010 by admin » (0) » AS3

Something that might help you save some precious time of your life.
If you get this error with (perhaps) a class you’ve coded, try this:

Don’t give the variable the same name as the class you want to instantiate…

var MyClass = MyClass();

is bad.

var varName = MyClass();

will probably work.

Flattr is here

Today I joined Flattr.com

It’s a social micropayment system from one of the former Pirate Bay guys from Sweden. I think it is a great idea and I hope a lot of technic blogs will implement it, because sometimes I would like to thank someone for his/her help with more than just a »Thank-You«-comment (but with less than buying something from his Amazon wishlist).

I probably implement it here, we’ll see!

Here is a little video that explains the way Flattr works:

iPhone-Link

Pitfalls with mailto-Links in Flash

October 20th, 2009 by max » (3) » AS3

In my last project I had some issues with IE8 (at customer-side), Mail (on agency-side) and my way of placing mailto-links.

In this project, the email-address and the subject come from a XML. This was my first setup:

XML-Node

<node contactAddress="support@acme.com" contactSubject="Kontakt über Homepage">

(Please notice: the german »Umlaut« in the subject)

AS3 (excerpt)

private function mailto(e:MouseEvent):void {
var mailaddress:String=XML.node.attribute("contactAddress");
var mailsubject:String=XML.node.attribute("contactSubject");
navigateToURL( new URLRequest( "mailto:"+mailaddress+"?subject="+mailsubject));
}

So, let’s see, what happened with different clients on different OS:

IE7, IE6, FF, Safari on WinXP worked without any problems (with Outlook Express). IE8 on WinXP opens a new Window with an error message (»Navigation wurde abgebrochen« / »Navigation to the webpage was canceled«), but opens Outlook (Express and Outlook 2007) with correct recipient and correct subject.
Every browser on Mac opens up Mail, but didn’t open a new eMail with recipient or subject.

To cut a long debugging-story short: please no german umlauts in mailsubject, so changing the XML-node the following mail, solved the problem:

<node contactAddress="support@acme.com" contactSubject="Kontakt per Homepage">

Nice, but still IE8 opens up a ugly window with the cancelation message. The solution here was the target-attribute of the navigateToUrl-Method: default is “_blank”, which I thought was the correct way to handle it, because I didn’t want the page to unload, if the mailto-Link was clicked. Turned out, that when you use the code in following way, the page doesn’t unload and new tabs/windows are surpressed.

private function mailto(e:MouseEvent):void {
var mailaddress:String=XML.node.attribute("contactAddress");
var mailsubject:String=XML.node.attribute("contactSubject");
navigateToURL( new URLRequest( "mailto:"+mailaddress+"?subject="+mailsubject), "_self");
}

Conclusion: don’t use Umlauts (and probably no other special characters) with OS X, don’t use “_blank” or default.