Monthly Archives: November 2005

Flex – The Wizard behind the Curtain


Flex MXML is translated into an ActionScript Class before it is compiled into SWF. The easiest way to learn the deeper side of Flex is to modify your installation to keep generated actionscript. You will learn more about Flex than you ever wanted to know.

I learn by doing and this feature of Flex has allowed me to learn the deeper side of Flex. It allows you to see how Flex application internals work and allows you to explore the deeper APIs within the Flex Framework. Lets face it, it is one thing to write MXML, but quite another to bend Flex to work they way you want.

Exploring Flex 101 – How to turn on “keep-generated-as”:

1. Locate this file:
{FLEX INSTALL}/WEB-INF/flex/flex-config.xml

2. Locate the XML tag “keep-generated-as” and modify the value to ‘true’

3. Restart Flex

Now whenever an MXML application is compiled, the generated AS file will remain on the file system like so:

MyApp.mxml
MyApp-generated.as

Open the generated AS file and be prepared for a jolt of development reality. It is so nice to locate “The wizard behind the curtain”.

Cheers,

Ted ;)

Using Flash Player under HTTPS with Flex and Flash


I have been recently working with the core team at Cynergy Systems on debugging an HTTPS file upload solution for Flex 1.5. It seems that the Flash Player has a port identity crisis when run under HTTPS leading to all sorts of errors. Here is the solution…

It seems that the security model of the Flash Player is very fine grained on a port level. When running a SWF file under HTTPS, the player can get confused about what port is actually in use. In a sense the sandbox of the HTTPS SWF file is not associated with the actual port that loaded the SWF and thus data access is problematic. The player has sort of an identity crisis internally and it cannot communicate with the domain/port that the SWF files was served from. The solution is to explicitly load a Cross-Domain Security Policy File when the SWF is loaded to correct the problem. The following code will fix the problem when running under HTTPS on port 443:

System.security.loadPolicyFile(‘https://flexdemos.cynergysystems.com/support/crossdomain.xml‘);

Note:

– View the contents of the crossdomain.xml file above denoting port 443’s use.
– The policyfile is not loaded by defualt and must use loadPolicyFile in this case.

I have worked with Cynergy on 2 projects using HTTPS/Flex/WebServices and have used HTTPS with several other clients. All have reported strange data related errors in using HTTPS of a similar nature. Considering this solved the File Upload issue, I believe that it should be standard policy to load a policy file when using HTTPS. As this is a backward compatible solution as it does not require a player update as loadPolicyFile is supported in Flash Player 7 and higher.

If you have found strange behavior in working with Flash Player and HTTPS, use loadPolicyFile and kiss your issues goodbye.

Special thanks the Carson Hager, Jason Weiss, and Dave Wolf for debugging this important and business critical issue. It really is an honor working with such a fantastic team at Cynergy. The Cynergy core team is a group of industry leading developers from the core team who created Sybase PowerBuilder & EAP Server, and Microsoft BizTalk Server. They have been making rich applications long before the birth of the Flash Player and long before I started programming. I cannot wait to show the community the projects we are working on at Cynergy, the work is truly impressive.

HTTPS, Check!
FLEX, Check!
LoadPolicyFile, Check!
All systems a go, we are cleared for launch!

Cheers,

Ted ;)

Macromedia please add flash.util.Synchronous Class into AS3


This is a feature request for Flash Player 8.5 in support of a new Class for handling synchronous behavior. Adding synchronous behavior into all Flash Player classes would be a massive undertaking but allowing a single function to execute in a structured manner would not. Let me explain.

First let’s define Synchronous within Flash Player to make sure we are all on the same page. I view Synchronous behavior in Flash as:

1. A Synchronous process is started
2. The Flash Player executes the process over and over until the process returns
3. The Player does not error or timeout or complain
4. When the process returns, AS execution starts from the exact point where it left off.

Here is some example Synchronous code examples:

// retrieve data from a URL and set it as a DataProvider property.
dataGrid.dataProvider = getData( url )

or

if( uploadFile( url ) ){
   \\file was browsed, selected, and uploaded to the url successfully
}else{
   \\an error occured
}

The key to making this work is providing a class within which a function can be executed over and over without causing the player to:

1. Reach the Script Timeout Limit
2. Reach the Recursion Limit

If Flash Player 8.5 provided a Class under which the above 2 rules were valid, we could execute a function over and over to provide Synchronous behavior. Here is an example that counts to 10,000,000 within function run Synchronously:

function timeTo10Million( ){

   import flash.util.Synchronous

   // define a function to be executed over and over
   // a single object argument is passed
   // with every execution to save data between calls
   var synchFunction = function( sdo:Object ){

      //if i is undefined, define it.
      if( sdo.i == undefined ) sdo.i=0

      //if startTime is undefined, define it.
      if( sdo.startTime == undefined ) sdo.startTime = flash.util.getTimer()

      //add 1 to i
      sdo.i++

      // if we have reached 10 Million return
      if( sdo.i >= 10000000 ){

         //return ms to count to 10 million
         //this will end execution of Synchronous.execute!!!
         return flash.util.getTimer() – sdo.startTime

      }

      //every million iterations, force an update to the DisplayList
      if( sdo.i % 1000000 == 0 ) Synchronous.updateAfterEvent()

   }

   //call Synchronous.execute with synchFunction and a new Object
   return Synchronous.execute( synchFunction , {} )

}

trace( timeTo10Million() ) // 55

When a function is executed under Synchronous.execute, the rules for AS execution change within the Flash Player. The player will execute the function over and over and if data is returned at any point, execution returns to the exact spot where Synchronous.execute was started. Synchronous.execute calls the passed function over and over, and passes a common object as a argument for storing data between executions. This allows you to avoid creating lots of temporary variables and allows other AS to execute during Synchronous execution. Within this function, you could fetch data remotely, listen for Socket AMF data to return, or just sit and wait for 100 ms without using events. Obviously use of Synchronous.execute is an advanced feature but it provides an opportunity to create lots of simplified tools very easily. I can think of lots of uses to simplify software development with Flash/Flex and I am sure you can think of allot more too.

The advantages here is that we can use AS3 language to extend the player synchronously without allot of muss or fuss. Thread management, specialized events, or advanced concepts of parallel execution are not needed. Also as a bonus, because Synchronous is a class, it is already ECMA compliant.

If you would like to see Synchronous behavior in Flash Player 8.5, say something!!! There is very little development time left as Flash Player 8.5 moves toward feature completion. I think this addition would revolutionize the use of Flash/Flex and simplify lots of concepts that make no sense to developers coming from other languages. It is about time we had an alternative to “waiting yet another frame”.

Comments encouraged!

Cheers,

Ted :)

A New Chapter – Working at Cynergy Systems


Things change quickly don’t they? Created in 2001, PowerSDK has serviced 35 separate clients ranging from Macromedia to Pepsi, all wanting to leverage the Flash Platform. It is with great pleasure that I begin a new chapter with Cynergy Systems.

The change to Cynergy Systems is about returning to software development. I write software, I love writing software, and I want to spend my time writing software. As PowerSDK grew, I found myself pulled away from software development and much of my time was spent running the business. When we would reach development capacity, PowerSDK would simply turn away new clients requesting development work.

The switch to Cynergy Systems changes this pattern dramatically as I will be focused on Flex development with Cynergy’s enterprise clients. I will be returning to development with an amazing team who is capable of delivering projects of any size and scale. With 6 offices in 5 continents, Cynergy Systems is a impressive company moving towards the Flash Platform. They are experience heavy in terms of enterprise development but are positioned to be the leader in Macromedia Flex consulting.

IFBIN also stands to benefit dramatically by this change. Cynergy wants IFBIN to succeed and they have provided me ample time to invest in its growth. What is great is that actual time spent on IFBIN will double as a result. By eliminating many time consuming tasks in PowerSDK, I am able to focus again on example development and pushing IFBIN forward as a company.

Just so we are clear, PowerSDK Software Corp. and IFBIN Networks Corp. are separate companies. Cynergy Systems acquired PowerSDK Software Corp.. The purchase does not affect IFBIN or its products.

If you are in need of Flex development, talk to Cynergy Systems.

Cheers,

Ted ;)

Cynergy Systems Acquires PowerSDK Software Corp.


Furthering its position as the leader in Rich Internet Application solutions, Cynergy Systems makes strategic acquisition of established industry leading Macromedia FlexTM consulting company.

Cynergy Systems Press Release

November 1, 2005, Washington D.C. – Cynergy Systems announced today it has reached an agreement to acquire PowerSDK Software Corp. Focused exclusively in the delivery of Rich Internet Applications (RIA) using the Macromedia suite of products including Macromedia Flex™, PowerSDK brings proven expertise, an extensive customer base, and a reputation for excellence. With this acquisition, Cynergy Systems, a Macromedia Flex Alliance Partner, furthers its position as the worldwide leader in RIA solutions.

“Cynergy Systems is defining the use of Macromedia FlexTM within the enterprise.” said Theodore Patrick, PowerSDK Founder. “In working with Cynergy earlier this year, I was impressed by the technical capability and the quality of the people at Cynergy. The combined resources of PowerSDK and Cynergy Systems will define the next generation of Macromedia FlexTM solutions for our customers.”

The definitive agreement, the complete terms were not disclosed, will seamlessly incorporate PowerSDK’s staff and facilities under the Cynergy Systems RIA practice.

“We have had phenomenal growth in our RIA practice over the last 18 months thanks to proven, demonstrable successes with the Macromedia FlexTM platform,” said Dave Wolf, Vice President of Consulting for Cynergy Systems. “PowerSDK’s expertise and reputation for excellence will bolster that business even more as we continue grow over in the future.”

About Cynergy Systems
Cynergy Systems delivers Web, RIA and Legacy Migration solutions to over 1,400 customers worldwide. Maintaining offices across three continents and leveraging over a decade of experience, Cynergy Systems focuses on the delivery of rich, powerful business applications to customers across dozens of verticals including Healthcare, Manufacturing, Banking, and Governmental Organizations. Partners include Macromedia Inc., Microsoft Inc., Sybase Inc., Percussion Software and Jive Software.

For more information contact sales@cynergysystems.com

For press inquiries contact publicrelations@cynergysystems.com

http://www.cynergysystems.com