Archive

Author Archive

Hash anchors (using “#”) in a SWF URL will break preloaders due to a player bug

May 18th, 2010 markledford 1 comment

It’s pretty frustrating when you attempt to do something as commonplace as add a custom preloader to a Flex App and and you end up debugging for hours because something went pear shaped for no apparent reason at all. No matter what I did the preloader would not show up until the app was loaded and it moved to the initialization sequence of the preload. During times like this Adobe’s public bug database is a godsend.

[SDK-14162] [Flash Player] Preloader not showing up when we add deeplinking urls
[FP-2332] Named Anchors in URL prevent SWF from being streamed in

Turns out there is a pretty significant Flash Player feature (read bug) that will foobar preloaders for Flex apps (and probably even regular Actionscript projects) if they contain an anchor tag. As described and as I’ve reproduced, this issue would effect most major Flex apps and Flash sites as most use deep linking techniques with hash tags like with SWFAddress.

Alex Harui explains the issue in the latter Jira like so:

This problem is due to a feature in the Flash Player that allows deep-linking in Flash Authoring SWFs. If you label frames on the timeline in the SWF, you can jump to them by putting hash fragments on the URL.

This feature is, of course, completely useless for Flex deep-linking as Flex apps only have two frames and there’s no way to compute what label to use on the frame.

This bug will remain NAB for now. We have made a request for a way to opt out of this feature in future players but it may not happen any time soon.

Technically it seams what happens in the swf will try to skip ahead to a non existent frame label causing it to prevent your swf from properly streaming.  The current fix is to use BrowserManagerShim.as a class provided in the first Jira that just loads your swf and takes the hash tag issue itself. 

Categories: flex Tags:

Steve Jobs’ Thoughts on Flash

April 29th, 2010 markledford 4 comments

Updated 06/04/10

As a consumer and lover of Apple products and a full-time Flash developer it was interesting to see Job’s RDF used against Flash (Oh no! Daddy hit mommy!). But seriously, its about time that Apple replied to the hoopla regarding its blocking of Flash on its Iphone platform. I may have my biases being a Flash developer but I also have my expertise in the field and I couldn’t help but note that most of the reasonings outlined in his article were pretty poor at best and completely meritless at worse.

No Flash site i know of “depends on rollovers” and would have to be “completely re-written” to support touch. Navigation is almost always based on mouse clicks which get triggered regardless of whether its touch or not.

Its silly not calling Flash a modern technology, it drastically updates every year, sometimes completely re-written, and its really the only technology in the world that does that and gets adopted near 98% year after year regardless–html certainly doesn’t do that. Even today with html 5 there isn’t an agreed upon video format. Some browsers require the Ogg Theora format which no one would otherwise transcode for right now, and the other mp4 which has its own can-of-worms with potential licensing costs as the patents are owned in part by, ding, Apple. Even with that hurdle quashed there are technical and logistical issues with supporting ad networks in html 5 video, but Apple is there again to take a bigger cut of the pie with its recent purchase of mobile ad network Quattro Wireless and new iAds advertising platform. Steve Jobs is creating an artificial hole in web media under the pretenses of open standards–something Apple is normally a foreigner to, to monetize and control it when restarting it from the ground floor.

I think I could provide significant arguments for practically every point (like that whole transition layer debacle) but I’m sure there’ll be plenty of that gong on on the internets.

What it comes down to is that there’ll always be the right tool for the right job and Flash still does certain things best right now. It continues to innovate with a refresh cycle that html with its design-by-committee is not close to catching up with. It really isn’t the complete web without supporting it and Adobe continues to update Flash Player to keep it relevant to modern needs. Adobe has been working on some hard core mobile optimizations with its Open Screen Project and Flash Player 10.1 which is in RC2 and continues to partner with the big names to make it happen.

My two cents,
Mark

Some good rebuttals are popping up btw:
http://www.businessinsider.com/steve-jobs-is-lying-about-flash-2010-4
http://jessewarden.com/2010/04/steve-jobs-on-flash-correcting-the-lies.html

Great summary in the first article:
Steve needs to stop trying to make this into a “technology” issue when this is all about money. If you came out and said you’re not supporting Flash because you can make more money without it, fine by me, I won’t argue with that. But to try and disguise it as something else, that only makes Apple look bad, not Adobe.

Categories: flex Tags:

FYI ExternalInterface.available probably doesn’t do what you think

April 22nd, 2010 markledford 1 comment

I think the general Flash Dev consensus is if ExternalInterface.available returns true that you can use ExternalInterface in the swf. This is actually not the case as this property does not check if your security sandbox allows you to use javascript. This is an important distinction for things like Flash widgets that can end up on 3rd party destinations like Facebook that re-write allowScriptAccess=”never”. You’ll need to always try/catch these calls to ensure a security sandbox error won’t break your swf. The closest to documentation on this I could find was this cautionary foot note in the docs which does not explicitly mention security sandbox issues:

NOTE The

 ExternalInterface.available

property reports whether the current container is a type that supports ExternalInterface connectivity. It will not tell you if JavaScript is enabled in the current browser.

Categories: actionscript Tags:

I finally got tethering on my iphone working!

February 17th, 2010 markledford 1 comment

So it was quite a chore but I finally got internet tethering working on my iPhone 3gs with firmware 3.1.2, baseband 05.11.07.
Btw firmware 3.1.3 was released a week or two ago, it won’t work with this and doesn’t have anything worthwhile so don’t update to it!
If you’re interested in tethering your iPhone then read on below. I haven’t been up on the jailbreak scene at all, so if I can do it, you can too, but
no promises if your set up isn’t exactly like mine and you end up bricking your phone. Oh and you need a Mac to do this.

This tethering is done through a jailbreak’ed app called MyWi.
MyWi
Its an app you actually have to pay for which is weird given its a jailbreak’ed app but its well worth the 10 bucks and has a free 10 day trial i’m still using.
Its actually better then the old hack for tethering that you could do with a custom ipcc  profile, mainly because it still works but also:
- it can allow you to share your iphone’s internet via USB / bluetooth OR by turning your phone into a WEPd wi-fi hotspot multiple computers can join
- shows up and down bandwidth usage as it runs in the background with a nice graphical display
- doesn’t require a custom ipcc profile

This also seams to be the best route for this firmware version because:
- you don’t have to unlock your phone and it doesn’t involve a tether’d jailbreak (where you have to plug your phone into the computer whenever you restart)
You don’t have to install ultrasn0w, blacksn0w, blackra1n (or any other program with 1s or 0s in it)
- at 10 bucks it isn’t worth the time-sink figuring out another reliable way of doing this

Drawbacks:
- your phone will be jailbroken(?) and may be less dependable (and will have a pineapple for a boot up logo) though mine seams to be working pretty well so far.

Steps:
1. Connect your iPhone to iTunes and back that ish up.
2. Download PwnageTool_3.1.5.dmg from http://blog.iphone-dev.org/ and install it
3. Use PwnageTool to create a jailbroken version of the iphone firmware and load it onto your iphone via iTunes. I followed a step-by-step tute like this one
3b. Resync your phone with iTunes to get all your apps, music, photos, etc back on your iphone. You can do this later as it takes forever.
4. You should have your jailbroken phone up and running at this point with Cydia app on it. A very slow, crude looking, not-apple-app-store App Installer with way too many ads in it.
Open Cydia and click on the search icon in the bottom right and type “rockapp”, and install it (its another App Installer like Cydia but from another company, the same one that makes iWi).
5. Open it, click on MyWi, install the trial, load it up and you should be good to go

Good luck!
Mark

Categories: iphone, not flash related Tags:

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:

mouse events aren’t dispatched for graphics drawn on main display class

January 5th, 2010 markledford 1 comment

This is bizarre. It appears the main display object’s graphics object is rendered on Stage and not its own display as in the example above:

In the Actionscript Project published above I have a red square drawn on the graphics of the main Sprite class and a child sprite with a green square and a textfield to the right to trace clicks.
I have MouseEvent.CLICK listeners on stage, main sprite ClickTest, and child Sprite. With mouse children disabled clicking anywhere will report a single MouseEvent.CLICK to stage even though they should be dispatching for both the main display and stage. With mouseChildren enabled the top square will still only trigger the Stage mouse listener but the bottom will correctly trigger the click on the child sprite, main parent ClickTest sprite, and stage showing that the main DisplayObject is participating in the mouse event bubbling.

Thus my conclusion that the main display object’s graphics object is rendered on Stage which can cause a lot of unexpected behavior and confusion.  Your root display class cannot listen to its own display to catch mouse events for its own graphics object. I guess this could make enough sense if the root display object shared its display with the root Stage but as this hierarchy diagram shows, it shouldn’t: http://www.adobe.com/devnet/flash/quickstart/display_list_programming_as3/

I’d consider it one of those bizarre architecture inconsistencies like swfs having references to stage in the constructor when ran stand alone but not when they are loaded into another swf, its just inconsistent and asking for trouble?

Categories: actionscript, bugs 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: ,