Hi,
I’m creating a component that places symbols on the stage based on text input by the flash author. The component behaves as expected when the swf is published, but doesn’t update in flash authoring when the data is changed in the component inspector. Live preview in the control tab is checked.
The component functioned as expected until a couple of days ago, and I can’t for the life of me see what I may have changed to cause it to stop functioning.
I’m not a programmer, and this is my first component. They are extremely useful to me and I’d like to make more, but I’m stymied. Before directing me to a tutorial: I’ve gone through all of the documentation I can find, including the famed MenuBar tutorial.
Will someone please take a look at the code and offer suggestions:
package {
import flash.display.;
import flash.text.;
import flash.filters.;
import flash.utils.;
import flash.events.*;
//=============================================================================
//=============================================================================
//
//=============================================================================
//=============================================================================
public class my_Component extends Sprite {
private var symbolType = "background1";
private var symbolState = "active";
private static const STAGE_WIDTH = 39.9;
private static const STAGE_HEIGHT = 39.2;
private var x_centerPoint = STAGE_WIDTH/2;
private var upperChar_y = STAGE_HEIGHT/2-7;
private var lowerChar_y = STAGE_HEIGHT/2+7;
public function my_Component() {
init();
draw();
setSize();
}
//
private function init():void {
scaleX = 1;
scaleY = 1;
}
//
protected function draw():void {
removeObjects();
placeBackgroundSymbol(symbolType,symbolState);
placeChar(myName,upperChar_y);
placeChar(myNumber,lowerChar_y);
}
public function setSize():void {
width = STAGE_WIDTH;
height = STAGE_HEIGHT;
draw();
}
private var _myName:String = "Max";
[Inspectable (name = "Name", type = String, defaultValue="Max")]
public function set myName(inputName:String):void {
if(isValid_name(inputName)) {
trace("set1");
_Name = inputName;
draw();
}
else {
trace("not a valid name");
}
}
public function get myName():String {
trace("get1");
return _myName;
}
private function isValid_name(inputTagName:String):Boolean
{
return true;
}
private var _myNumber:String = "1234";
[Inspectable (name = "Number", type = String, defaultValue="1234")]
public function set myNumber(inputNumber:String):void {
if(isValid_number(inputNumber)) {
trace("set2");
_myNumber = inputNumber;
draw();
}
else {
trace("not a valid number");
}
}
public function get myNumber():String {
trace("get2");
return _myNumber;
}
private function isValid_number(inputTagNumber:String):Boolean
{
return true;
}
//
private function placeBackgroundSymbol(backgroundSymbol,backgroundState) {
var myBackground:MovieClip = new libraryObject1();
myBackground.x = STAGE_WIDTH/2;
myBackground.y = STAGE_HEIGHT/2;
this.addChildAt(myBackground,1);
myBackground.gotoAndStop(backgroundState);
}
private function placeChar(my_chars,char_y_loc) {
var numChar = my_chars.length;
var myCharArray:Array = my_chars.split("");
for (var i:Number = 0; i < numChar; i++) {
tagCharArray* = "text_" + myCharArray*;
var char:MovieClip = new _control_characters();
var bias = 6*((i+1/2) - (numChar/2));
this.addChild(char);
char.gotoAndStop(myCharArray*);
char.x = x_centerPoint + bias;
char.y = char_y_loc;
}
}
public function removeObjects():void {
while (this.numChildren>1) {
trace("current object: " + this.getChildAt(1));
removeChildAt(1);
}
}
}
}// end package