Quote:
|
Originally Posted by d*d
how much of different animal is AS3 to AS2?
|
alot of it is different, though if youre familiar with as2 it should be easy to migrate to as3...
biggest change is probably the document classes.
have a looksie at what ive just coded today:
package folder {
import flash.display.*;
import flash.events.*;
import flash.text.*;
public class PhotoPanel extends Sprite {
private static const defaultTitle:String = "Photo Viewer [No Photo Selected]";
private static const defaultPhotoName:String = "Enter Photo Name Here";
private var title:TextField;
private var photoname:TextField;
public function PhotoPanel() {
title = new TextField();
title.text = PhotoPanel.defaultTitle;
title.width = 350;
title.height = 25;
title.border = true;
title.background = true;
title.selectable = false;
addChild(title);
photoname = new TextField();
photoname.text = PhotoPanel.defaultPhotoName;
photoname.width = 150;
photoname.height = 30;
photoname.x = 100;
photoname.y = 150;
photoname.border = true;
photoname.background = true;
photoname.type = TextFieldType.INPUT;
addChild(photoname);
photoname.addEventListener(Event.CHANGE, changeListener);
photoname.addEventListener(FocusEvent.FOCUS_IN, photoFocusInListener);
photoname.addEventListener(FocusEvent.FOCUS_OUT, photoFocusOutListener);
stage.addEventListener(FocusEvent.FOCUS_OUT, panelFocusOutListener);
}
private function changeListener(e:Event):void {
if(photoname.text.length == 0) {
title.text = "Photo Viewer [Unnamed Photo]";
} else {
title.text = "Photo Viewer [" + photoname.text + "]";
}
private function photoFocusInListener(e:FocusEvent):void {
if(photoname.text == PhotoPanel.defaultPhotoName) {
photoname.text = "";
title.text = "Photo Viewer [Unnamed Photo]";
} else {
title.text = "Photo Viewer [" + photoname.text + "]";
}
}
private function photoFocusOutListener(e:FocusEvent):void {
if(photoname.text.length == 0) {
photoname.text = PhotoPanel.defaultPhotoName;
}
}
private function panelFocusOutListener(e:FocusEvent):void {
if(e.relatedObject == null) {
title.text = PhotoPanel.defaultTitle
}
}
}// function
}// sprite
}//package