Archive

Archive for the ‘flex’ Category

Cannot pass JSON string as String to ExternalInterface.call. It gets converted to an object

January 26th, 2010 markledford No comments

Note to self. This scenario isn’t mentioned here: http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00000343.html

Categories: flex Tags:

cannot call ANY methods of XML or XMLList instances via bracket notation

January 18th, 2010 markledford No comments

Every single method, unique to XML and XMLList or inherited will be return as an empty XMLList instead of the intended method as a Function when its retrieved as a property of that instance. Note that this not calling XMLList methods but retrieving the actual methods as properties of the objects themselves.

For example:
myXML.contains is XMLList //true
myXML.toString is XMLList //true

This makes it impossible to call a method of an XML or XMLList programmatically via bracket notation like:
myXML['toXMLString']() //returns TypeError: Error #1006: value is not a function.

It feels like a Proxy is involved internally and these methods were not set to returning properly in getProperty. Anyone have any feedback or work arounds?

Categories: flex Tags:

major Flash Player GC bug converting string to XML

December 20th, 2009 markledford 2 comments

When converting a string to XML the memory used by the XML will never free up no matter the references or garbage collection tricks you have up your sleeve.  This is really excruciating when needing to parse large XML files from a Flex or AIR app.

http://bugs.adobe.com/jira/browse/SDK-11982

http://bugs.adobe.com/jira/browse/SDK-11244

http://bugs.adobe.com/jira/browse/FP-599 <- Looks like this issue has been open for well over a year and may be fixed for the next release of Flash Player (apparently not 10.0.42.34 released a few days ago, just checked, perhaps they mean the next full release :/)

UPDATE: Luca in the comments pointed me to an apparent fix they’ve added to AIR 1.5.2 via System.disposeXML(xml) found in the release notes here.

I’ve verified that this new method works like a charm. It seams like a bit of a strange one-off hack that they’ve put it in under System for AIR only but I’m guessing that they wanted to address it quickly for the SDK that needed it most. Hopefully the regular Flash Player fix is coming in the next major update and won’t require this unusual method.

Categories: actionscript, bugs, flex Tags:

Using [Embed] with fonts in Flex / Flash Builder Actionscript projects includes SDK specific core Flex classes

September 3rd, 2009 markledford 1 comment

Have you gotten this error when upgrading a Flex project to Flex 4?

1044: Interface method allowDomain in namespace mx.core:IFlexModuleFactory not implemented by class _Main_mx_managers_SystemManager.
1044: Interface method get preloadedRSLs in namespace mx.core:IFlexModuleFactory not implemented by class _Main_mx_managers_SystemManager.

Looking at the error its clear that Flex 3.4’s IFlexModuleFactory got compiled in and referenced by Flex 4’s SystemManager (which no longer has these methods) but how?

If you’re in my boat you have a central Actionscript-only Flex Library Project repository where you keep all your reusable Actionscript classes. This project is compiled with an older Flex SDK (3.4 in this instance) as it targets Flash Player 9 and other Flash 9 / Actionscript Only projects reference it. Your library  may also includes metatags even though the compiler adds some basic mx.core classes to do the embedding. This normally wouldn’t be an issue but you’ll find your boat will capsize if you’ve included any fonts embedded this way as the compiler includes some SDK specific classes, namely IFlexModuleFactory via FontAsset. You can verify this by including “-link-report linkreport.xml” compiler argument to this project.

Solution: Export the fonts separately, perhaps in a separate swc that isn’t referenced directly in your updated Flex 4 projects.

Categories: flex Tags:

flash player 10 security change can break focus logic with cross domain swfs

August 28th, 2009 markledford 1 comment

With the barrage of player updates and security changes to the Flash Player staying on top of the issues and incompatibilities from player to player is sometimes as troublesome as cross browser compatibility for regular web development. This is especially true for the upgrade from Flash Player 9 to 10.

There were some well publicized major security changes for policy files and the filereference class included with the Flash Player 10 security updates but a seemingly less significant new restriction regarding cross domain swf focus can wreak havoc on an existing flash project . The new restriction is outlined here:
Related-object properties in events may not be available

Starting in Flash Player 10.0.2, if an object that would be referred to by any of these properties [MouseEvent.relatedObject, FocusEvent.relatedObject, ContextMenuEVent.mouseTarget] resides in a different security sandbox (for example, because it is part of a different SWF that was served from a different domain), and the two sandboxes do not both trust each other (by means of the Security.allowDomain method), then the value of this property is changed to null.

I’ve found this is a significant change for cross domain swfs that utilize any of Flash’s V3 Components. Some 3rd party crossdomain swfs that once worked fine will no longer focus properly when clicking on textfields. Digging into this component architecture’s FocusManger you can find the culprit:

fl.managers.FocusManager::mouseFocusChangeHandler(event:FocusEvent)

/**
*  @private
*  This gets called when mouse clicks on a focusable object.
*  We block Flash Player behavior.
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/

private function mouseFocusChangeHandler(event:FocusEvent):void {
   if (event.relatedObject is TextField) { //<- related object will always be null
      return; // pass it on
   }
   event.preventDefault();
}

The solution is to add a Security.allowDomain(“YourDomain”) if you have access to republish, otherwise you’d have to use a proxy server.

Categories: flex Tags: ,

swfObject javascript error in Internet Explorer

April 15th, 2009 markledford 3 comments

We’ve had this IE error reported 3 times this week:

Line: 130
Character: 4
Code: 0
Error Message: ’script.parentNode’ is null or not an object

The issue:
The SWFObject library is included multiple times on a page causing the IE DOM ready check hack it uses internally to be triggered multiple times. This hack inserts and removes a test node. Since the first instance removes this node, additional tries cause the error.

Solution:
Remove multiple imports of <script src=”swfobject.js” type=”text/javascript”></script> from your page.

Categories: flex Tags:

embed parameter “menu” = false and ContextMenuEvent.MENU_SELECT

March 11th, 2009 markledford No comments

In the Adobe LiveDocs it states:

  • menu- Possible values: true, false.
    • true: isplays the full menu, allowing the user a variety of options to enhance or control playback.
    • false: displays a menu that contains only the Settings option and the About Flash option.

Naturally not wanting the clutter in my context menus I had menu set to false in its embed code. Today I noticed new Context Menu support I had added to my app was not showing up in Flash 9 Player though it was appearing in Flash 10. Apparently setting this option to false will also keep the ContextMenuEvent.MENU_SELECT option from being dispatched in Flash Player 9 :-x

Categories: flex Tags:

AS3 htmlDecode htmlEncode xml hack

February 25th, 2009 markledford 3 comments

You’d think there would be a straight forward way to htmlEncode and htmlDecode strings in flash but there doesn’t seam to be any sort of built-in utility class that supports this. Oddly enough there isn’t one in Javascript either. Like this Javascript hack, here is a handy hack to pimp AS3’s native XML object instance to do the htmlEncoding/decoding for you.

Unfortunately this doesn’t work for  many encoded characters like “&iacute;”, “&oacute;”,  “&aacute;”, and “&ntilde;”. It seams the best route to robust html html encoding/decoding is to roll your own utility function like this.

Categories: flex Tags:

Multipart form data in flash

February 20th, 2009 markledford No comments

Eugene has a handy MultipartURLLoader class to do the leg work of sending multipart form data from flash.

Note that because it uses:
urlRequest.requestHeaders.push( new URLRequestHeader( ‘Cache-Control’, ‘no-cache’ ) );

You may get SecurityError:
Error #2044: Unhandled securityError:. text=Error #2170: Security sandbox violation: http://domain1.com/your.swf cannot send HTTP headers to http://domain2.com/yourscript.php.

You may need to add a variation of <allow-http-request-headers-from domain=”*” headers=”*”/>  to your crossdomain.xml file or comment out that line. I chose the latter as I don’t think its neccessary in a POST call.

Categories: flex Tags:

javascript injection in AS3

January 20th, 2009 markledford No comments

Pretty useful method of storing Javascript inside of a swf for use with ExternalInterface. The novel part is maintaining the formatted Javascript inside of an xml object, check it out here. Thanks to Derek for the link.

Categories: flex Tags: