Thursday 28 April 2011

flex, air, How to write a file where the application is located


problem

adobe flex4 AS3.0, filestraem (air)
How to write a file where the application is located | the mystery "fileWriteResource" hidden error | how to write files in applicationDirectory (where is not allowed) [tested in windows only]
---
> page by dennis
solution

How to write a file where the application is located
in the follow example, the variable "filename" is String and has as value the the file name without path, i.e.: "sample.txt"
the follow code doesn't work, produces an error "fileWriteResource" that is not even thrown!
    var newFile:File=File.applicationDirectory.resolvePath(filename);
use the follow code:
    var newFile:File=File(File.getRootDirectories()[0]).resolvePath(File.applicationDirectory.nativePath+File.separator+filename);  //I am not kidding... it is working

Thursday 21 April 2011

flex error message: If the program is already running, close it before attempting to run.


problem
adobe flex4 AS3.0 air
Launching an air application from Flex 4 IDE, it crashes because of a bug, but the widow of the application is not created so…
Trying to launch the application again you get the error
If the program is already running, close it before attempting to run.
You cannot close the application… how to kill this invisible application?
---
> dn
solution
kill the process adl.exe

how to get the command line arguments of the flex air application


problem
adobe flex4 AS3.0 air
how to get the command line arguments of the air application
---
> dn
solution
You have to listen to invoke event of the air application.
Then, this event gives an InvokeEvent object.
This object has the arguments array, in this arrays are the command line arguments stored... see the follow Listener as example:
   protected function Handler_InvokeEvent(event:InvokeEvent):void
   {
    lb_test.text= event.arguments[0]+' '+ event.arguments[1];
    loadConfigFile();
   }
  

Saturday 16 April 2011

how to get locked photos from sites where have disable the right click copy paste ability


problem
firefox, how to get photos or general media from sites that are not allowed to be copied via right click copy paste method
solution
Firefox supports this feature: right click on the page on an empty area or press the "right click" button of you keyboard as you are not focusing any flash media in the loaded site. Then select View Page Info. Then select the tab media, there you can see all the media are download in you computer. So can save as anything you want. What you cannot see is the media that is handled from plugins like Flash player. For instance, you cannot download youtube videos by this way because this is media is downloaded or downloading by p2p connection and it is not stored in your pc as file.

Sunday 3 April 2011

Flex, how to round a number, how to convert a Number to Integer, a Number to Text

problem:
Working with numbers (with decimals) might be a nightmare, as a simple division may create a huge number of decimals. The problem is not the calculation but the storing this kind of data in sql databases and the calculation consume a lot of cpu. In case you develop an application that you want to work very fast the solution is to round the number after a division or multiplication.

solutions:

1. Convert a Number to String

toFixed property of Number

The following example shows how toFixed(3) returns a string that rounds to three decimal places.
var num:Number = 7.31343;
trace(num.toFixed(3)); // 7.313


The following example shows how toFixed(2) returns a string that adds trailing zeroes.
var num:Number = 4;
trace(num.toFixed(2)); // 4.00

2. Round a Number (number -> number, no conversion) 

Math.round(val:Number):Number 
The silly thing is that this function doesn't get argument for how many decimals to you want.
This round function rounds the 0.5 to 1.

3. Convert a Number to Int (rounding)
int(Math.round(0.665)) //  returns 1

4. Convert a String to Int
var myInt:int = parseInt(input.text);

5. Convert a String to Number
var myFloat:Number = parseFloat(input.text);

how to avoid the activation of your Adobe product

problem:
For some reasons you might want to do activate you Adobe product. If you want to do not allow the application to approach event the server(s) of Adobe, follow the bellow steps

difficulty: 5/10
 
solution:
the solution is simple, add the servers of the Adobe in the black list of your windows system, so every Adobe application will try get any kind of activation if info, it will fail as you windows system will block the request.
1. edit the file with notepad: C:\WINDOWS\system32\drivers\etc\hosts.  (it doesn't have extension)
2. disable your internet connection (from control panel -> network center / connections)

3. add the follow lines at the end of the file (if they don't exist)
127.0.0.1 localhost
127.0.0.1 activate.adobe.com
127.0.0.1 practivate.adobe.com
127.0.0.1 ereg.adobe.com
127.0.0.1 activate.wip3.adobe.com
127.0.0.1 wip3.adobe.com
127.0.0.1 3dns-3.adobe.com
127.0.0.1 3dns-2.adobe.com
127.0.0.1 adobe-dns.adobe.com
127.0.0.1 adobe-dns-2.adobe.com
127.0.0.1 adobe-dns-3.adobe.com
127.0.0.1 ereg.wip3.adobe.com
127.0.0.1 activate-sea.adobe.com
127.0.0.1 wwis-dubc1-vip60.adobe.com
127.0.0.1 activate-sjc0.adobe.com
127.0.0.1 adobe.activate.com
4. Enable your network connection
--- notes ---

note1: this bypass method doesn't activate any product... you must follow other ways to turn active your Adobe product!

note2: in any case we do not encourage you to crack or to make any illegal activities. Adobe is a great company with huge history that did fight a lot of times Microsoft and because of Adobe we enjoy many powerful things in our computers. This method is published for non commercial use of products or in case where the activation method is failing for some reasons.