Apple removes Flash CS5 export restrictions, should I stop learning Objective-C?

UPDATE: It’s been over a year since I considered stopping my study of Objective-C and I can gladly say that I made the right choice in continuing to learn Objective-C and native app development. With Adobe’s recent moves discontinuing Mobile and TV Flash development and moving the Flex SDK to ‘an established open source foundation’ it is clear they are no longer interested in investing in the technology and I’m glad I started expanding now instead of waiting for tomorrow. This is one of those rare times in life I’ll get to look back and pat say that I actually made a great choice for my future.

I’ve been a Flash developer for many years now. I was excited about the opportunity to create native apps for the iOS environment when it was first announced but life was too hecktic at the time to start learning Objective-C. A little while later Adobe sources announced that the next version of the Flash IDE, CS5, would be able to export compiled iOS apps! I was thrilled to hear that I could put all my existing ActionScript knowledge into instant use on the iOS devices and I decided again to work on my other projects and learning C# and wait for Adobe to release CS5. Then the 3.3.1 change happened at the same time that Flash CS5 was release, Apple doesn’t want Adobe’s knock off Objective-C apps ported from Flash. I’m at a complete loss, I waited for the dust to settle and it seemed Apple was completely resolved to keep Adobe out of it’s devices.

It was time to learn Objective-C if I was ever going to get into iOS development. I hit the books and started learning all the fun stuff about C and all the strange things I was going to have to work around that I had gotten used to having in ActionScript 3.

Today Apple makes a new statement back tracking on the 3.3.1 sections of the developer license (http://www.apple.com/pr/library/2010/09/09statement.html) and now Flash CS5 compiled apps are allowed again!

Wait what? I thought Apple was this stone pillar of decision, Steve Jobs even had a post Thoughts on Flash ripping it apart and now it’s OK to put Flash apps on their devices essentially? I’m more than a little frustrated by this. On one hand I’ve started to develop a new skill set in developing mobile applications for the iOS devices and on the other I have a long history of ActionScript knowledge I could use to make iOS apps even faster.

I’m already 70% done with my first iOS app since starting out and now I wonder if I even need to continue to nurture my Objective-C learning because I can just recompile my Flash games and push them right to the store.

I was so mad when Apple first made the decision to reject Flash apps, then I accepted it and started learning Objective-C, now I think I’m kind of upset that they backtracked such a short time but still long enough for me to get neck deep in Objective-C books.

I think I have to finish this first game in Objective-C but after that is it worth the work to continue learning that language now that any language can be compiled down to Objective-C and then approved?

Flash cannot parse this document – Adobe Flash CS5

I found a fix for a single case of “Flash cannot parse this document” error when opening a file saved from Adobe Flash CS5. Here is how it happened.

A designer friend of mine upgraded to CS5 recently and sent me an email in a panic when she got this error “Flash cannot parse this document” after trying to open up a file she had just saved. While she tried to salvage some of her work from a decompiler I took a look at if we could fix the file.

Some quick Google searching came up with the right clue to figuring out what was wrong. The user wbfreek21 got me on the right path to figuring out just what happened. He talks about how he was able to fix his particular file by going into the new XML based FLA format and removing empty XML elements from the DOM here.

That’s it! Flash cannot parse this document, it’s an error in the XML! I quickly followed the instruction to open the FLA as a ZIP and started poking around in the XML files. They were large, this wasn’t a small project. Firefox has an XML parser as well but it lists out where the problem characters are, I tried opening all the files in the LIBRARY directory in Firefox and instantly found the issue. The empty character that wbfreek21 reported was this ETX (End of Text) character that had found it’s way into the document. I pulled out that character and successfully opening up the file in Flash CS5 again much to the designers joy.

Here is the step by step process I used to find and remove the problem:

  1. Make a copy of your corrupt FLA and put it in a fresh folder, in case you need to repeat steps
  2. Rename the extension on your FLA to ZIP and extract the contents to a folder
  3. There are several XML files in the extracted folder structure, I found my corrupt file in the LIBRARY folder but all XML files should be tested. Open each XML file in Firefox, when you reach a corrupted file you will get an error page that looks like this:
  4. Open that document in a text editor that can show hidden ASCII characters, I used Notepad++ but I wasn’t able to find an editor that worked for a Mac sorry, scroll to the line that Firefox reported your error on and take a look at the code in there to see what your problem area was, my XML document looked like this:
  5. Save your XML file with the character removed and repeat steps 3 and 4 on the same file you found an error in and the rest of the XML files in the folder structure.
  6. Now open up your XFL file in the root of your extracted folder structure, you shouldn’t get any errors, if you get a parse error again repeat steps 3 through 5. Use Save As to make a copy of your file as a FLA, you’re all set!

Sizing the buttons on the NumericStepper

So your working on a new RIA in Flash and you want to use the built in NumericStepper, or any other Flash component for that matter but you aren’t happy with the skin. You’ve already seen Customizing the NumericStepper component by Adobe and you’re ready to move past changing the color of the component and want to update the buttons. Every time I updated the component skin after it has been added to the Library in Flash and tested the Movie, the smaller button graphics I created get stretched and distorted. It was always 21 pixels wide and 12 pixels tall! The Adobe documentation on the NumericStepper didn’t provide any help in resizing these buttons that control the increase and decrease for the NumericStepper component.

What you need to do is open up the source and take a look to figure out what was going on. I found the source files here C:\Program Files (x86)\Adobe\Adobe Flash CS4\Common\Configuration\Component Source\ActionScript 3.0\User Interface\fl\controls\NumericStepper.as on my system. I found out what was going wrong by doing a quick search for that pesky 21 pixel width and found my answer starting on line 527.

527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
override protected function configUI():void {
	super.configUI();
 
	upArrow = new BaseButton();
	copyStylesToChild(upArrow, UP_ARROW_STYLES);
	upArrow.autoRepeat = true;
	upArrow.setSize(21, 12);
	upArrow.focusEnabled = false;
	addChild(upArrow);
 
	downArrow = new BaseButton();
	copyStylesToChild(downArrow, DOWN_ARROW_STYLES);
	downArrow.autoRepeat = true;
	downArrow.setSize(21, 12);
	downArrow.focusEnabled = false;
	addChild(downArrow);
 
	inputField = new TextInput();
	copyStylesToChild(inputField, TEXT_INPUT_STYLES);
	inputField.restrict = "0-9\\-\\.\\,";
	inputField.text = _value.toString();
	inputField.setSize(21, 24);
	inputField.focusTarget = this as IFocusManagerComponent;
	inputField.focusEnabled = false;
	inputField.addEventListener(FocusEvent.FOCUS_IN, passEvent);
	inputField.addEventListener(FocusEvent.FOCUS_OUT, passEvent);
	addChild(inputField);
 
	inputField.addEventListener(Event.CHANGE, onTextChange, false, 0, true);
	upArrow.addEventListener(ComponentEvent.BUTTON_DOWN, stepperPressHandler, false, 0, true);
	downArrow.addEventListener(ComponentEvent.BUTTON_DOWN, stepperPressHandler, false, 0, true);
}

Ah ha! They set the size of the buttons when the component is initialized on the stage. You can’t edit this file to solve your problem though you’ll need to extend the fl.controls.NumericStepper class and override the configUI function to change the size of your buttons. I suspect there are several other instances of hard-coded component sizes in the Flash component library but you just need to look to the source they provided to extend the components to your liking.