flashape
06-07-2003, 01:10 AM
I had made some components that worked exactly how i wanted them to. Then I started reading about #initclip/#endinitclip and Object.registerClass, so I wanted to try and code my component in that style. I noticed on Macromedia's site they have this tutorial (macromedia.com/support/flash/applications/creating_comps/index.html)which doesnt mention anything about any of that stuff.
So the problem I am having now is that the component has these panels that are supposed to animate as soon as the component becomes visible on the stage...and apparently if i put the code inside the #init/#endinit block you never see it eanimating. I also just tried to call the class's method from a a regular frame action but its still not working.
Here is the code...most of it is jsut one long function to animate the panels. I'm sure the code is a bit screwed up now, I have been trying everything. If someone could help me out and point me in the right direction I'd appreciate it.
#initclip
function ActionComponentClass(){
this.init();
}
ActionComponentClass.prototype = new MovieClip();
//initialize the component
ActionComponentClass.prototype.init = function (){
/* COMPONENT PARAMETERS
actionText_param
*/
//hide the text box
this.actionText_txt._visible = false;
//the text that shows on the panel
this.actionText_txt = this.actionText_param;
}
ActionComponentClass.prototype.expandPanel = function (){
//****************
//setting up the text area
//****************
//allow html text in text field
actionText_txt.html = true;
//set the text field text
//defined in properties panel
actionText_txt.htmlText = '<P ALIGN = "CENTER">' + this.actionText;
//make the text box autosize
actionText_txt.autoSize = "center";
actionText_txt._width = 185;
//resize the middle panel to fit the entire text field
panelMid_mc._height = (actionText_txt._height);
//***************
//animating the panel
//***************
//hide the arrow until scaling is finished
cornerArrow_mc._visible = false;
//grab the current y scale fo the middle panel, before we shrink it down
finishYscale = panelMid_mc._yscale;
//grab the x and y scale for the ! mc too
circleFinishY = (cornerArrow_mc._yscale - 90);
circleFinishX = cornerArrow_mc._xscale;
//shrink the panels to 1 pixel...
cornerArrow_mc._xscale = cornerArrow_mc._yscale = 1;
panelTop_mc._xscale = panelTop_mc._yscale = 1;
panelMid_mc._xscale = panelMid_mc._yscale = 1;
panelBottom_mc._xscale = panelBottom_mc._yscale = 1;
actionText_txt._visible = false;
//...scale them back up
speed = 20;
panelTop_mc.onEnterFrame = function() {
if (this._yscale < 101) {
this._yscale = this._xscale += speed;
} else {
delete this.onEnterFrame;
}
};
panelMid_mc.onEnterFrame = function() {
this._y = (panelTop_mc._y + panelTop_mc._height) - 1.5;
if (this._xscale < 101){
this._xscale += speed;
}
if (this._yscale < finishYscale) {
this._yscale += 50;
} else {
if (this._yscale > 98 && this._xscale > 98){
actionText_txt._visible = true;
placeArrow();
cornerArrow_mc._visible = true;
}
}
};
panelBottom_mc.onEnterFrame = function() {
this._y = (panelMid_mc._y + panelMid_mc._height) - .5;
if (this._yscale < 101) {
this._yscale = this._xscale += speed;
}
};
cornerArrow_mc.onEnterFrame = function(){
if (this._xscale < circleFinishX){
this._xscale += 10;
this._yscale +=8;
}
}
}
Object.registerClass("FActionComponentSymbol", ActionComponentClass);
#endinitclip
ActionComponentClass.expandPanel();
So the problem I am having now is that the component has these panels that are supposed to animate as soon as the component becomes visible on the stage...and apparently if i put the code inside the #init/#endinit block you never see it eanimating. I also just tried to call the class's method from a a regular frame action but its still not working.
Here is the code...most of it is jsut one long function to animate the panels. I'm sure the code is a bit screwed up now, I have been trying everything. If someone could help me out and point me in the right direction I'd appreciate it.
#initclip
function ActionComponentClass(){
this.init();
}
ActionComponentClass.prototype = new MovieClip();
//initialize the component
ActionComponentClass.prototype.init = function (){
/* COMPONENT PARAMETERS
actionText_param
*/
//hide the text box
this.actionText_txt._visible = false;
//the text that shows on the panel
this.actionText_txt = this.actionText_param;
}
ActionComponentClass.prototype.expandPanel = function (){
//****************
//setting up the text area
//****************
//allow html text in text field
actionText_txt.html = true;
//set the text field text
//defined in properties panel
actionText_txt.htmlText = '<P ALIGN = "CENTER">' + this.actionText;
//make the text box autosize
actionText_txt.autoSize = "center";
actionText_txt._width = 185;
//resize the middle panel to fit the entire text field
panelMid_mc._height = (actionText_txt._height);
//***************
//animating the panel
//***************
//hide the arrow until scaling is finished
cornerArrow_mc._visible = false;
//grab the current y scale fo the middle panel, before we shrink it down
finishYscale = panelMid_mc._yscale;
//grab the x and y scale for the ! mc too
circleFinishY = (cornerArrow_mc._yscale - 90);
circleFinishX = cornerArrow_mc._xscale;
//shrink the panels to 1 pixel...
cornerArrow_mc._xscale = cornerArrow_mc._yscale = 1;
panelTop_mc._xscale = panelTop_mc._yscale = 1;
panelMid_mc._xscale = panelMid_mc._yscale = 1;
panelBottom_mc._xscale = panelBottom_mc._yscale = 1;
actionText_txt._visible = false;
//...scale them back up
speed = 20;
panelTop_mc.onEnterFrame = function() {
if (this._yscale < 101) {
this._yscale = this._xscale += speed;
} else {
delete this.onEnterFrame;
}
};
panelMid_mc.onEnterFrame = function() {
this._y = (panelTop_mc._y + panelTop_mc._height) - 1.5;
if (this._xscale < 101){
this._xscale += speed;
}
if (this._yscale < finishYscale) {
this._yscale += 50;
} else {
if (this._yscale > 98 && this._xscale > 98){
actionText_txt._visible = true;
placeArrow();
cornerArrow_mc._visible = true;
}
}
};
panelBottom_mc.onEnterFrame = function() {
this._y = (panelMid_mc._y + panelMid_mc._height) - .5;
if (this._yscale < 101) {
this._yscale = this._xscale += speed;
}
};
cornerArrow_mc.onEnterFrame = function(){
if (this._xscale < circleFinishX){
this._xscale += 10;
this._yscale +=8;
}
}
}
Object.registerClass("FActionComponentSymbol", ActionComponentClass);
#endinitclip
ActionComponentClass.expandPanel();