Monthly Archives: September 2012

Flex & Javascript : Why that won’t work?

Some tricks to keep in mind while trying to make a Flex application and Javascript communicate between them. Tutorials are available in the official documentation here and here. But you may be in a hurry, and omit some details that may prevent you from achieving what you want. So, either RTFM pretty slowly, or check those features:

That's you'll always get whenyou are in hurry!

  • ExternalInterface.available

You have to  check whether the browser supports the interface by using its available property:

if(ExternalInterface.available)
{
  //make calls
}
  • Check Browser constraints

The ExternalInterface class requires the user’s web browser to support either ActiveX or the NPRuntime API that is exposed by some browsers for plug-in scripting.

  • Check Embedded SWF ID

Your SWF object is included in the HTML page using the Object tag.

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
<strong>id="logon"</strong> width="100%" height="100%" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">

The id and the name mustn’t  contain those characters :   [.-+*/\].  The sample application here is called “logon”.

  • Referencing your SWF Object

Not all browsers reference the swf object in the same way, some you may add a JS function to avoid this browser incompatibility issue:


<script language="javascript">

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

</script>

Be sure to make the correct reference to you application, because:


getFlexApp(logon);

won’t work. You forgot the double quotes :p


getFlexApp("logon");

That’s the correct way.

  • Make your Flex methods accessible

Inside the Object tag, in the swf object, change the


allowScriptAccess="sameDomain"

to


allowScriptAccess="always"

And in the Flex side, add a callback to your method to be added to the externalInetrface dictionary.


if(ExternalInterface.available){

//callFlexMethod is the AS function you want to call from JS

ExternalInterface.addCallback('YouWillCallTheMethodFromJSByThisName',callFlexMethod);

}

Allow security domain using Security.allowDomain(‘your js domain’) and make concerned functions public accessible via a wrapper function:


public function callFlexMethod():void{
Security.allowDomain('*');
if(ExternalInterface.available){
var wrapperFunction:String = "myPrivateMethod";
ExternalInterface.call(wrapperFunction);
}
 }

private function myPrivateMethod():void{
//some code here
}

Got it?… Good for you 😉

Get my blog content back!

It seems that data devil is playing around my lap-top. After my disk crash, my WordPress blog was suspended suddenly, with no previous alert! All I saw is

seuforia.wordpress.com is no longer available.
this blog has been archived or suspended for violation of our Terms of Services.
For questions or concerns, contact WordPress.com Support.

Furthermore, my account was suspended too and I can’t login to my dashboard. So I started reading the annoying terms of services. I thought that happened because of photos in my blog; I admit that I have some pictures taken from the net. Then, I read the Suspended blogs support page, and I was about to let down the whole thing thinking that all my posts were lost, because wordpress support, says

If  a blog has been suspended for violating our terms, its domain/URL and content will not be returned.

I don’t know why when I read this line, I heard Mario’s Game Over sound in my head 😀

All I could do is just send a message throught that contact form to wordpress support bagging them to send me back my content. Hopefully they answered me in about three business days saying

Blog Suspended by error

WordPress Support Answer

Ouch! Hopefully it was just a mistake. Once I’ve got my access back, I exported the whole content as an XML file (free export version). I think it’s time for me to install a backup solution on my lap.

Rescue your damaged hard drive for free

Last week, windows XP started throwing some disk errors and some blue screens on my data drive which is a 200GB NTFS partition from a 500GB toshiba hard drive. I thought that by executing CHKDSK and recovering damaged blocks this error will go away. So it took about 72 hours (yeah that’s correct… seventy two hours) for disk verification, but no error was reported.
I started a disk defragmentation. Meanwhile , a windows blu screen occured! I restarted the computer and the Data drive was empty. Hopefully, I did a backup before.

I googled for existing solutions “damaged hard drive rescue”, and I found some commercial solutions. I tried Stellar Phoenix but something went wrong with it after disk analysis (which was correct and I was able to see my files but it took about 12 hours for 178GB). So I let down.

I also tried the SysDev product, but demo version allows you only to recover 64kb. Somehow, “the godmother” told me about a product based on Sysdev work: R.saver. This russion product from R.Lab worked like charm, but you should know some russian to use it or just tweak 😀 . Analyse process took about 2 hours and file recognition about 3 hours for 200GB.

Damaged HD rescue

R.Lab

The process analyzes all clusters on your disk and recreates the entry point for every found file using IntelliRaw technic; Fetched files are classified by type then under IntelliRaw tree item. You can even search files if you can’t find them directly where you used to find them when your disk was safe; Those files are arranged under [Parent Unknown] directory…

 

Here is the product description in English (google translate from Russian):

Free software for recovering data from healthy drives.Has a simple and convenient interface. Produces restoring data from different versions of the corrupted file systems NTFS, FAT, and exFAT, recover deleted files and data from formatted. R.saver under Windows also allows access in read the sections with file systems: HFS, HFS +, HFSX, Ext2 , Ext3, Ext4, ReiserFS, JFS, XFS, UFS, UFS2, NWFS, ISO9660 and UDF.