Notes

Notes: CSS StyleSheets

Friday, January 16th, 2009 | Notes | No Comments

Note: A text field with a style sheet is not editable. In other words, a text field with the type property set to TextFieldType.INPUT applies the StyleSheet to the default text for the text field, but the content will no longer be editable by the user. Consider using the TextFormat class to assign styles to input text fields.

Flash Player supports a subset of properties in the original CSS1 specification (www.w3.org/TR/REC-CSS1). The following table shows the supported Cascading Style Sheet (CSS) properties and values, as well as their corresponding ActionScript property names. (Each ActionScript property name is derived from the corresponding CSS property name; if the name contains a hyphen, the hyphen is omitted and the subsequent character is capitalized.)

› Continue reading

Tags: ,

Notes: HTMLText

Friday, January 16th, 2009 | Notes | 4 Comments

This is the first of hopefully a series of posts of useful things I want accessible on my blog. Mostly for my own benefit but anyone else is free to use this as an easy reference for AS3.

Flash Player supports the following HTML tags:

Anchor tag

The <a> tag creates a hypertext link and supports the following attributes:

  • target: Specifies the name of the target window where you load the page. Options include _self, _blank, _parent, and _top. The _self option specifies the current frame in the current window, _blank specifies a new window, _parent specifies the parent of the current frame, and _top specifies the top-level frame in the current window.
  • href: Specifies a URL or an ActionScript link event.The URL can be either absolute or relative to the location of the SWF file that is loading the page. An example of an absolute reference to a URL is http://www.adobe.com; an example of a relative reference is /index.html. Absolute URLs must be prefixed with http://; otherwise, Flash treats them as relative URLs.

    You can use the link event to cause the link to execute an ActionScript function in a SWF file instead of opening a URL. To specify a link event, use the event scheme instead of the http scheme in your href attribute. An example is href="event:myText" instead of href="http://myURL"; when the user clicks a hypertext link that contains the event scheme, the text field dispatches a link TextEvent with its text property set to “myText“. You can then create an ActionScript function that executes whenever the link TextEvent is dispatched. You can also define a:link, a:hover, and a:active styles for anchor tags by using style sheets.

	var style:StyleSheet = new StyleSheet();

	var link:Object = new Object();
	link.fontWeight = "bold";
	link.color = "#FF0000";

	var hover:Object = new Object();
	hover.fontStyle = "italic";

	var active:Object = new Object();
	active.fontStyle = "italic";
	active.color = "#FFFF00";

	style.setStyle("a:link", link);
	style.setStyle("a:hover", hover);
	style.setStyle("a:active", active);

	var txt:TextField = new TextField();
	txt.width = 400;
	txt.styleSheet = style;
	txt.htmlText = "Visit: <a href='www.google.com' target='_blank'>Google.com</a> or call a <a href='event:link1'>function</a>";
	txt.addEventListener(TextEvent.LINK, linkHandler);
	addChild(txt);

	function linkHandler(event:TextEvent):void {
		if(event.text == "link1") {
			trace("hello!");
		}
	}
	

› Continue reading

Tags:

Search