t-roy.net*
blog by designer troy ginbey
September 28, 2008 at 10:27 pm · Filed under CSS
With CSS, it’s possible to make the first element after another element look different to the rest. Lets say you have a title, and two paragraphs afterwards e.g.:
<h3>My Paragraph Title</h3>
<p>This is paragraph one.</p>
<p>This is paragraph two.</p>
To make the first paragraph after the title bold, you use what’s called an ‘adjacent sibling selector‘. This allows you to target an element which follows another element. In this case, the first p element follows an h3 element. To use CSS to say that you want the first p tag after an h3 tag to be set in bold, your code would look like this:
h3 + p {font-weight: bold;}
Now each time a p tag follows an h3 tag… it is set to bold. Nice.
September 28, 2008 at 9:59 pm · Filed under CSS
I’ve decided to add a new category to my blog - CSS. It’s been a topic I’ve wanted to write about for a while now, only if to learn a thing or two along the way. I’m going to cover all things to do with CSS - from Learning CSS, CSS techniques, Browser hacks and CSS best practices.
August 30, 2008 at 4:27 pm · Filed under General Rantings
Yep… They make you smarter, more interesting, and give you those good looking friends you see on commercials. I literally haven’t put it down since I walked out of the shop with it yesterday… Sorry Sarah! :)
July 16, 2008 at 10:25 am · Filed under Adobe Flash, General Rantings
This is pretty cool… being able to control your Flash movies from your HTML page through JavaScript.
To do this, you need to make use of Flash’s ExternalInterface (from Flash 8+)
Your flash code will look something like this:
import flash.external.ExternalInterface;
function stopVideoPlaying() {
myVideo.stop();
}
ExternalInterface.addCallback("stopVideoPlaying", this, stopVideoPlaying);
The first line imports the External Interface. The next is three lines is the function we want to call from our HTML page.
Finally, we add an addCallBack method, which, in order, defines the JavaScript function to listen for, the target, and the function to call when the callBack is received.
The JavaScript code will look like this:
window.onload = function() {
if(navigator.appName.indexOf("Microsoft") != -1) {
flash = window.swfVideo;
}else {
flash = window.document.swfVideo;
}
}
function stopFlashVideo() {
flash.stopVideoPlaying();
}
Then, to call the Javascript method, just make sure your Flash is given an id name of swfVideo, then call the JavaScript function stopFlashVideo.
May 25, 2008 at 12:21 pm · Filed under AS3.0 Fundamentals, Adobe Flash
Wow… every so often you stumble upon something that you know will change the way you design forever. I was flicking through the ACP (Adobe Certified Professional) Exam Guide for Flash CS3 (as you do on a Sunday), and came across something I didn’t recognise - scale9Grid.
scale9Grid divides a display object into 9 regions, allowing different rules to be applied to it when the object is scaled.
How is this useful?? Well.. think about designing a simple content area with rounded corners. You want the content area scale vertically as the amount of text it holds increases. With any normal object with rounded corners, as you scale it’s height, the corners would scale and distort the more it is verticaly scaled. Enter scale9Grid. With one line of code, you can define the regions of the rounded rectangle to allow for distortion free scaling… Here’s an example:
myRoundedRectangle.scale9Grid = new Rectangle(10,10,300,600);
The above code adds a scale9Grid to a rounded rectangle object - meaning when it is scaled, the rounded corners will stay the same…. Brilliant!
May 22, 2008 at 10:30 am · Filed under AS3.0 Fundamentals, Adobe Flash
I’ve been using Array for a while now - but don’t frequently use all of it’s methods… so I’m going to go through the ones I don’t use a lot….
Array.sort();
var beers:Array = ["Fosters", "Alpha", "VB", "Asahi"];
beers.sort(); // default sort
trace(beers); // output: Angelou,Blake,Dante,cummings
beers.sort(Array.CASEINSENSITIVE);
trace(beers); // output: Alpha,asahi,Fosters,VB
beers.sort(Array.DESCENDING);
trace(beers); // output: asahi,VB,Fosters,Alpha
beers.sort(Array.DESCENDING | Array.CASEINSENSITIVE);
trace(beers); // output: VB,Fosters,asahi,Alpha
May 21, 2008 at 3:33 pm · Filed under AS3.0 Fundamentals, Adobe Flash
package {
import flash.display.*;
import flash.text.TextField;
public class AS3Tester extends Sprite {
public function AS3Tester() {
var myTextContainer:TextField = new TextField();
myTextContainer.text = "I like beer";
this.addChild(myTextContainer);
}
}
}
In the above code, I create a variable to reference a new TextField object, and set it’s text to “I like beer”. This alone wont add the TextField to the stage. To do this I then need to use the addChild method to add it to the display list:
addChild(child:DisplayObject):DisplayObject
addChild is a method of DisplayObjectContainer. When a DisplayObjectContainer (a Sprite, a Loader or the Stage) calls the addChild method, it adds a child DisplayObject instance to that DisplayObjectContainer instance.
To remove an object from the display list is the reverse:
removeChild(child:DisplayObject):DisplayObject
So the code to remove the TexField above would be:
this.removeChild(myTextContainer);
If I wanted to add a display object instance to a specific DisplayObjectContainer instance, I use addChildAt:
addChildAt(child:DisplayObject, index:int):DisplayObject
Here’s an example of the code in use:
var myDisplayContainer:Sprite = new Sprite();
var myFirstSprite:Sprite = new Sprite();
var mySecondSprite:Sprite = new Sprite();
myDisplayContainer.addChild(myFirstSprite);
myDisplayContainer.addChildAt(mySecondSprite, 0);
this.addChild(myDisplayContainer);
The above code first creates a DisplayObjectContainer called myDisplayContainer, then adds a Sprite (myFirstSprite) to it. Then using addChildAt, a second sprite is added to myDisplayContainer at index 0, which is the back of the list - meaning it will be displayed underneath myFirstSprite.
The final line adds the myDisplayContainer to the stage.
May 20, 2008 at 9:43 am · Filed under AS3.0 Fundamentals, Adobe Flash
Display List programming is a big part of ActionScript 3.0… Basically anything that is visually added to the stage must be added to Flash’s Display List hierarchy.
In the next few posts I’m going to go through a few core display programming tasks…
- Adding display objects to the display list
- Removing objects from the display list
- Moving objects among display containers
- Moving objects in front of or behind other objects
May 18, 2008 at 7:01 pm · Filed under AS3.0 Fundamentals
An XMLList is a great object for working with one or more XML elements. You can call methods on the elements as a group or on the individual elements in the collection. In the example below, I’ve created an XML List to store all beers from the beers XML object that have the brand “fosters”:
beers:XML = XML;
showBeersByBrand("alpha");
private function showBeersByBrand(name:String):void {
var results:XMLList = beers.beer.(@brand == name);
showList(results);
}
private function showList(list:XMLList):void {
var item:XML;
for each(item in list) {
trace("item: " + item.toXMLString());
}
}
Next entries »