All A-grade browsers support the .png file format. However, IE6 does not support .png’s with transparency (or alpha channel). Microsoft has provided developers with a number of ‘filters’ that add functionality to IE and the one we are after to solve the .png transparency problem is called the AlphaImageLoader. Documentation can be found here: http://msdn.microsoft.com/en-us/library/ms532969(VS.85).aspx
Implementation of AlphaImageLoader is fairly straightforward. It can only be applied to background images. And it’s usage injects a new, psuedo element into the DOM to display the .png, and introduces a few peculiarities to watch out for along the way.
The link to the image asset in your stylesheet must be relative to the document rather than relative to the stylesheet. Using root-relative links sitewide resolves confusion that may come out of this.
element {
background-image:none;
filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='/path/to/asset.png');
}
AlphaImageLoader takes three arguments:
enabled= true or false – default is true, false seems useless
sizingMethod= image, crop or stretch – default is image, this will adjust the size of your element to fit the image. Crop and Stretch are much more useful, as your element will retain its dimensions. Crop clips the image to fit the dimensions of the element. Stretch stretches or shrinks the image to fill the borders of the element.
src= ‘/path/to/asset.png’
‘background’ Note that the background in the sample above is set to ‘none’. Because the AlphaImageLoader is introducing a new element behind the actual element it is applied to, we have to set ‘background:none’ or the original, unfixed .png will sit in front of the fixed one.
‘background-position’ does not work. So your background will always cling to top, left. This is problematic when creating sprites whose states are displayed by shifting the background-position on :hover.
‘background-repeat’ does not work. So the common practice of repeating a small slice of an image to cover the entire background of an HTML element will not work either. In many situations, the ‘strech’ attribute of the ‘sizingMethod’ argument can stand in for a graphic that needs to repeat along and x or y axis.
Elements with AlphaImageLoader applied must hasLayout. Give it a width and/or height. See this article for more info: http://www.satzansatz.de/cssd/onhavinglayout.html
Another oddity it introduces is with clickable elements. They aren’t clickable anymore. Giving and element ‘position:relative’ will allow you to regain functionality, but can cause other issues if the AlphaImageLoader is applied to an element that requires absolute positioning. One workaround would be to add in extra containing markup.
In order to deal with .png’s in an img tag, we need to wrap the image in a span (or other element), apply a background to the span, apply AlphaImageLoader to the span’s background, and finally tell the img be transparent.
HTML for img tag
<span id="png-example" class="pngwrapper">
<img width="150" height="150" alt="Png Example" src="/path/to/asset.png" />
</span>
CSS for img tag
.pngwrapper img {
filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);
}
#png-example {
filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/path/to/asset.png');
}
Two widely used javascript solutions exist that automate the process outlined above. They can be found at: http://homepage.ntlworld.com/bobosola/pnghowto.htm and http://labs.unitinteractive.com/unitpngfix.php
The benefit of using either of the above solutions is that they evaluate your document and automatically apply AlphaImageLoader where appropriate. This can be an ideal solution for situations where the developer cannot predict when a .png will be used, like in a CMS situation.
The downside is that you are traversing the entire DOM in order to find all instances of .png usage, then applying the AlphaImageLoader to each. Since this is a fix solely for IE6, and IE6 is full of memory management problems, this can really be a drain on resources, especially in applications already employing large amounts of javascript.
Both these fixes will apply ‘position:relative’ to the element with the .png … and any child element. This is can be problematic and can produce unexpected results.
Because we only need to fix transparency for IE6, it is good practice to employ another IE specific option. Conditional comments: http://msdn.microsoft.com/en-us/library/ms537512(VS.85).aspx. Put all CSS into an IE specific style sheet, the CSS ‘filter’, needed to use AlphaImageLoader is not valid CSS.
<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href="/css/ltIE7.css" />
<![endif]-->
The code above will target only Internet Explorer versions lower than 7. Use a similar comment to include script blocks intended only for IE6.
When using .png’s to make create structural elements– containers with transparent backgrounds, rounded corners, etc. –I prefer to target those .png’s manually using CSS. This is less taxing on the browser and introduces fewer inconsistencies. In some situations this isn’t possible and one has to rely on a javascript application of AlphaImageLoader. Either javascript option can be limited to certain elements of the DOM, and if possible, it is preferrable to not just apply pngFix.js to the entire document.
In a lot of situations where using a .png might be the preferable option, some clever rearranging of your markup may allow you to use a .jpg instead. Also a bit of Photoshop trickery may allow you to use a .gif. If there is no perceived visual difference, do it. In addition to a laundry list of issues that .png’s introduce for the developer, they add a great deal of weight to the page and can impede performance in that regard. There are not a lot of compression options for .png’s, and the ones that are out there simply strip the extra header information off the file. Here is a drag and drop .png ‘optimizer’: http://www.leveltendesign.com/blog/nickc/pngthing-v11-previously-pngoptimizer
I started a little project over at http://code.google.com/p/allyourbase/. It is an upgraded and cleaned up version of my baseline.css file. There are also a few handy javascript classes that make use of YUI. Have at it, I hope you find it useful.
Technologies: CSS, HTML, Javascript, Actionscript
Frameworks: MooTools
Link: bauer.com
Technologies: CSS, HTML, Javascript
Frameworks: Dojo
Notes: Progressively enhanced, standards based AJAX front end experience
Link: lee.com
Work <- -> Hobby <- -> Passion
Concepts > Software
Be master of tool or instrument (specialist) or creative user of that tool
Eye of the Tiger with iPhone v Flash player. Good way to start a code heavy session first thing in the morning. Up to late to really try to comprehend much of this. Will be a good session to watch back.
-It was good to have examples of things in the SDK and their analog in the Flash IDE. Example: Create an image view. Put a .png in it. Similar to creating a movie clip and placing a library item in it.
-All class have a .h and a .m file. .h contains vars while .m contains executable code that relies on the .h file.
Scripter -> Developer -> Architect
Reactive -> Proactive -> Pragmatic
Developter is proactive. Architect not focused solely on completion, more about reason and problem solving.
In development there are lots of wrong answers. Lots of really wrong answers. No right answers. Eventually learn to bend rules to solve problems creatively.
Why have coding standards? Consistent both internally and externally Consistent within your own work as well as the community as a whole. Standardized code tends to be self documenting.
Events vs. Method calls. Events don’t rely on other bits of code. They simply broadcast. Something else may or may not be listening. Doesn’t break due to dependancy. Try to absract external dependencies. When something changes, make adjustments to the connection rather than the funcitonality.
Build isolated test cases and integrate when stable. Set micro-deadlines.
Design -> UX <- Developmet
Thoughts:
Really a great roundup of best practices and ways to think about working. It’s nice to have this information collected in one presentation. Made me proud to be part of a development team that implements most if not all of these techniques on some level.
Exactly as advertised. Maybe could have been call Very Cool Shit or Super Cool Shit.
sourcebinder.org – coupon code SBFITC
Whatever babbles bubbles up. Neat flash/twitter integration aviary.com
Papervision X running Quake … Clay surface … Reflective surface … Sphere with water surface.
Open frameworks – talking to illustrator and moving objects on a live .ai file in realtime to music … similar, iTunes audio controlling view of data in Maya. vimeo.com/drwoohoo
Awesome session! Lots of practical information. Full code samples. fitc.sisutastic.com
Commercial web apps using Drupal: The Onion, Infoworld, Fast Company, Nonesuch
-SEO! Publish views for Flash and Static HTML. Able to publish for multiple front ends.
3 systems:
-Create a view for dynamic embed of flashvars
-Create an HTML view and consume that content into Flash (parse as XHTML or XML)
-Create native actionscript objects with AMFPHP. Small, Fast. This connection allows for 2 way communication; writing in to the Drupal CMS
Modules:
-Services Module (AMFPHP gateway) (Also can create JSON object, good if one wanted to create an AJAX version of the same content)
-CCK Module – expands on properties available when createing a content object
-Views Module – What we use to create our data object
-SWF Address Module (optional)
-Admin Menu (optional)
-Also need to get Core Lib from Adobe
In Drupal a ‘node’ is the native content object, a view is a filtered collection of these objects. AMFPHP is the data gateway; requests will go to /services/amfphp with query string. In Flash we need to import net.responder, net.netconnection, net.objectencoding. AMFPHP returns a native Flash object.
-sidenote: was not familiar with setting breakpoints in actionscript and using that to run code only to a specified point in the debug player.
-create encoded keys in Drupal to authenticate session information.
-use a singleton class to store session information and call public methods.
Thoughts:
Admittedly I am a fan of open-source, off the shelf solutions. I love wordpress, and we have scratched the surface of flash integration in WordPress themes. The interesting thing about Drupal integration, is that we can use it solely as a CMS and easily create custom data objects with the views module and package them in a native Flash object. Increases speed of retrieving data, no need to transform PHP and HTML into a format that is easily parsed by Flash. Also allow creation of a variety of front-end interfaces. Create data views for flashy Flash front-end, Static HTML pages for SEO, and HTML and JSON versions for non-flash, but still rich browser based experiences like iPhone all from the same data source, and all in a very user friendly admin back-end.
-Tailor message for the audience you want
-Shape your image
-Create a following of ambassadors
-Define your mantra
-Know what your real product is (it isn’t your skills)
Speaker posted slides, the rest of my notes are kind of pointless.
Thoughts:
Great speaker in general. Techniques outlined are useful, I suppose for anyone on an individual level, but also within a larger organization where you have departments that rely on each other for clear communication.