Maintaining Aspect ratio’s on Flex Containers

September 28th, 2008

A nice thing about using images in Flex you never have to worry about maintaining the proper aspect ratio. If you hard code a width or height would otherwise break that aspect ratio Flex inevitably ignores it and uses blank pixels to fill the extra space created around it. However, If you need a container to size based on a percentage AND constrain to say a 4:3 ratio it turns out there’s no way to make this happen (as an old mentor would say) “auto-magically”. Of course there’s an relatively easy way to achieve by binding an container to its own height or width property and adjusting the value as such:

Here an example where we want the height to take up the maximum space available and the width to adjust itself so that the resulting box maintains the 4:3 ratio.

<mx:Canvas height="100%" width="{(this.height * (4/3))}">

You could do the converse as well..but make sure you use division here since its the ratio is of width to height and we’re dealing with height first now.

<mx:Canvas height="{(this.width / (4/3))}" width="100%">

ian News

Using recursion to perform an action on all DisplayObject children

September 18th, 2008

One of our animators recently handed me some Flash built training animations (SWF) that were to be viewed in our Flex shell. In this case we needed playback controls like pause, play, next, back and so on to work with these animations. The pause functionality in this case was problematic. Sometimes this just requires a simple stop() action but more often than not animators build animations that are comprised of many smaller MovieClip animations that are re-used quite a bit on the stage. Issuing a stop() on the root level MovieClip doesn’t stop all sub-timlines as they operate independently from the root timeline and doesn’t result in a true pause. You’ll need issue a stop on all children of the MovieClip in this case to freeze everything in its place.

You might have handled this same thing in AS2 using a for loop:

for (var m in this){
 
    if (typeof(this[mov]=="movieclip"){
        this[mov].stop();
    }
 
}

All in all this worked nicely as it could grab the full hierarchy of children. Unfortunately this no longer works in AS3. The closest thing to it would be a for loop using the number of children in a DisplayObject.

for (var i:uint = 0; i < mc.numChildren; i++){
     if (typeof(this[mov]=="movieclip"){	
         mc.getChildAt(i).stop();
     }
}

The problem with this is it only gets the direct children of the DisplayObject and none of their children’s children – and so on. However, we can fix that by wrapping it in a recursive function.

private function stopAllMovieClips(mc:*) : void {
 
	 	trace("Stop: ", mc.name);
 
		 if(mc is MovieClip) mc.stop();
 
		 for (var i:int = 0; i < mc.numChildren; i++) 
		 if (mc.getChildAt(i) is MovieClip){
                      stopMovieClip(mc.getChildAt(i));
                 }
 
}
 
stopAllMovieClips(this);

Notice that you can’t strongly type the argument for this function because you’ll come across a different class types when sifting through all children (Sprite, MovieClip, Graphic, etc). Of course MovieClip isn’t the only type of object this will work on and you aren’t limited to stop(). Any descendant of DisplayObject that has children or Flex Container is fair game here and you can perform nearly any action you want.

ian Flex

Per-corner cornerRadius controls on a Container

September 17th, 2008

Earlier today I needed a container with flat edges at the top and rounded edges at the bottom for something I was building. Unfortunately there isn’t a built in method to do this in Flex. Well, heres how. Create a new skin that extends the default HaloBorder skin and override its updateDisplayList.

package
{
 
	import flash.display.*;
	import flash.geom.*;
	import flash.utils.*;
 
	import mx.core.EdgeMetrics;
	import mx.skins.halo.HaloBorder;
	import mx.utils.ColorUtil;
	import mx.utils.GraphicsUtil;
 
	public class CustomCornerBorder extends HaloBorder 
	{
 
	public function TopicMenuPopupBorder() 
	{
		super(); 
 
	}
 
	override protected function updateDisplayList
(unscaledWidth:Number, unscaledHeight:Number):void{	
 
		var g:Graphics = graphics;
 
		super.updateDisplayList(unscaledWidth, unscaledHeight);
 
		var r:Number = getStyle("cornerRadius") as Number;
		if (!r) r = 0; 
 
		var bg:uint = getStyle("backgroundColor") as uint;
		if (!bg) bg = 0x000000;
 
		drawRoundRect(0,0, unscaledWidth,unscaledHeight, 
               { tl: 0, tr: 0, br: r, bl: r }, bg, 1);
 
	}
 
 
 
	}
}

If you take a peek in the Container class definition it uses a radius object to determine which sides are to be rounded. Unfortunately it doesn’t actually expose any of this to us developers. To add insult to injury there are no styles that correspond to the radius object so we have to hard code the desired radius values into our new border class like I’ve done above. If hard coding values isn’t your thing you could subclass your container and add a custom style in for this.

Lastly don’t forget to set the borderSkin property on your container for it all to work.

border-skin: ClassReference("com.proflightinc.view.skins.TopicMenuPopupBorder");

ian News

Ternary conditionals in MXML bindings

September 16th, 2008

Ok, I’m not sure how I missed this and if its common knowledge then forget I said anything, but I found out today that you can do this:

height="{ (dropDown.height > descriptorBox.height)
? (dropDown.height + 50) : (descriptorBox.height + 50) }” />

Doesn’t look like much but its a quick and dirty way to have conditional bindings without having to use a binding class or getter/setter method to handle the logic. Call me lazy, but I think this is pretty cool.

ian AS3.0, Flex, News

Apex MVC

September 13th, 2008

This is something I’ve been putting together for a little while now. Thus far I’ve just been using it for my own personal and professional projects but I think its got some very desirable features and needs to be shared. Its a truly lightweight MVC framework that basically aims to keep things as short and simple as possible.

Here’s the long description:

apex-mvc is an lightweight framework for those don’t want to bother with a complex MVC framework and still find other “lightweight” frameworks unnecessarily cumbersome. It gives you the ability to access a central data model, central services, and central events.

What is unique about about Apex is that it provides a single point of access to all central entities through the static “Apex” class. This allows you to quickly reference your central entities from anywhere without having to continually request instances.

Here are some other features of apex-mvc:

apex makes configuring services by allowing them to defined in MXML while still providing central access.

apex is designed in a way that is mindful of intellisense making it easy to see all central data and services from anywhere in your application.

apex is easy to learn and easy to use so that you can focus on developing your application without getting caught up on your MVC framework.

Its being hosted over at google code. View the project page here

ian News

I won a copy of Flex Builder 3!

April 14th, 2008
Comments Off

Actually this is a bit old news, but I won a raffle for Flex Builder 3 at the Adobe Flex Builder Pre-Release tour when it came to Philadelphia to the visit our PAFlex users group. It just recently showed up in the mail and really brightened my day. Big thanks to Adobe Developer relations for giving away free stuff, the Adobe reps that night (who’s names I forget unforuntately) and of course the PAFlex user group.Viagra users
Carvedilol
Canada xanax
Vidarabine
Loracarbef
Phentermine rx
Dyphylline
Famvir
Cycloserine
Asa
Cod online tramadol
Novobiocin
Phentermine sale
Granisetron
Phentermine for weight loss
Viagra sales online
Phentermine online
Difference between viagra and levivia
Buy cheap fioricet
Uk cheapest viagra
Tussionex
Online phentermine no prescription
Adipex phentermine prescription
Fenoldopam
Cheap tramadol without prescription
Fioricet medication
Which is better cialis or levitra
Xanax gg 258
Cheap soma online
Picture of generic xanax
Phentermine xenical diet pill
Metharbital
Phentermine cod overnight
Filing income tax tramadol
Celebrex
Cialis levivia viagra compare
Decadron
Herbal viagra alternatives
Generic viagra lowest prices
Addiction recovery xanax
Viagra usage
Best price on phentermine
Exelon
Discount phentermine free shipping
Is phentermine dangerous
Pediacare
Flunitrazepam
Cheapest phentermine free shipping
Piperacillin
Prochlorperazine
Pfizer xanax
Loprox
Xanax tablet
Lodine
Isoproterenol
Enoxaparin
Oxyphenbutazone
Thiabendazole
University rochester viagra pfizer
Viagra pulmonary hypertension
Discount pharmacy phentermine
On line phentermine
0 buy by popl powered viagra wordpress
Herbal online viagra
Tramadol narcotic
Oxycontin xanax bars per casettes and lortabs
Buy phentermine online cod
Phentermine and lexapro
Hyzaar
Atacand
Lowest prices on phentermine
Cephapirin
Levitra vs cialis vs viagra
Drug screen xanax
Ciprofloxacin
Effects from side viagra
Paregoric
Order phentermine online
Xanax
Nicotrol
Caffeine
Long term side effects of phentermine
Cialis in the uk
Generic viagra and generic drug
Order phentermine cod
Diet drug fenfluramine phentermine
Viagra pictures
Cheap viagra india
Herbal substitute viagra
Phentermine withdrawal symptoms
Dextromethorphan
Xanax cod
Betamethasone
Viagra testimonial
Clarithromycin
L arginine natural viagra
Phentermine online prescriptions
Female uk viagra
Timolol
Cialis levitra better
Viagra cialis levivia dose comparison
Rimantadine
Viagra lawsuits
Buy viagra canada
Long term effects of xanax
Xanax with same day delivery
Viagra sale uk
Phentermine without a prescription
120 cheap tramadol
Melphalan
Yohimbine
Chlordiazepoxide
Prozac drug interaction with xanax
On line doctor phentermine
Hetacillin
Overnight phentermine no prescription
Meperidine
Phentermine medical insert
Viagra sale
Capoten
Zyban
Epirubicin
Arthrotec
Ephedrine
Adipex diet discount phentermine pill
Cheapest viagra prices
Does viagra woman
Canadian online pharmacy xanax
Paramethadione
Extra cheap phentermine
Hyperalimentation
Xanax urine test
Buy generic phentermine
Order viagra now
Alteplase
Nizoral
Phentermine shipped to florida
Cheapest free shipping phentermine
Buy phentermine online prescription
Clomid
Order xanax online
Xanax drug testing
Xanax info
Digoxin
Strattera
Buy Vicodin
Ibuprofen
Sucralfate
Cephalexin
Order vicodin online

ian News

Influence 1.1

April 14th, 2008

Alright, spent a bit of time today updating my Influence theme for DokuWiki. Just a few changes, but well needed.

  1. Full page path now displays under the page/file name (You must enable displaying of full page paths in the configuration first)
  2. Changed active link colors to something more readable, this was pretty bad before.
  3. Some other minor style/design changes that you probably won’t notice anyway

I upgraded to dokuwiki-rc2008-04-11 and everything seems to be compatible.

Download Influence 1.1

ian News

Influence theme for DokuWiki

February 29th, 2008

Influence

Alright, it’s been a little while since my last post. I’ve been quite busy with work to say the least. Thankfully things have slowed down somewhat and I’m reclaiming some time in the evenings to play around with various things (hurrah!). Hopefully that means that I’ll be giving this blog a little more attention too.

I came across DokuWiki the other day when looking for a suitable open source Wiki for our development team here at work. It’s a light-weight Wiki built with development teams in mind (although, I would hardly say that it is limited to them). It also has a good number of plug-ins available. Traditionally I’ve been a Confluence user, but lets face it, its a bit more costly than what most small dev shops are willing to spend. I do, however, really like the look and feel of Confluence. So, yea, as you may have guessed I went ahead and made a theme thats loosely based on the default Confluence theme for everyone to enjoy.

A link, you say?

Influence 1.0b

A little disclaimer here, I’m not a CSS guru by any means (actually I find it quite irritating) so if you see something that seems pointless or redundant then you know why.

Will post updates as I make em’.

ian News

Using Dynamic DNS and Remote Desktop with Fios

October 23rd, 2007

So Fios is available in your area now and needless to say you’re psyched. When the Fios installation guys show up to your door they typically give you an Actiontec MI424WR router. They’ll stick around and help you get about as far as getting your machine connected to the internet (directly or through wireless), but thats about it. When my router was first set up I took some time to poke around in the admin utility. Sadly, Verizon has butchered the original admin utility that Actiontec provided in favor of their own fully branded utility. The problem with this is that the page load times are painfully slow, making it difficult to go in and change settings. While I was in there I took a moment to rename my router and wireless network after various mythical beasts (doesn’t everyone do this?) and set up a passkey for my wireless network. While I was in the process of doing this I stumbled upon a section for Dynamic DNS in the Advanced tab. Some modern day routers have built in functionality for synchronizing with dynamic DNS servers, and indeed the MI424WR supports this. This sort of thing can very nice if you want to remote desktop into your machine or if you want to run a production server from home (but keep in mind that port 80 is blocked by Verizon, so you’ll need to use 8080 or something else if you intend to do this). The problem, however, is that there are virtually no instructions on how to configure this, and having called Verizon to ask about it, it turns out it is only supported for those paying for business services.

After looking around on google for a while I managed to dig up the original manual for the straight from Actiontec (which seemed to have been hidden away purposely). Using this and trial and error I was able to get DDNS updating from the MI424WR. Heres what you’ll need to know:

The MI424WR only supports DDNS through dyndns.org. You’ll have to go create an account with them before doing anything else. Once you’re done make note of the dynamic domain that you created (mydomain.dyndns.org for example), your username and password. Now head over to the Advanced->Dynamic DNS section of the utility. You’ll see a screen that looks like this:

ddns.jpg

Heres what should go where:

    Connection to Update – This should be set to BroadBand connection Coax
    User Name – Your dyndns.org username
    Password – Your dyndns.org password
    Dynamic DNS System – Should be set to Dynamic DNS
    Host Name: Set this to the full host name that you created when making your dyndns.org account. It should be like something.dyndns.org, or something.dnsalias.com (dyndns.org provides a number of domains you can choose, these are just two)

Now hit Apply and then Update Now and you should be ready to go. It should report back “Updated – IP updated successfully” on the same screen. Now you should have working DDNS.

Now for the remote desktop setup. Right click on My Computer and go to properties. Look for the remote tab. Once you’ve found it make sure that the radio box for “Allow users to connect remotely to this computer” is checked. Thats all you need there, now back into the router utility. Click on the “Firewall Settings” icon, then on the left side click the “Port Forwarding” section. Now click add at the bottom. On the “Protocol” drop down menu here, select “Show All Services”. Now you should be able to open the same menu and select an option for “Remote Desktop”. Select it and hit Apply. The resulting screen should look something like this.

portforwarding.jpg

Hit Apply one more time. Thats it, you should now have a working Remote Desktop connection thats accessible through your own personal DDNS domain. Open up Remote Desktop Connection from another computer and connect to your personal dyndns.org domain that you specified earlier.

ian News

Flash Forward: Learning AS3 for designers

September 23rd, 2007

Lately a lot of designers have been asking me the what they can expect to be different in CS3 and AS3 where they are concerned. I took notes of the recent Flash Forward conference in wordpress, so I’ve decided to post this summation of Rich Shupe’s “Learning AS3 for designers” Panel.

I’m sititing in on the Flash forward panel AS3 for designers. I’m curious to see some of the new features in the Flash CS3 IDE where AS3 and designers are concerned, more specifically how designers can animate and bounce things down to AS3 for hand-off to a developer like myself.

Rich Shupe is the speaker for this panel.

General changes

Right now hes summarizing general things that have changed for designers in CS3, primarily the lack of the old onRelease and attachMovieClip/duplicateMovieClip methods.

Now he’s going over changes in scaling. _xscale and _yscale are depreciated in favor of scaleX and scaleY. Values are now 0 to 1 instead of 0 to 100.

Now he’s explaining that actionscript directly on stage objects is gone, and that this is a good thing. All stage objects in flash, if they are to have their own behavior, need to be tied to a MovieClip based class.

Now on to the document class. He’s creating and displaying a custom sprite based class for use on a library item.

Now he’s going over mandatory datatyping in AS3. Datatyping, where is a virtual machine or a compiler is concerned, is really going to work wonders for the performance of the binary applications you’re building.

Display list

He’s explaining how addChild adds items to the top of the display list stack, and thast removeChildAt(number) will remove anything at a specified depth.

Rich is also showing us how to:

Heres an awesome feature of AS3: Reparenting movie clips.
Dynamically creating shapes (although, we could do this in as2.0).

Events

Loading

Now Rich is going over the new URL Request loader in favor of the old loadMovie/MovieClipLoader or the old XML.load method.
He’s now touting a new feature where you can now stop the load process in AS3, and gain access to raw data while the load is in progress.

Sound

Rich is going over the additions to the sound API, primarily that you can now have a new sound channel for each sound object, which effectively gives you a lot more control over sounds Loading can be buffered via the SoundLoaderContext class. You can also access the global sound with the SoundMixer class. You can also compute waveform spectrums with the computeSpectrum method.

Rich had built a quick example of computeSpectrum and using a custoom visualization class to draw and is now showing a waveform analysis swf that he built which is quite impressive looking. He just swapped out the visualization class with something that makes use of the graphics API for a more complex visualization. that uses lines instead of dot sprites.

He’s closing with some books he’s authored, and were done

ian AS3.0, Flash