Author Archive for Jason

02
Nov
11

Native Extensions for Android with Air 3 and Flashdevelop

I spent a day or so recently wrangling with the new Native Extension capabilities introduced in Air 3, so thought I’d post up some details of my findings.

Firstly, I’ll be honest and say that I found the process (starting from scratch) to be quite convoluted.

I got pointers in (mostly) the right direction from here, here and here. But I was still struggling with how to use FlashDevelop to get the compilation of java files, and packaging of the ANE.

That’s where the Ant script that was included in the Git hub of Small Screen Design helped greatly! I made some tweaks and managed to get Christian Cantrell’s original compass app (which wasn’t supplied with the .ane file) to compile and package successfully.

You can download my FlashDevelop project folder to see the build.xml file and the structure which I’ve used.

CompassNativeExtension.rar

Hope this helps others struggling with getting their head around the seemingly dizzying number of hoops to jump through to get Native Extensions humming along ;-)

16
Aug
11

Textfield scaling issue

Thought I’d post about this issue unless anyone else comes across something similar and needs a fix.

On a recent site I worked on (www.sky.com/bintm) i’m scaling the content when the user goes into FullScreen mode to make use of slightly higher res photo assets available.

This knocks the double column text article page out of whack. Essentially scaling a movieclip with a dynamic textfield in it results in a different textHeight and numLines being traced for the same textfield dependent on whether you’re in FullScreen mode or not.

After a bit of hunting I came up with the following fix - setting the gridFitType property of the textfield to GridFitType.SUBPIXEL . I tried GridFitType.PIXEL but that still gave different results dependent on the users screen mode.

08
Jul
11

FullScreen Flash mask gotcha

Long time between posts… but thought I’d document this so that anyone else coming across the issue can get a quicker fix than I found.

The problem I was having was with a masked area that wasn’t resizing along with the rest of the content when stage.displayState = StageDisplayState.FULL_SCREEN

The fix for this was to ensure that the mask was actually added to the stage before being applied to the DisplayObject you wanted to mask. Here’s some code:

var __mask:Shape = new Shape();
__mask.graphics.beginFill(0xffcc00, 1);
__mask.graphics.drawRect(GRAPH_X, GRAPH_Y - 40, GRAPH_WIDTH, GRAPH_HEIGHT+39);
__mask.graphics.endFill();
addChild(__mask);
_barsHolder.mask = __mask;

The fix wasn’t entirely obvious as masks don’t generally need to be added to the DisplayList to function properly. Obviously when you’re having the Flash go fullscreen you do.

Hopefully that helps someone else avoid the issue I was having.

13
Oct
10

Flash busted my bullocks last week

Generally speaking, Flash and cross browser deployment go hand in hand… not so for me over the last week. I spent 4 days doing some work for an Agency in London, and I encountered 3 browser related Flash “bugs”.

1. The stage appears to initialise quicker in Firefox and Chrome on Windows than it does in IE. I was working with some code that I hadn’t written (gotta throw a disclaimer in there ;-), and the assumption the code was making was that the stage dimensions were available on Frame 1 of the actionscript’s Document Class. IE wasn’t having a bar of this assumption, instead returning 0 for both the width and height, which was essentially causing the rest of the application to render off screen. Simple remedy was to add an ENTER_FRAME listener and wait for the dimensions to be greater than 0. Notch that one up to utilising someone else’s code that wasn’t really tested properly across browser… but that’s kinda the point of Flash right?

2. The MouseEvent.MOUSEWHEEL event doesn’t fire in IE 8. It does however work in IE6 and 7. I performed the obligatory Google searches for people that were experiencing the same issue, and only really managed to see results related to Mac and the scrollwheel (which can be remedied using swfmacmousewheel). Does anyone have the mouse scroll wheel working in IE8?

3. ExternalInterface relies on the swf actually being visible on screen in Firefox and Chrome. In IE, setting the div that contains the Flash content to display:none still allows a javascript function to communicate with the swf. In Firefox, when the div is hidden, the swf somehow ceases to exist. My hunch is that this is to with swfobject… This situation can be remedied by moving the swf off of the browsers viewport (ie. position:absolute; left:-1000; for a movie that’s 1000 pixels wide). Not sure of the ramifications this fix would have on CPU usage though (the new Flash Player 10.1 made changes in this area (see Periodic timer)).

22
Aug
10

Passing a value object as a parameter to amphp’s browser

Unfortunately I don’t have the answer on how to do this, and after a bit of Googling it seems like I’m not the only one.

Getting VO’s from AMFPHP back into my Flex app as strongly typed objects is fine. Sending a single VO to a method in AMFPHP has me somewhat bamboozled though, given that this makes the Browser then only want to take a single parameter as well (which makes life a bit difficult for testing purposes).

My initial idea to get around this was to modify the service browser to detect when a parameter of a service method was actually a VO object. Then instead of letting the Browser just display a single textinput field (which would require an object with the same type as the VO you want to use - something I’ve got no idea how to do by text alone in the browser), each property of the VO would instead be displayed as it’s own individual textinput field.

Has anyone else been sending VO’s to AMFPHP and still made use of the Browser in their setup? Please drop us a comment if you have.

28
Jun
10

Be careful source controlling Flash Builders html-template folder

As the title of this thread suggests, svn’ing the html-template that Flash Builder relies on to generate the container html files can lead to some headaches. One in particular that has just taken me about 5 hours to solve.

I’ve been migrating my SVN repo over to Springloops (check it out if you haven’t already) and decided to add the html-template folder to source control. Made a few commits, then got to building a deployable swf and that’s when the shit hit the fan. From what I can ascertain, Flash Builder was copying whatever was in the html-template folder (which included the .svn metadata folder) into the build folder. As everything in the build folder was versioned as well (so I can one click deploy to staying and production server) bizarre things started happening when I tried to commit things. In hindsight I should’ve cottoned on to the fact that Flash Builder was actually copying and pasting the html-template’s svn data into a folder that it shouldn’t have been. Of course, hindsight’s a wonderful thing ;-)

20
Jun
10

A Flash spoof of Apple’s HTML5 page

This is absolute Gold!

http://www.flashlab.com/html5/

Bravo to those that created it; you’ve made some very salient points with the examples and comparisons given.

Now we just need to ensure that the same number of people (including Managers and tech decision makers) that read the dribble Apple’s CEO posted a few months back could see and experience this site. And hopefully they can if the Flash community band together with the aim of setting the facts straight.

16
Jun
10

FileReference.load() - keep it in scope!

Just a quick note (possibly to self) that when dealing with FileReference you need to ensure that the scope of the FileReference is maintained. This was mentioned in the Actionscript documentation, but it took me a while to figure out that that could be the problem for my code failing silently. Originally I thought it was because I wasn’t using the right playerglobal.swc from within Flex, or that I couldn’t export using Flex SDK 3.2 (as this method is a Flash Player 10 one). It took me a while to reread the documentation for the load method and comprehend that perhaps I needed to declare some instance variables instead of local ones. Some code will hopefully illustrate what I mean:

public function uploadImage():void
{
	var __imageTypes:FileFilter = new FileFilter("Images (*.jpg, *.jpeg, *.gif, *.png)", "*.jpg; *.jpeg; *.gif; *.png");
	var __fileRef:FileReference = new FileReference();
	try	{
		__fileRef.addEventListener(Event.SELECT, onFileSelect);
		__fileRef.addEventListener(Event.COMPLETE, onFileOpen);
		__fileRef.browse([__imageTypes]);
	} catch (error:Error) {
		trace("Unable to browse for files.");
	}
}

private function onFileSelect(event:Event):void
{
	trace("onFileSelect called");
	var fileRef:FileReference = event.target as FileReference;
	fileRef.load();
}

private function onFileOpen(event:Event):void
{
	trace("onFileOpen called");
	var fileRef:FileReference = event.target as FileReference;
	var data:ByteArray = fileRef.data as ByteArray;
	var encoder:Base64Encoder = new Base64Encoder();
	encoder.encodeBytes(data);
	trace(encoder.toString())
}

The problem with that code is that the original __fileRef variable is only available within the uploadImage function. As soon as onFileSelect is triggered (which works fine), fileRef (a new local variable within this function) trys to call load(). This was failing silently for me.

So instead of declaring the original __fileRef variable as a local one, I’ve declared it as a private variable in the class. That way it’s always in scope!

09
Jun
10

why no AIR store?

Does anyone else find it odd that there’s no Adobe backed central repository for distributing AIR applications? I know that the Central runtime never really went anywhere (apparently due to the technical limitations of the users computer at the time).

So is the world ready for a centralised, built for developers, run for users AIR (dare I say it) App store?

Perhaps it’s time to feed Apple a bit of it’s own medicine, pretending to be innovative in an area that quite clearly has already been done - just not marketed properly.

This time around however, I think Adobe (and it’s throng of Flash developers) can cling to the coattails of Apple’s App Store - but with the promise of being able to use the application across all devices that have the Flash Player installed.

I’m hoping that the latest Flash Player version will allow this to become a reality.

If anyone’s got information about businesses that have already tried to monetise this please add your comments at the bottom.

UPDATE: I’ve been reliably informed by Tink in the comments that there is an Adobe AIR Marketplace. Possibly the fact that I don’t know about it means that there’s still a bit of marketing work to be done somewhere.

27
May
10

Flash 10.1 - Failure is not an option

In light of the recent debate sparked by Steve Jobs’ comments regarding Flash and it’s perceived weaknesses I thought I’d take an opportunity to make it patently clear - the perception of Flash is that it’s a slow, memory and cpu intensive, battery sucking sun of a gun!

Now while I found it relatively easy to pick apart what Jobs said in my previous post, there’s certainly a long way to go to convince the rest of the tech world that the things he’s saying are false. It seems that Adobe are putting a good percentage of their eggs in the Flash Player 10.1 basket as a sign to all those interested in the debate that they are trying to address all (or most) of the issues that have been raised. My fear is that if this release isn’t the golden hair child that Adobe’s making it out to be, then we’ve got a bit of a case of the boy crying wolf on our hands.

The more I read (and I’ve been keeping close tabs on what both sides are saying), the more I see the battle lines are being drawn based on a lot of misinformation. Or more succinctly, the naysayers are not aware of the work that’s been going into 10.1 - fair enough I suppose, you’re only as good as your last innings…

So it’s for this reason that the only thing that really matters is that this latest release gets beta tested to buggery, delivers on the feature-set and enhancements that are being touted, and the millions of other Flash developers out there continue to have a livelihood that doesn’t involve jumping through hoops that are wasteful, and frustrating.

I’m slightly miffed that it’s taken a massive kick in the pants by a competitor (though perhaps that’s always the way…) to open Adobe’s eyes to some of the more regularly complained about issues with Flash. The issues that are now trying to be addressed aren’t new, they’re issues that Flash Designers and Developers have been on Adobe’s case about for many years … so long as their eyes are now open (and remain so), well I suppose that’s a start.

I can’t remember a tech issue that’s gotten me this energised for years! So I’m looking forward to seeing what devices start to utilise the forth coming Flash Player, and how they (and there battery life) perform.

Failure is not an option.




Categories

Recent Comments

Posts this month

February 2012
M T W T F S S
« Nov    
 12345
6789101112
13141516171819
20212223242526
272829  

Archives