There has been some discussion on the RobotLegs AS3 Framework Google Group about the best workflow for launching popups in Flex, so I thought I’d do a quick sample. (more…)
Kingsland Road, London E2 8AA
tel: +44 (0) 207 749 3788
hello@dndigital.net
October 16th, 2009
There has been some discussion on the RobotLegs AS3 Framework Google Group about the best workflow for launching popups in Flex, so I thought I’d do a quick sample. (more…)
August 12th, 2008
The title could do with some improving – what I’m trying to say is that when subclassing UIComponent, any Image component instances need to be given an appropriate width/height. I have overlooked this time and time again, only to find that the image doesn’t appear – because it’s width and height are initialised to zero.
The following code will result in an image with zero width/height, so the image won’t show:
1 2 | var img:Image = new Image(); img.source = "myfile.jpg"; |
Solutions:
1 2 | img.width = 100; img.height = 100; |
1 2 3 4 5 | img.scaleContent = false; // or, if loading cross-domain, provided a crossdomain policy file allows access img.trustContent = true; img.scaleContent = false; |
1 2 3 4 5 6 7 8 9 | img.addEventListener(Event.COMPLETE, onImageComplete); protected function onImageComplete(evt:Event):void { var img:Image = evt.target as Image; img.removeEventListener(Event.COMPLETE, onImageComplete); img.width = img.content.width; img.height = img.content.height; } |
I’ve mainly blogged about it so I remember the next time I write some code – but maybe it will also help somebody else debug their missing image problems.
August 4th, 2008
Here’s a little code snippet that allows you to access flashvar parameters inside a custom Flex preloader.
The custom preloader class extends Sprite and implements the IPreloaderDisplay class. Once the Sprite’s ‘root’ property becomes available, you can use the standard AS3 way of accessing flashvars, namely:
1 | var flashvars:Object = root.loaderInfo.parameters; |
This code should be used once the ‘root’ property has been initialised – for example in the ‘initialize()’ method defined by the IPreloaderDisplay interface:
1 2 3 4 | public function initialize():void { var flashvars:Object = root.loaderInfo.parameters; } |
Just for reference, compare the above approach with the standard Flex method of accessing flashvar parameters – which becomes possible once the main Application instance has been created:
1 | var flashvars:Object = Application.application.parameters |