Flash on iOS issue with flash.net.navigateToUrl( );

I’m playing around with Flash packager for iPad and iPhone and it seems like there might be some restrictions on accessing files bundled with the application and delivered within the application directory.

During some video tests I delivered one h.264 video within the application directory and tried starting it using this code invoked on a MouseDown event:

var file : File = File.applicationDirectory.resolvePath( "video.mp4" );
navigateToURL( new URLRequest( file.url ) );

But nothing happened. Really nothing. No thrown error. It’s like I simply didn’t call navigateToUrl. Of course everything works fine with remote URLs so I’m quite sure I didn’t make a mistake.

After several different approaches I figured out I couldn’t access any of my files within the app:/ directory. Regardless of the filetype. Well, at least it didn’t work on my devices: iPhone with iOS 4.1 and iPad with iOS 3.2.2.

There’s a discussion about that the Adobe forums: http://forums.adobe.com/message/2979185

Posted in Flash on iOS, iPhone / iPad | 7 Comments

iPhone / iPad ActionScript Guide quotes

As I mentioned here I strongly recommend to read Adobe’s Building ADOBE® AIR® Applications with the Packager for iPhone® guide or Flash Platform for iPhone.

Just some ActionScript facts:

ActionScript APIs unsupported on mobile devices
ActionScript APIs specific to mobile AIR applications
ActionScript APIs of special interest to mobile application developers

Posted in ActionScript, Flash, iPhone / iPad | Leave a comment

iPhone / iPad Development Guide quotes

Since I’m diving deeper into Flash for iOS devices I strongly recommend to read Adobe’s Building ADOBE® AIR® Applications with the Packager for iPhone® guide or Flash Platform for iPhone.

Beside the know how of subscribing as a Apple developer, obtaining certificates and so on I think this informations are quite valuable but easy to forget:

iPhone icon and initial screen images

The iPhone adds a glare effect to the icon… To remove this default glare effect, add the UIPrerenderedIcon key to the InfoAdditions element in the application descriptor file…

All iPhone applications display an initial image while the application loads on the iPhone. You define the initial image in a PNG file named Default.png stored in the main development directory… The Default.png file is 320 pixels wide by 480 pixels tall, regardless of the initial orientation of the application or whether it is full-screen or not.

The iPhone displays its status bar over the 20 pixel-wide rectangle at the top or left of the default image.

For iPad support, you can define images for each supported initial orientation (Default-Portrait, Default-PortraitUpsideDown, Default-PortraitLandscapeLeft, Default-PortraitLandscapeRight.png)… Initial screen images for the iPad are 768 pixels wide and 1024 pixels high.

iPhone application settings

There must be way more settings than this:

<iPhone><InfoAdditions><![CDATA[
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleBlackOpaque</string>
<key>UIRequiresPersistentWiFi</key>
<string>NO</string>
]]></InfoAdditions></iPhone>

Debugging an iPhone application

Debugging the iPhone App over Wi-Fi is possible and GPU rendering diagnostics can be activated at compile time.

Continue reading about more specific ActionScript notes here.

Posted in Flash, iPhone / iPad, Mobile Devices | 4 Comments

iPad says hello to Flash community

Hello iPad. Maybe Apple denied compiling Apps with Flash because they just had problems delivering enough iPads to the Flash community? ;)

Since customer requests grow and a new version of iPad seems to appear on the horizon I decided to get one of the 1. gen. iPads for testing purposes. I’m looking forward developing parallel solutions for the web and the iPad / iPhone and I see myself fighting against system limitations like the old days where we had to test our Flash 4 projects on PCs much slower than current mobile devices.

Ride it baby!

Posted in Flash, iPhone / iPad, Mobile Devices | Leave a comment

YouTube about Flash and the HTML5 <video> tag

Interesting YouTube API Blog post explains why YouTube uses Flash Player for video playback:

http://apiblog.youtube.com/2010/06/flash-and-html5-tag.html

Posted in Flash, Flash in Browser, Flash Player, Video | Leave a comment

Open Source Media Framework 1.0

Adobe recently released OSMF version 1.0! Again just some links:

OSMF Blog – Announcing OSMF 1.0!
Source ZIP
Release Notes PDF
ASDocs ZIP

Posted in ActionScript, Flash, Flash in Browser, Flash Player, Flex, Librarys, Video | Leave a comment

Flash Performance Visualizer

Mr.doop’s Hi-ReS! Stats is a must have for every ActionScript developer. Seems to be still no. 1!
And I don’t want to search again… So here just the links:

Mr.doop’s blog | Hi-ReS! Stats
Mr.doop’s Stats.as @ GitHub

Update – Most recent version I found:
http://code.google.com/p/mrdoob/source/browse/trunk/libs/net/hires/debug/Stats.as

Posted in ActionScript, Flash, Flash in Browser, Flash Player, Flex | Leave a comment

Undocumented XMLUtil class in Adobe Flash CS5?

I tried to recompile an older Flash CS 4 project with Flash CS 5 but got this compile time error 1061: Call to a possibly undefined method reuseNodes through a reference with static type Class caused by the usage of one of my utility classes:

This didn’t work

import de.superclass.util.XMLUtil;
...
XMLUtil.someMethod();

This still works

...de.superclass.util.XMLUtil.someMethod();

So there was no error in my class because it’s still usable when I use the full class package but it didn’t work when I just import it with the import statement.

After some research I found an undocumented XMLUtil class which avoids the correct access to my de.superclass.util.XMLUtil class.

This class doesn’t exist in Flash CS 4 but is available in Flash CS 5. Simply create a new FLA in Flash CS 5 an run this code on timeline

trace( describeType( XMLUtil ) );

and you’ll get this result:

<type name="XMLUtil" base="Class" isDynamic="true" isFinal="true" isStatic="true">
  <extendsClass type="Class"/>
  <extendsClass type="Object"/>
  <constant name="kAttrYMin" type="String"/>
  <constant name="kAttrXMax" type="String"/>
  <constant name="kAttrYMax" type="String"/>
  <constant name="kAttrObj0" type="String"/>
  <constant name="kAttrObj1" type="String"/>
  <constant name="kAttrX0" type="String"/>
  <constant name="kAttrY0" type="String"/>
  <constant name="kAttrX1" type="String"/>
  <variable name="kTagGravity" type="String"/>
  <constant name="kAttrY1" type="String"/>
  <variable name="kTagCollideSpace" type="String"/>
  <constant name="kAttrType" type="String"/>
  <variable name="kTagRigidBody" type="String"/>
  <constant name="kAttrPin" type="String"/>
  <variable name="kTagRect" type="String"/>
  <constant name="kAttrSlider" type="String"/>
  <variable name="kTagJoint" type="String"/>
  <constant name="kAttrLength" type="String"/>
  <variable name="kTagSpring" type="String"/>
  <constant name="kAttrStrength" type="String"/>
  <variable name="kTagFrames" type="String"/>
  <constant name="kAttrDamping" type="String"/>
  <variable name="kTagFrame" type="String"/>
  <constant name="kAttrSimSpeed" type="String"/>
  <variable name="kTagFluid" type="String"/>
  <constant name="kAttrAxis" type="String"/>
  <variable name="kTagEmitter" type="String"/>
  <constant name="kAttrAsset" type="String"/>
  <variable name="kTagOrigin" type="String"/>
  <constant name="kAttrSpring" type="String"/>
  <variable name="kTagKeyframes" type="String"/>
  <constant name="kAttrSpringStrength" type="String"/>
  <variable name="kTagKey" type="String"/>
  <constant name="kAttrSpringDamping" type="String"/>
  <variable name="kTagView" type="String"/>
  <variable name="kTagGeom" type="String"/>
  <constant name="kAttrIndex" type="String"/>
  <constant name="kAttrCollideType" type="String"/>
  <constant name="kAttrCellSize" type="String"/>
  <constant name="kAttrSpringValue" type="String"/>
  <constant name="kAttrCollideSpace" type="String"/>
  <constant name="kAttrRowDimen" type="String"/>
  <constant name="kAttrDensity" type="String"/>
  <constant name="kAttrColDimen" type="String"/>
  <constant name="kAttrPosX" type="String"/>
  <constant name="kAttrTimeStep" type="String"/>
  <constant name="kAttrPosY" type="String"/>
  <constant name="kAttrTime" type="String"/>
  <constant name="kAttrAngle" type="String"/>
  <constant name="kAttrColor" type="String"/>
  <constant name="kAttrVelX" type="String"/>
  <constant name="kAttrStrokeColor" type="String"/>
  <constant name="kAttrVelY" type="String"/>
  <constant name="kAttrAlpha" type="String"/>
  <constant name="kAttrVelA" type="String"/>
  <constant name="kAttrFPS" type="String"/>
  <constant name="kAttrCOR" type="String"/>
  <constant name="kAttrSprings" type="String"/>
  <constant name="kAttrCOF" type="String"/>
  <constant name="kAttrLimits" type="String"/>
  <constant name="kAttrFixed" type="String"/>
  <constant name="kAttrMinAngle" type="String"/>
  <constant name="kAttrID" type="String"/>
  <constant name="kAttrDBlend" type="String"/>
  <constant name="kAttrPoseStrength" type="String"/>
  <constant name="kAttrPoseDamping" type="String"/>
  <constant name="kAttrBodyDamping" type="String"/>
  <constant name="kAttrX" type="String"/>
  <constant name="kAttrY" type="String"/>
  <constant name="kAttrXMin" type="String"/>
  <accessor name="prototype" access="readonly" type="*" declaredBy="Class"/>
  <method name="nodeHasAttribute" declaredBy="XMLUtil" returnType="Boolean">
    <parameter index="1" type="XML" optional="false"/>
    <parameter index="2" type="String" optional="false"/>
  </method>
  <method name="getIntAttribute" declaredBy="XMLUtil" returnType="int">
    <parameter index="1" type="XML" optional="false"/>
    <parameter index="2" type="String" optional="false"/>
    <parameter index="3" type="int" optional="true"/>
  </method>
  <method name="getNumberAttribute" declaredBy="XMLUtil" returnType="Number">
    <parameter index="1" type="XML" optional="false"/>
    <parameter index="2" type="String" optional="false"/>
    <parameter index="3" type="Number" optional="true"/>
  </method>
  <method name="getBoolAttribute" declaredBy="XMLUtil" returnType="Boolean">
    <parameter index="1" type="XML" optional="false"/>
    <parameter index="2" type="String" optional="false"/>
    <parameter index="3" type="Boolean" optional="true"/>
  </method>
  <method name="getStringAttribute" declaredBy="XMLUtil" returnType="String">
    <parameter index="1" type="XML" optional="false"/>
    <parameter index="2" type="String" optional="false"/>
    <parameter index="3" type="String" optional="true"/>
  </method>
  <factory type="XMLUtil">
    <extendsClass type="Object"/>
  </factory>
</type>

So I had to rename my class to de.superclass.util.XMLUtils.

You might run into the same problems when using mx.utils.XMLUtil (Flex Framework) or com.adobe.utils.XMLUtil (AS3CoreLib) but I didn’t test it!

UPDATE:
I found XMLUtil classes in
Adobe Flash CS5/Common/Configuration/ActionScript 3.0/libs/ik.swc and
Adobe Flash CS5/Common/Configuration/ActionScript 3.0/libs/PffLib.swc

Removing the $(AppConfig)/ActionScript 3.0/libs directory within the ActionScript export settings avoids the problem. But I have no time to test if this directory is necessary. If you run into problems please leave me a comment!

Posted in ActionScript, AIR, Flash, Flash in Browser, Flash Player, Flex | 3 Comments

Aligning Flash TextField instances visually correct

I was looking for an easy way to align TextField instances with different font sizes visually correct. I really thought this wouldn’t take much time but it turned out to become really frustrating.

So think about a simple scenario: Try to align two TextField instances with different font sizes side by side. If you just set the TextField.y property to the same value you will recognise that different font sizes have different top margins. Well, you might fix that by hand if you have a static layout but what if you don’t know what kind of Text will be displayed? In my case I needed to align text always on top with the same margin regardless of the headline font size.

I tried hard to get this done by using different methods provided by the TextField class. Then I tried to work with the TextLineMetrics class as well. Nothing worked properly for me. I needed to work with CSS formatted HTML text so I was looking for a margin-top style or something similar. Not available. Hm.

Then I remembered my solution about finding the alpha bounds within external loaded PNG files and used that. Well, the main downside is that I need to create a BitmapData instance to determine the exact text bounds but otherwise it worked out very well.

It all comes down to two simple methods that will slip into my library. At the end you will receive a rectangle representing the bounds on the TextField instance.

If you know a different way to obtain the same exact result please leave me a comment!

Here’s my solution:

function getDisplayObjectAlphaBounds( displayObject : DisplayObject, smoothing : Boolean = true ) : Rectangle
{
    var bitmapData : BitmapData = new BitmapData( displayObject.width, displayObject.height, true, 0 );
        bitmapData.draw( displayObject, null, null, null, null, smoothing );
 
    var alphaBounds : Rectangle = bitmapData.getColorBoundsRect( 0x01000000, 0x01000000 );
 
    bitmapData.dispose();
 
    return alphaBounds;
}
 
function getTextFieldTextBounds( textField : TextField, smoothing : Boolean = true ) : Rectangle
{
    var background : Boolean = textField.background;
    var backgroundColor : uint = textField.backgroundColor;
    var border : Boolean = textField.border;
    var borderColor : uint = textField.borderColor;
    var opaqueBackground : Object = textField.opaqueBackground;
 
    textField.background = false;
    textField.border = false;
    opaqueBackground = null;
 
    var textBounds : Rectangle = getDisplayObjectAlphaBounds( textField, smoothing );
 
    textField.background = background;
    textField.backgroundColor = backgroundColor;
    textField.border = border;
    textField.borderColor = borderColor;
    textField.opaqueBackground = opaqueBackground;
 
    return textBounds;
}
 
var textFormat : TextFormat = new TextFormat();
    textFormat.align = TextFormatAlign.CENTER;
    textFormat.color = 0x0000FF;
    textFormat.font = "Arial";
    textFormat.size = 30;
 
var textField : TextField = new TextField();
    textField.border = true;
    textField.borderColor = 0x0000FF;
    textField.background = true;
    textField.backgroundColor = 0x000022;
    textField.defaultTextFormat = textFormat;
    textField.height = 260;
    textField.text = "\nThis text\ncan be\naligned\nproperly!";
    textField.width = 300;
    textField.x = 30;
    textField.y = 30;
 
addChild( textField );
 
// Get bounds
var textBounds : Rectangle = getTextFieldTextBounds( textField );
 
// Draw bounds
var shape : Shape = new Shape();
    shape.x = textField.x;
    shape.y = textField.y;
 
var g : Graphics = shape.graphics;
    g.lineStyle( 1, 0x00FFFF );
    g.drawRect( textBounds.x, textBounds.y, textBounds.width, textBounds.height );
 
addChild( shape );

Posted in ActionScript, AIR, Flash, Flash in Browser, Flash Player, Flex | 2 Comments

Setting up my new MacBook Pro

A few days ago my new my new antiglare 15″ i7 MacBook Pro arrived and I decided to manually setup this new system. Rethinking everything is always a good opportunity to leave some old stuff behind.

Before I bought my first MacBook Pro in late 2006 I owned PCs only and so I still used Thunderbird on my Mac until now. But it wasn’t that easy to bring all my old local stored mails into Mail. It worked quite well but for some reasons it didn’t work for every folder. For example one folder contained 2364 emails but Mail was only importing 653. I tried it several times but I had to use my IMAP account to transfer these mails into this new environment. That took really a little while for several folders.

Maybe it’s not necessary but since my new user account uses the same username and password I had no problem to simply copy & paste data for Adium, Address Book, iCal, iPhoto, iTunes and Skype.

I also decided to upgrade or switch to newer software like OmniFocus, Parallels Desktop 5, Transmit and Versions. And of course a fresh version of FDT Enterprise is still my favorite application.

Luckily Adobe shipped the new Creative Suite 5 today and so hopefully there’s no need to install CS 4 products anymore.

My last step is refining my directory structure and then I’m looking forward to work with this machine for the next 3 or 4 years with hardware video encoding and 8 GB RAM.

But the biggest question is: Which sticker will I use to hide the big apple?

Update – 2011.09.15. Finally I made a decision:

Posted in Mac | Leave a comment