Showing posts with label flex. Show all posts
Showing posts with label flex. Show all posts

Wednesday, May 6, 2009

Macintosh and FileReference Type in Flex

In Mac, the Type attribute of the filereference object returns null by default and this is a huge problem, considering that the type attribute works by default for the PC.


private function getMacExtension(myExtension:String,myName:String):String {
if (myExtension == null) {
if (myName.lastIndexOf(".") > 0) {
myExtension = myName.substr(myName.lastIndexOf("."), myName.length);
myExtension = myExtension.toLowerCase();
}
}
return myExtension;
}

Wednesday, April 1, 2009

Accurately Position Drag and Drop Item

Anyone who played with Flex' drag and drop function (for canvas) will know that the drag and drop function will cause the image to be incorrectly placed on a canvas. That is, the background transparent image will appear on this particular position (when you hold down your mouse button) but when you release your mouse, the image appears in another position that is not accurately where you dropped it.

This is due to the fact that the image (when you clicked) had a pointer that was not at coordinates zero, zero. When we click the image and drag, it was most likely at a portion of the image, and when we drag it around the canvas, the 'transparent rectangular background of the image' made it appear as if we are dropping the image at that particular rectangular position.

You can see the codes to do drag and drop for canvas at:
http://livedocs.adobe.com/flex/3/html/help.html?content=dragdrop_7.html

In order to overcome this problem, at line dragInitiator, i added the following lines:
ds.addData(event.localX, "NumberX");
ds.addData(event.localY, "NumberY");

Then at the line of dragDropHandler, I placed the following:
Image(event.dragInitiator).x =
Canvas(event.currentTarget).mouseX- parseInt("" + event.dragSource.dataForFormat("NumberX"));
Image(event.dragInitiator).y =
Canvas(event.currentTarget).mouseY- parseInt("" + event.dragSource.dataForFormat("NumberY"));

Viola! Your image should appear wherever you drop them now.

Friday, February 6, 2009

Unable to view Flex program in Firefox and Safari

If you have a Flex program, but you are unable to run it successfully in Firefox and Safari but you can run it inside internet explorer, then chances are you are having some problems with the javascript component that loads the flex program.

It may not be a flex program error, look in the javascript first.

Saturday, November 15, 2008

Firefox Flex Error

In Flex, when you build files normally, you have to take note of the folder you copied your files from. If you are running into errors about debuggers in firefox, that means you copied the wrong files to the server you are running your program from. You should have copied files from the bin-release folder and not the bin-debug folder.

To build files into your bin-release folder you have to choose the "Build Release" option inside Flex. This will essentailyl ask Flex to build a release for real usage and not for debugging purposes.

Flex's Error #2048: Security sandbox violation

I was running the flex application within the C:\ path while it was trying to access documents using web services from http://localhost:4076. It immediately threw an error. After much googling I found that the main reason is Flex do not allow a program to access information from outside the domain it was called from.

To get around this problem, you have three choices:
  1. Add a crossdomain.xml file to the server with the data.
  2. Upload your SWF file to the same server as the data service.
  3. Create a proxy on your server that calls the data service, and put your SWF file on the same server as the proxy.

The simplest method is to create a crossdomain.xml file. The instructions are:

A crossdomain.xml file is an XML file that provides a way for a server to indicate that its data and documents are available to SWF files served from certain domains, or from all domains. The crossdomain.xml file must be in the web root of the server that the Flex application is contacting. For more information about configuring crossdomain.xml files, see the technote on the Macromedia website: http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_14213.