flash actionscript:
I am trying to script a database editing module for my flash app. I have one
already I made on the stage but I would rather have it all actionscript. The
editor is just a set of forms which are selected with a comboBox and call asp
pages.
On the stage I just have set frames which are called by switching the comboBox
selection. If I script it I cant use this method but I could have 5 or 6 forms
all stacked and either swith depths or turn on and off visbility.
The script below has the comboBox and majority of the movie clip. The problem
is I am having trouble manipulating even the first form let alone a set of
forms. I really just need to suffle through them like a jukebox or pages in a
book. I dont know how to target the movieclips properly whill turning the
unselected ones on and off.
My first hurdle is trying to target the form from the switch event handler.
////////////////////////////////////variables///////////////////////////////////
//////
stageHeigth = 400;
stageWidth = 320;
dragBarHeight = (stageHeigth-1)/15;
winWidth = 4*dragBarHeight;
winHeight = 8*dragBarHeight;
barText = "Control";
fillColorOne = 0xffff99;
fillColorTwo = 0xffffff;
fillColorThree = 0xffffff;
lineColorOne = 0x0000000;
fDepth = 5000;
fullAlpha = 100;
////////////////////////////////////variables///////////////////////////////////
//////
//Create the root movieClip
createWin = function (WinName) {
_root.createEmptyMovieClip(WinName, fDepth++);
// initial place on screen, upper right conner
_root[WinName]._x = 0;
_root[WinName]._y = 0;
// draw box
_root[WinName].clear();
_root[WinName].lineStyle(1, lineColorOne, fullAlpha);
_root[WinName].beginFill(fillColorOne, fullAlpha);
_root[WinName].moveTo(0, 0);
_root[WinName].lineTo(stageWidth-1, 0);
_root[WinName].lineTo(stageWidth-1, stageHeigth-1);
_root[WinName].lineTo(0, stageHeigth-1);
_root[WinName].lineTo(0, 0);
_root[WinName].endFill();
initializeEditWin.apply(_root[WinName]);
};
initializeEditWin = function(){
this.createObject("ComboBox", "naviComboBox", fDepth++);
this.naviComboBox._x = 10;
this.naviComboBox._y = 35;
this.naviComboBox.setSize(300);
this.naviComboBox.dataProvider = [{label: "Modify Selected Node", data:
defaultValue}, {label: " Edit Node Information", data: "form1"},
{label: " Add New Node", data: "form2"},{label: " Add Library Node",
data: "form3"},{label: " Add Template Nodes", data: "form4"},
{label: " Delete Node(s)", data: "form5"},{label: "TEMPLATES", data:
"form0"},{label: " Delete a Template", data: "form6"},
{label: " Create a Template", data: "form7"}, {label: "ADD This Node to
the Library", data: "form8"}];
this.naviComboBox.addEventListener("change", onChange);
this.createBar = function() {
this.createEmptyMovieClip("dragBar", fDepth++);
this.dragBar.clear();
this.dragBar.lineStyle(1, 0x0000000, 100);
this.dragBar.beginFill(0xff9900, 100);
this.dragBar.moveTo(0, 0);
this.dragBar.lineTo(stageWidth-1, 0);
this.dragBar.lineTo(stageWidth-1, dragBarHeight);
this.dragBar.lineTo(0, dragBarHeight);
this.dragBar.lineTo(0, 0);
this.dragBar.endFill();
this.createTextField("dragBar_txt", fDepth++, 0, 3, stageWidth,
dragBarHeight);
this.dragBar_txt.embedFonts = false;
this.dragBar_txt.selectable = false;
this.dragBar_txt.text = barText;
format = new TextFormat();
format.font = "Arial";
format.align = "center";
format.bold = true;
format.size = "16";
this.dragBar_txt.setTextFormat(format);
// Drag bar
this.dragBar.onPress = function () {
_global.infoDrag = true;
leftX = nodeHeight + winWidth/2;
topY = nodeHeight + dragBarHeight/2;
rightX = StageWidth - nodeHeight - winWidth/2;
bottomY = StageHeight - winHeight - nodeHeight - 5*dragBarHeight;
// drag parent, bar will follow
this._parent.startDrag(true, leftX, topY, rightX, bottomY);
this._parent._alpha=60;
};
// end bar drag
this.dragBar.onRelease = function () {
_global.infoDrag = false;
this._parent.stopDrag();
this._parent._alpha=100;
};
this.dragBar.onReleaseOutside = function () {
_global.infoDrag = false;
this._parent.stopDrag();
this._parent._alpha=100;
};
};
this.createEditNodeForm = function() {
this.createEmptyMovieClip("editNodeForm", fDepth++);
this.editNodeForm.clear();
this.editNodeForm.lineStyle(1, 0x0000000, 100);
this.editNodeForm.beginFill(fillColorThree, 100);
this.editNodeForm.moveTo(10, 75);
this.editNodeForm.lineTo(stageWidth-10, 75);
this.editNodeForm.lineTo(stageWidth-10, stageHeigth - 10);
this.editNodeForm.lineTo(10, stageHeigth - 10);
this.editNodeForm.lineTo(10, 75);
this.editNodeForm.endFill();
this.editNodeForm._visible = true;
};
this.createBar();
this.createEditNodeForm();
function onChange(){
var selectedForm = this.getValue();
trace(selectedForm);
switch(selectedForm){
case "form1":
trace("hello")
editNodeForm._visible = false;
break;
case "form2":
trace("googdbye")
break;
default:
trace ("form0");
break;
}
}
};
createWin("edit_mc");