Jan 20 2012

Adobe Flash – Important Bug – RSL & FlashVars

Tag: Actionscript,Adobe,Adobe Flash - bug or feature,AllgemeinKonstantin Elstner @ 09:16

Seit Adobe im Jahr 2010 Flash Professional CS5 vorgestellt hat, kommt es immer wieder zu einem aufttretenden Bug.
Die Möglichkeit FlashVars auszulesen existiert schon fast seit der Jahrtausendwende, Adobe scheint es aber zu lieben Entwicklern immer wieder Steine vor die Füße zu werfen, auch bei den FlashVars ist es nicht anders. Normalerweise sollten diese wie folgt auslesbar sein:

loaderInfo.parameters.xmlPath

Diese Codezeile würde die Variable “xmlPath” wenn gesetzt auslesen.

Seit Flash CS5 kann es aber passieren das eben dieser Code “undefined” zurück gibt, obwohl die Variable korrekt von außen gesetzt ist. Ein Umstand, der so gut wie jeden Entwickler in den Wahnsinn treiben kann.

Sollte das auslesen wie oben beschrieben einmal nicht funktionieren sollte man entweder:

parent.loaderInfo.parameters.xmlPath

oder wenn dies auch nicht zum Ziel führt:

parent.parent.loaderInfo.parameters.xmlPath

probieren.

 

Alternativ geht auch der Zugriff über root oder stage:

Global.xmlPath = root.loaderInfo.parameters.xmlPath

oder

Global.xmlPath = stage.loaderInfo.parameters.xmlPath

 

Warum dies notwenig ist?

Adobe hat mit Flash CS5 auch für die IDE das RuntimeSharedLibrary Feature eingeführt (kurz RSL), diese Technik kommt aus dem Flex Bereich und wird ua. für das TextLayoutFramework verwendet. Mit Hilfe von RSL können einzelne Klassen in SWZ Dateien gepackt werden, diese werden gesondert signiert und der User muss nicht zB. bei jedem Flex Anwendungsaufruf das komplette Flex Framwork laden, sondern nur die vom Entwickler integrierten Erweiterungen. Dies spart Traffic und kann auch in eigenen Klassen verwendet werden. Weitere Infos gibt es unter http://help.adobe.com/de_DE/FlashPlatform/reference/actionscript/3/fl/rsl/package-detail.html.

Damit die generierte SWF die bereitstehenden RSL-Dateien vor der eigentlichen Anwendung laden kann integriert Adobe automatisch einen RSL-Preloader. Da man bei Adobe stellenweise wohl nicht so viel Wert auf QM legt hat sich in diesem Preloader ein Bug eingeschlichen, der eben die Übergabe, bzw. die Weiterleitung der FlashVars verhindert, daher der Workaround via parent.loaderInfo.

Adobe ist über den Bug informiert, hat diesen aber auch in die Version CS5.5 übernommen, bleibt zu hoffen er wird in CS6 endlich gefixt, denn selbst ein unabsichtliches anlegen eines TLF basierenden Textfeldes in der IDE ruft die fehlerhafte RSL-Preloader-Mechanik auf die Tagesordnung.

http://forums.adobe.com/thread/644057


Jul 26 2011

Adobe Flash – bug or feature – No multitouch gestures on android

Tag: Actionscript,Adobe,Adobe Flash - bug or feature,AllgemeinKonstantin Elstner @ 00:09

After I wrote in one of my last posts about the missing stageVideo on Android devices. Today I want to write about another missing feature.

A very nice “gimmick” of android is the multitouch feature, swipe to left or right to go to another “site”, swipe down to scroll and so on. Adobe write in there actionscript 3.0 api documents, that this feature would be available to all multitouch devices with one exception, the mac os trackpad is not supported:

Note: The Multitouch feature is not supported for SWF files embedded in HTML running on Mac OS.

(source: http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/flash/ui/Multitouch.html)

 

These days we were working on a flash magazine, which we also optimized  for use with tablets. Our client, for whom we has produced successfully an Android AIR magazine demo, asked us if we could integrate swipe gestures for left and right to switch the sites. I said to him, maybe it is possible, I would check it out and call him back. So I adapted our magazine to test the support of multitouch.

The first thing we struggled over is the fact, that Adobe may thought, when developing Flash CS5.5, that there would be no differences between the Flash Player 10.0 and Flash Player 10.1. Very interesting I think ;)

If you are going to try code like this in Flash Player 10.0:

1
2
3
import flash.ui.Multitouch;
[...]
Multitouch.inputMode = MultitouchInputMode.GESTURE
import flash.ui.Multitouch;
[...]
Multitouch.inputMode = MultitouchInputMode.GESTURE

Flash will publish your swf without any problems. But if a user with a flash player > 9.x and < 10.1, the flash player will hang without any visible error to the user.

With hang I mean, totally hang, after excuting this lines of code the complete SWF file will stop working. If you try this code with a 10.0 debugger player you get a General Error, and afterwards the code excution stops. So be sure, that this SWF will be only delivered for users with flash palyer 10.1 or greater.

This problem occurs for all multiouch related events and gestures!

A workarround is very simple implemented … simply check with an if-condition which version of the flash player the user has:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// this function will return true if the flash player version is 10.1 or greater
function get multitouchSupported():Boolean {
var vAr:Array = Capabilities.version.split(",");
 
if( Number( vAr[0].split(" ")[1] ) < 10 ) {
return false;
} else if( Number( vAr[0].split(" ")[1] ) > 10 ) {
return true;
}
 
if( Number( vAr[1] ) > 0 ) {
return true;
}
 
return false;
}
// this function will return true if the flash player version is 10.1 or greater
function get multitouchSupported():Boolean {
var vAr:Array = Capabilities.version.split(",");

if( Number( vAr[0].split(" ")[1] ) < 10 ) {
return false;
} else if( Number( vAr[0].split(" ")[1] ) > 10 ) {
return true;
}

if( Number( vAr[1] ) > 0 ) {
return true;
}

return false;
}

or check which CPU the device has:

1
2
3
if( Capabilities.cpuArchitecture == "arm" ) {
// code to excute
}
if( Capabilities.cpuArchitecture == "arm" ) {
// code to excute
}

 

The second thing I deiscovered for my self, is that it seems, like it is impossible to use multitouch events like the TransformGesture or the general MultiTouch-Actions if your app is running in a browser on an Android device. On my test devices, a Samsung Galxy I9000 (Android 2.3.3) and a Samsung Galaxy Tab 10.1v, there was no multitouch support in the browser. I tested the support with this simple lines of code:

1
2
3
4
5
if( Multitouch.supportedGestures == null || Multitouch.supportedGestures.length == 0 ) {
trace( "no multitouch support");
} else {
trace( "multitouch available");
}
if( Multitouch.supportedGestures == null || Multitouch.supportedGestures.length == 0 ) {
trace( "no multitouch support");
} else {
trace( "multitouch available");
}

The same code traces “multitouch available” if the code is running as a AIR app on this devices.

I hope, that this will be changed in a feature release of the flash player.

 

In short:

- Take care, that code like the following is only excuted in a flash payler greater or equal to 10.1, otherwise the SWF will stop working

1
2
3
import flash.ui.Multitouch;
[...]
Multitouch.inputMode = MultitouchInputMode.GESTURE
import flash.ui.Multitouch;
[...]
Multitouch.inputMode = MultitouchInputMode.GESTURE

- On Android devices there is at this time no multitouch support available in the browser


Jul 06 2011

Adobe – bug or feature: No stageVideo on Android 3.0.1 & 3.1?

Tag: Actionscript,Adobe,Adobe Flash - bug or featureKonstantin Elstner @ 21:20

Today I experimented with the new stageVideo, which is available since Flash Player 10.2. It is a very nice technique, where the video is rendered through a pipe by the gpu. So the cpu consumption is quite 10 to 20 percent playing a full HD video instead of 50 percent or more. Even it reduces the energy consumption.
On a mobile chip-set like the Tegra from Nvidia the video playback should be very smooth in theory.
Adobe has announced this technique at the Adobe Max last year. In January Adobe said it would be available with Android 3.0.
So I thought it would be the right time to check it out now on my Galaxy Tab 10.1v.

But surprise:
No stageVideo is available in Flash Player 10.3 on Android 3.0.1.
No stageVideo is available in Adobe AIR 2.6 on Android 3.0.1.
And last but not least no support of stageVideo in Adobe AIR 2.7 on IOS.

What happened?

Adobe has quite updated the release informations for stageVideo.

At this developer FAQ (modified 28 March 2011):

http://www.adobe.com/devnet/devices/articles/optimization_features_fp101.html

And at this site too (modified 4 April 2011):

http://www.adobe.com/devnet/devices/articles/mobile_video_encoding.html

Adobe informs, that stageVideo would be available with Android 3.0.1 …

But at this shortly updated main site (tab mobile features):
http://www.adobe.com/products/flashplayer/features/
Adobe told us, that the stageVideo would be not available until Android 3.1.

Hardware-accelerated video presentation (requires Android 3.1)

Enjoy beautiful, smooth playback of high-definition H.264 video content powered by Adobe® Flash® technology across the web in both embedded and full-screen mode using Android™ tablets with Android 3.1, like the Motorola XOOM. Adobe Flash Player leverages the Stage Video hardware-accelerated video pipeline to provide higher frame rates and less power consumption, building on the efficiency of hardware-accelerated H.264 decoding.

Note: Hardware-accelerated video presentation support will only be available with Android 3.1 and is not supported on earlier versions of Android.

I like the note *irony*.

What a pity and what a great way of communication.

Thanks Adobe.

I hope stageVideo will be truly supported on Android 3.1. At this time I can not test it, because I have no Android 3.1. Playing a h264 video with cpu based rendering is quite a pain.

And by the way: should not Flash Player 11 released in mid 2011?

 

[Update]

Today I updated my Galaxy Tab 10.1v to Android 3.1 with Flash Player 10.3.185.25 … also no stageVideo support. Can somebody confirm this with other devices?

Testlink is:
http://d-ssl.de/svTest/

Player is based on OSMF 1.6.

Code to check stageVideo support:

try {
console.appendText( “availabe stageVideo pipes: “+stage['stageVideos'].length+”\n” );
} catch(e:Error) {
return;
}
for( var i:int; i < stage['stageVideos'].length; i++ ) {
if( stage['stageVideos'][i].videoWidth > 0 ) {
console.appendText( “pipe “+i+”: video size: “+stage['stageVideos'][i].videoWidth+”x”+stage['stageVideos'][i].videoHeight+”\n” );
}
}