Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

AS3 Code Examples In Flash

New Here ,
Jan 06, 2008 Jan 06, 2008
Here's The Accessibilty Code Example:

package {
import flash.display.Sprite;
import flash.accessibility.Accessibility;
import flash.utils.setTimeout;

public class AccessibilityExample extends Sprite {
public static const BUTTON_WIDTH:uint = 90;
public static const BUTTON_HEIGHT:uint = 20;

private var gutter:uint = 5;
private var menuLabels:Array = new Array("PROJECTS", "PORTFOLIO", "CONTACT");
private var menuDescriptions:Array = new Array("Learn more about our projects"
, "See our portfolio"
, "Get in touch with our team");

public function AccessibilityExample() {
configureAssets();
setTimeout(updateAccessibility, 2000);
}

private function updateAccessibility():void {
trace("Accessibility.active: " + Accessibility.active);
if(Accessibility.active) {
Accessibility.updateProperties();
}
}

private function configureAssets():void {
var child:CustomAccessibleButton;
for(var i:uint; i < menuLabels.length; i++) {
child = new CustomAccessibleButton();
child.y = (numChildren * (BUTTON_HEIGHT + gutter));
child.setLabel(menuLabels );
child.setDescription(menuDescriptions
);
addChild(child);
}
}
}
}

import flash.accessibility.AccessibilityProperties;
import flash.display.Shape;
import flash.display.SimpleButton;
import flash.display.Sprite;
import flash.events.Event;
import flash.text.TextFormat;
import flash.text.TextField;


class CustomAccessibleButton extends Sprite {
private var button:SimpleButton;
private var label:TextField;
private var description:String;
private var _name:String;

public function CustomAccessibleButton(_width:uint = 0, _height:uint = 0) {
_width = (_width == 0) ? AccessibilityExample.BUTTON_WIDTH : _width;
_height = (_height == 0) ? AccessibilityExample.BUTTON_HEIGHT : _height;

button = buildButton(_width, _height);
label = buildLabel(_width, _height);

addEventListener(Event.ADDED, addedHandler);
}

private function addedHandler(event:Event):void {
trace("addedHandler: " + this._name);
var accessProps:AccessibilityProperties = new AccessibilityProperties();
accessProps.name = this._name;
accessProps.description = description;
accessibilityProperties = accessProps;
removeEventListener(Event.ADDED, addedHandler);
}

private function buildButton(_width:uint, _height:uint):SimpleButton {
var child:SimpleButton = new CustomSimpleButton(_width, _height);
addChild(child);
return child;
}

private function buildLabel(_width:uint, _height:uint):TextField {
var format:TextFormat = new TextFormat();
format.font = "Verdana";
format.size = 11;
format.color = 0xFFFFFF;
format.align = TextFormatAlign.CENTER;
format.bold = true;

var child:TextField = new TextField();
child.y = 1;
child.width = _width;
child.height = _height;
child.selectable = false;
child.defaultTextFormat = format;
child.mouseEnabled = false;

addChild(child);
return child;
}

public function setLabel(text:String):void {
label.text = text;
this._name = text;
}

public function setDescription(text:String):void {
description = text;
}
}

class CustomSimpleButton extends SimpleButton {
private var upColor:uint = 0xFFCC00;
private var overColor:uint = 0xCCFF00;
private var downColor:uint = 0x00CCFF;

public function CustomSimpleButton(_width:uint, _height:uint) {
downState = new ButtonDisplayState(downColor, _width, _height);
overState = new ButtonDisplayState(overColor, _width, _height);
upState = new ButtonDisplayState(upColor, _width, _height);
hitTestState = new ButtonDisplayState(upColor, _width, _height);
useHandCursor = true;
}
}

class ButtonDisplayState extends Shape {
private var bgColor:uint;
private var _width:uint;
private var _height:uint;

public function ButtonDisplayState(bgColor:uint, _width:uint, _height:uint) {
this.bgColor = bgColor;
this._width = _width;
this._height = _height;
draw();
}

private function draw():void {
graphics.beginFill(bgColor);
graphics.drawRect(0, 0, _width, _height);
graphics.endFill();
}
}
TOPICS
ActionScript
969
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 06, 2008 Jan 06, 2008
LATEST
:

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines