PDA

View Full Version : Whats up with this?


duncant
07-13-2005, 03:43 PM
I have been writing a few functions, and can not seem to get it working correctly.


var rotationSpeed = 3.8;
var ScaleLarge = 101;
var ScaleSmall = 25;
var HoverSize = 35;
var Speed = 5;


with(mc1)
{
_xscale = 25;
_yscale = 25;
_rotation = random(90);
}
/************************************************** ************************
FUNCTION OpenWindow
************************************************** ************************/
MovieClip.prototype.OpenWindow = function()
{
this.onEnterFrame = function()
{
this._xscale += Math.floor((ScaleLarge - this._xscale))/Speed;
this._yscale += Math.floor((ScaleLarge - this._yscale))/Speed;
trace(this._xscale);
this._rotation += Math.floor((0 - this._rotation))/rotationSpeed;
if(this._xscale >= ScaleLarge - 1)
{
trace("HITTTTTT");
delete this.onEnterFrame;
this.mcHit.enabled = false;
}
}
}
/************************************************** **********************
FUNCTION CloseWindow
************************************************** **********************/
MovieClip.prototype.CloseWindow = function()
{
this.onEnterFrame = function()
{
this._xscale += Math.floor((ScaleSmall - this._xscale))/Speed;
this._yscale += Math.floor((ScaleSmall - this._yscale))/Speed;
trace(this._xscale);
this._rotation += Math.floor((random(90) - this._rotation))/rotationSpeed;
if(this._xscale <= ScaleSmall)
{
delete this.onEnterFrame;
this.mcHit.enabled = true;

}
}
}

/************************************************** ************************/

mc1.onPress = function()
{
this.OpenWindow();
trace("Movieclip " +this+ " has been pressed");
}
mc1.mcClose.onPress = function()
{
mc1.CloseWindow();
}


I can't seem to get this mcHit enabled function to go to false.

I have attached a dummy file, if anyone would like to have a crack at it?

Thanks

ds.pixeled
07-13-2005, 03:50 PM
i think you need to change your scripts to
var rotationSpeed:Number = 3.8;
var ScaleLarge:Number = 101;
var ScaleSmall:Number = 25;
var HoverSize:Number = 35;
var Speed:Number = 5;
but doing this sort of thing is usually only done when you have an abstract number that needs to be evaluated. if it's just a set number, why not put in that number instead of making it a variable?

creynders
07-13-2005, 03:55 PM
Maybe you should change
delete this.onEnterFrame;
this.mcHit.enabled = false;
to
this.mcHit.enabled = false;
delete this.onEnterFrame;

duncant
07-13-2005, 04:21 PM
ds.pixeled
Using the variables will allow my to change values at ease in the long run.
mc1 will not just be on it's own, there will be about 20 of them.

Anyway I tried both what you had suggested and no luck.

I tried changing the values of

this.mcHit.enabled = true;

to

this.mcHit._alpha = 50;

Just to see if it works, and it did, there seems to be something with the MovieClip.enabled property that my code doesn't like.

Stumped.

ds.pixeled
07-13-2005, 04:39 PM
does anyone know if that's an AS 1.0 or AS 2.0 script command? i've had problems in the past where simple stuff like that hasn't carried over and there was something else you were supposed to do now... just a thought.

srija
07-13-2005, 04:44 PM
hey
it s


mc1.mcHit.enabled = false;
mc1.mcHit._alpha = 50;



ur mcHit is inside mc1

duncant
07-13-2005, 05:29 PM
yes I know mcHit is inside mc1. I want mcHit to be disabled.

srija
07-13-2005, 06:09 PM
duncant,
i m also new to flash
just trying to help u out :confused:
to my knowledge
If enabled is set to false, the button movie clip's callback methods and on action event handlers are no longer invoked, and the Over, Down, and Up frames are disabled.
The enabled property does not affect the Timeline of the button movie clip; if a movie clip is playing, it continues to play. The movie clip continues to receive movie clip events The enabled property only governs the button-like properties of a button movie clip.

plz let me know if this makes sense
srija

duncant
07-13-2005, 07:08 PM
Sorry srija, I know you are just trying to help me out. It is just so annoying and frustrating.
As it was all working before I made it all into prototype functions.

ds.pixeled seems to be on to something. I am thinking there is a bug with the way the code has been wrote.

So if anyone can shed any light, please do so.

Thanks

ds.pixeled
07-13-2005, 09:10 PM
well if there is a problem in the coding it isn't in the basic scripting two things to look at are the path you've given it. you can double check that by clicking on the target shaped icon in the actions panel up near the top. just click through and it'll give you want you want. i recommend having it set to relative because if it's then loaded into another .swf it still works. the other thing is double check that your if condition script works. there might be and error with that. which the way you've set up your variables doesn't work with as 2.0. try setting it to publish in flash player 6 and see if it works. oh and get rid of the "var" in front of your variables to do that. look in the actionscript dictionary it'll have more on the whole variable thing. (the dictionary is under help in flash in case you didn't know.)

duncant
07-14-2005, 09:48 AM
Tried what you had suggested, it has me stumped.
Are there any alternatives to MovieClip.enabled = boolean;?

duncant
07-14-2005, 02:00 PM
figured it out: Use this

mc1.mcHit.onPress = function()
{
mc1.OpenWindow();
trace("Movieclip " +this+ " has been pressed");
}
mc1.mcClose.onPress = function()
{
mc1.CloseWindow();
}
instead of this:

mc1.onPress = function()
{
this.OpenWindow();
trace("Movieclip " +this+ " has been pressed");
}
mc1.mcClose.onPress = function()
{
mc1.CloseWindow();
}

and use:

MovieClip._visible = boolean;

instead of:

MovieClip.enabled = boolean;