Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




MovieClip.prototype.fadeIn In AS3?



Please help me adjust this code to work in Actionscript 3.0

PHP Code:


MovieClip.prototype.fadeIn = function(){
    mcImg.onEnterFrame = function(){
        this._alpha +=6;
        if(this._alpha > 99){
            this._alpha = 100;
            delete this.onEnterFrame;
        }
    };
}; 



ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0
Posted on: 02-07-2008, 03:26 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

[FMX/2004] FadeIn Prototype, Run By Multiple Objects At The Same Time
I have the following prototype, which is used by typing objName.fadeIn(100, 3);
this is all well and good, although when I start to use it on multiple mc's at once the playback becomes quite choppy and nasty... any ideas dudes?

Code:
MovieClip.prototype.fadeIn = function(v, r) {
this.onEnterFrame = function() {
if (this._alpha<v) {
this._alpha += r;
} else {
delete this.onEnterFrame;
}
};
};

[FMX/2004] FadeIn Prototype, Run By Multiple Objects At The Same Time
I have the following prototype, which is used by typing objName.fadeIn(100, 3);
this is all well and good, although when I start to use it on multiple mc's at once the playback becomes quite choppy and nasty... any ideas dudes?

Code:
MovieClip.prototype.fadeIn = function(v, r) {
this.onEnterFrame = function() {
if (this._alpha<v) {
this._alpha += r;
} else {
delete this.onEnterFrame;
}
};
};

Fadein Menu MovieClip Controlled By Button
Hi everyone, I'm trying to create a menu MovieClip that should fade in onto the main page. I want this to be controlled by "on(press)" event inside a button that is not in the menu MovieClip. I guess what I'm trying to ask is this: 1. can you control a movieClip through an ouside button, and 2. how do you fade in a movieClip onto the main stage. ((--ThanXs--))

Preloader With Fadein Effect For Empty Movieclip?
peepz,

i have this script to preload a empty MC:


Code:
stop();
titleArray = lv.title.split("|||");
urlArray = lv.url.split("|||");

myTitleArray = titleArray;
myUrlArray = urlArray;

this.createEmptyMovieClip("e_mc", 1);

holder = _root.mcPhotoShow.mcPhotoShowImageHolder;
holder2 = _root.mcPhotoShowImageHolder2;

holder.createEmptyMovieClip('frame', 1);
holder2.createEmptyMovieClip('frame', 1);

for (var i = 0; i<myTitleArray.length-1; i++) {
var temp_mc = e_mc.attachMovie("button", "b"+i, i);
temp_mc.i = i;
temp_mc._y = i*24;
temp_mc.btn_txt.text = myTitleArray[i];

temp_mc.onRollOver = function() {
this.mcRollOver.gotoAndPlay(2);
};

temp_mc.onRollOut = function() {
this.mcRollOver.gotoAndPlay(20);
};

temp_mc.onRelease = function() {

loadMovie(myUrlArray[this.i], holder.frame);
loadMovie(myUrlArray[this.i], holder2.frame);

_root.mcPhotoPreloader.gotoAndStop(1);

holder.onEnterFrame = null;
preloadID = setInterval(checkLoading, 500);
};
}

function checkLoading() {
clearInterval(preloadID);
holder.onEnterFrame = function() {
if (this.frame.getBytesLoaded() != undefined && this.frame.getBytesLoaded()>4) {
geladen = this.frame.getBytesLoaded();
totaal = this.frame.getBytesTotal();
percentage = geladen/totaal*100;
trace(percentage);
trace(geladen);

_root.mcPhotoPreloader.gotoAndStop(Math.round((8/100)*percentage)+1);

trace (Math.round((8/100)*percentage)+1);

if (this.frame.getBytesLoaded() == this.frame.getBytesTotal()) {
holder.onEnterFrame = false;
if (percentage == 100) {
_root.photoloader = "yes"
_root.mcPhotoPreloader.gotoAndPlay(9);
}
}
}


//end if holder
};
//end enter frame
}
//end function

but there are 2 problems:

1st:
the image shows up before the preloader is ready :S

2nd:
i wan the effect i uploaded, after the preloader is fully loaded

hope somebody can help me?

THnx for all your support!

Preloader With Fadein Effect For Empty Movieclip
peepz,

i have this script to preload a empty MC:


Code:
stop();
titleArray = lv.title.split("|||");
urlArray = lv.url.split("|||");

myTitleArray = titleArray;
myUrlArray = urlArray;

this.createEmptyMovieClip("e_mc", 1);

holder = _root.mcPhotoShow.mcPhotoShowImageHolder;
holder2 = _root.mcPhotoShowImageHolder2;

holder.createEmptyMovieClip('frame', 1);
holder2.createEmptyMovieClip('frame', 1);

for (var i = 0; i<myTitleArray.length-1; i++) {
var temp_mc = e_mc.attachMovie("button", "b"+i, i);
temp_mc.i = i;
temp_mc._y = i*24;
temp_mc.btn_txt.text = myTitleArray[i];

temp_mc.onRollOver = function() {
this.mcRollOver.gotoAndPlay(2);
};

temp_mc.onRollOut = function() {
this.mcRollOver.gotoAndPlay(20);
};

temp_mc.onRelease = function() {

loadMovie(myUrlArray[this.i], holder.frame);
loadMovie(myUrlArray[this.i], holder2.frame);

_root.mcPhotoPreloader.gotoAndStop(1);

holder.onEnterFrame = null;
preloadID = setInterval(checkLoading, 500);
};
}

function checkLoading() {
clearInterval(preloadID);
holder.onEnterFrame = function() {
if (this.frame.getBytesLoaded() != undefined && this.frame.getBytesLoaded()>4) {
geladen = this.frame.getBytesLoaded();
totaal = this.frame.getBytesTotal();
percentage = geladen/totaal*100;
trace(percentage);
trace(geladen);

_root.mcPhotoPreloader.gotoAndStop(Math.round((8/100)*percentage)+1);

trace (Math.round((8/100)*percentage)+1);

if (this.frame.getBytesLoaded() == this.frame.getBytesTotal()) {
holder.onEnterFrame = false;
if (percentage == 100) {
_root.photoloader = "yes"
_root.mcPhotoPreloader.gotoAndPlay(9);
}
}
}


//end if holder
};
//end enter frame
}
//end function

but there are 2 problems:

1st:
the image shows up before the preloader is ready :S

2nd:
i wan the effect i uploaded, after the preloader is fully loaded

hope somebody can help me?

THnx for all your support!

Preloader With Fadein Effect For Empty Movieclip?
peepz,

i have this script to preload a empty MC:


Code:
stop();
titleArray = lv.title.split("|||");
urlArray = lv.url.split("|||");

myTitleArray = titleArray;
myUrlArray = urlArray;

this.createEmptyMovieClip("e_mc", 1);

holder = _root.mcPhotoShow.mcPhotoShowImageHolder;
holder2 = _root.mcPhotoShowImageHolder2;

holder.createEmptyMovieClip('frame', 1);
holder2.createEmptyMovieClip('frame', 1);

for (var i = 0; i<myTitleArray.length-1; i++) {
var temp_mc = e_mc.attachMovie("button", "b"+i, i);
temp_mc.i = i;
temp_mc._y = i*24;
temp_mc.btn_txt.text = myTitleArray[i];

temp_mc.onRollOver = function() {
this.mcRollOver.gotoAndPlay(2);
};

temp_mc.onRollOut = function() {
this.mcRollOver.gotoAndPlay(20);
};

temp_mc.onRelease = function() {

loadMovie(myUrlArray[this.i], holder.frame);
loadMovie(myUrlArray[this.i], holder2.frame);

_root.mcPhotoPreloader.gotoAndStop(1);

holder.onEnterFrame = null;
preloadID = setInterval(checkLoading, 500);
};
}

function checkLoading() {
clearInterval(preloadID);
holder.onEnterFrame = function() {
if (this.frame.getBytesLoaded() != undefined && this.frame.getBytesLoaded()>4) {
geladen = this.frame.getBytesLoaded();
totaal = this.frame.getBytesTotal();
percentage = geladen/totaal*100;
trace(percentage);
trace(geladen);

_root.mcPhotoPreloader.gotoAndStop(Math.round((8/100)*percentage)+1);

trace (Math.round((8/100)*percentage)+1);

if (this.frame.getBytesLoaded() == this.frame.getBytesTotal()) {
holder.onEnterFrame = false;
if (percentage == 100) {
_root.photoloader = "yes"
_root.mcPhotoPreloader.gotoAndPlay(9);
}
}
}


//end if holder
};
//end enter frame
}
//end function

but there are 2 problems:

1st:
the image shows up before the preloader is ready :S

2nd:
i wan the effect i uploaded, after the preloader is fully loaded

hope somebody can help me?

THnx for all your support!

FLA FADEIN

Movieclip.prototype.distance=function(movieclip) ?
hi,
I want to know want does this mean:
Movieclip.prototype.distance=function(movieclip){

please help
Thank you

How To Use MovieClip.prototype?
when and where must ues it?and how to use it??

Movieclip.prototype
Hey I was just wondering how do you make it so like a button can use the same functions as a movieclip like:
MovieClip.getDepth()
how would you make it so that you could say
Button.getDepth()
thanks!

MovieClip.prototype
How do I rewrite this for Flash 8:
Code:
MovieClip.prototype.elasticScale = function(targetScale, accel, friction) {
this.speed += (targetScale-this._xscale)*accel;
this.speed *= friction;
this._xscale = this._yscale += this.speed;
};
Right now it only works if I change the publishing to Flash 6.

Movieclip.prototype ?
Okay, okay...I'll admit, I'm a little rusty around the edges...so please, forgive me now!

To that end, what the heck is
Code:
movieclip.prototype.scaler = function(friction) {
//do some stuff
}
Where, "scaler" is the name of the function (hehe..I think!)

First off, it only works when published to Flash player 6 w/AS 1.0?!? Secondly, what was it replaced with for newer Flash Player version, i.e. 7 & 8 players??

I've tried converting it to the following function, as in:


Code:
function scaler(scale, friction) {
//do some stuff
?
But that just breaks it completely!? Which is strange, b/c in theory, it should work, no?

Anywho...any help and/or advice on this prototype jibjab would be much luved!

Thanks in advance!


mo

MovieClip.prototype Is Doing Nothing
On a first frame of my main timeline I have this:


PHP Code:



MovieClip.prototype.ResizeRectangle = function(w, rate) {
    var obje=this;

    obj.onEnterFrame=function() {
        tmpw=(w-obje._width)*rate;
        obje._width=obje._width+tmpw;
        if (Math.abs(w-obje._width) <= 1) { obje._width=w; } 
    }
}
aaa.ResizeRectangle(580,0.200); 




Also there is a movieclip instance called "aaa". Why the last line of code

PHP Code:



aaa.ResizeRectangle(580,0.200); 




won't animate the movieclip "aaa"? What I am doing wrong?

Thanks.

MovieClip.prototype
Sorry , this question might sound stupid but I keep on hearing abt. MovieClip.prototype and the list of methods in it.What is it exactly? is an actionscrpt file like mx.transition and tweens of Macromedia.

Help With MovieClip Prototype
Has anyone ever used the AS script found at senocular.com called freeTransform.as?

[AS2] MovieClip.Prototype
Quote:




_level0.workspace.x0y0 x: 0 y: 0 depth: 2
x: undefined y: undefined depth: 2
_level0.workspace.x0y1 x: 16 y: 0 depth: 3
x: undefined y: undefined depth: 3
_level0.workspace.x0y2 x: 32 y: 0 depth: 4
x: undefined y: undefined depth: 4
_level0.workspace.x0y3 x: 48 y: 0 depth: 5
x: undefined y: undefined depth: 5
etc..





Code:
// selectedTile is a global variable
MovieClip.prototype.worktileFunctionality = function(tile:MovieClip) {
drawTerrainTile(this, tile);
this.onPress = function () {
drawTerrainTile(this, selectedTile);
}
}

function setupWorkspace(map:Array, workspace:MovieClip) {
var depth = 1;
for (var i = 0; i < 25; ++i) {
for (var j = 0; j < 25; ++j) {
workspace.createEmptyMovieClip("x"+i+"y"+j, depth);
depth++;
worktile = workspace["x"+i+"y"+j];

worktile._x = j*16;
worktile._y = i*16;

tileNum = map[i][j][0]-1;
tile = terrainTiles[tileNum];

trace(worktile+" x: "+worktile._x+" y: "+worktile._y+" depth: "+depth);
// defined

worktile.worktileFunctionality(tile);

trace(worktile+" x: "+worktile._x+" y: "+worktile._y+" depth: "+depth);
// undefined?
}
}
}
What am I doing wrong with this prototype?

MovieClip.prototype?
hi all,

is MovieClip.prototype now removed in the As2?, if it is removed what command replaced it , thanks

MovieClip.prototype
Hi all

I am finishing up the Friends of Ed Actionscript for Flash MX.At the end they show using MovieClip.prototype. Is this depreciated or not best practice? I was planning on moving onto FOE Object-Oriented ActionScript.

Movieclip.prototype
Hi.
Could someone please explain me the definition of "movieclip.prototype", the prototype part. What it's function is and so on.
Thanks

MovieClip.prototype.DoSomething =
Whatis the meaning of this script

// ACTION FOR THE BUTTON
MovieClip.prototype.DoSomething = function (theClip) { trace ("nome: "+theClip._name);trace ("valore: "+theClip.mov.txt);};

I want to make the buttons of the menu to be active,
I found this action on the frame, & found another action on the symbol
which is:

on(release){
DoSomething(_parent);
}

What can i do to make the buttons to be active , notice that there is one symbole which appears as 4 links

Please help
I need it urgent

If u need to download the menu go to
http://www.flashkit.com/movies/Inter...04/index.shtml

Thank u & Please help
[Edited by cipolla on 12-03-2001 at 08:40 AM]

Movieclip.prototype Problem
Ok I am new to prototype and I have a image as a mc then I turned it into another mc which I called "internal" and inside that I have 4 more images each on there own key frame with stop(); on each one.
So mc inside that is mc internal inside that is sequence images.
Now on my first frame I have my functions

Code:
Movieclip.prototype.color_load = function() {
//mysound = new Sound(this);
butCol = new Color(this.internal);
};
Movieclip.prototype.color_update = function() {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
counter++;
addcol = random(151);
butCol.setTransform({rb:addcol, gb:addcol, bb:addcol});
duplicateMovieClip("line0", "line"+counter, counter);
//trace("line"+counter);
} else {
butCol.setTransform({ra:100, ga:100, ba:100, rb:0, gb:0, bb:0});
}
};
Then on the first mc I have

Code:
onClipEvent (load) {
color_load();
internal.gotoAndStop(1);
}
onClipEvent (enterFrame) {
color_update();
}
and the second the same code except

internal.gotoAndStop(2);
and so on .

I am having messed up shi"ttt going on when I publish the movie for one when I hit test over the first mc it triggers the effect on the last mc
and also the line duplication is happening but its not showing up.
Can someone please help with this issue. Thanks in advance

MovieClip.prototype Internals?
does anyybody knows how to list all MovieClip.prototype objects?
i know that those ar hidden from for-loop, so i cant use:
for (e in MovieClip.prototype) {
trace(e);
}

i simply wont to dig into mc, what can i do?

Movieclip.prototype.anything = Function()
Hi,
Please can any one explain - even it seems ridiculous to you - the difference (advantage) between:

movieclip.prototype.anything = function()
and
anything = function ()

Thanks a lot

Rewrite MovieClip.prototype?
peepz,

is it posible to rewrite this prototype so i can use it in the flash player V7 ?

im using actionscript 1.0

i have some problems with it :S

code:
MovieClip.prototype.elasticMoveY = function(targety, accely, converty) {
stepy = stepy * accely + (targety - this._y) * converty;
this._y += stepy;
}
MovieClip.prototype.elasticMoveX = function(targetx, accelx, convertx) {
stepx = stepx * accelx + (targetx - this._x) * convertx;
this._x += stepx;
}


in my flash 5.0 it works fine...

i also want to ad something that it always bounces back to its original position...

thanks for all your help!

MovieClip.prototype Problem
I am using a function for playing animation in reverse on mouse click event... code is something like this ...

Quote:




on (press){

_root.inst_sliding_pic.reverseShift(1000/12, 2);

MovieClip.prototype.reverseShift = function(t, fr) {

...................
}




problem with this code is it doesnt work on first click but it does work very well on the next clicks.

MovieClip.prototype Issue
Hi there,

First of all, if you really want to help me, please don't:

1. question my approach (taken out of context to focus on the problem)
2. suggest a workaround


My problem: I've got the following code:
code: MovieClip.prototype.sequence = function() {
_root["Button"+i].onRelease = function() {
this.gotoAndStop("active");
};
};
for (i=1; i<=4; i++) {
_root["Button"+i].i = i;
_root["Button"+i].sequence();
}
This code works fine. However, for some reasons which I do not wish to elaborate on, I need to replace this code with code: MovieClip.prototype.sequence = function() {
_root["Button"+i].onRelease = function() {
_root["Button"+i].gotoAndStop("active");
};
};
for (i=1; i<=4; i++) {
_root["Button"+i].i = i;
_root["Button"+i].sequence();
}
since I need the absolute path. Only exchanged the highlighted area. Now it doesn't work any more; - question: why not?
What can I do to make it work? In case of confusion, view attached file.
Help appreciated.

Problem With MovieClip.prototype
Hi guys,

I'm having abit of difficulty and I'm hoping someone can aid me with this. First off my version details are: Flash 8 using AS2.0.

I have a class in TextComponent.as by the same name.

It's a class that encapsulates all the properties of a TexField. On creating a new instance, the constructor creates an empty MovieClip and within that a dynamic TextField, and uses an embedded font.

So on the timeline in frame 1, I have something like:


Code:
import com.domain.TextComponent;

MovieClip.prototype.right = function()
{
return this._x + this._width;
}

var myText1:TextComponent;

onLoad = function()
{
myText1 = new TextComponent("Initial text");
}

onEnterFrame = function()
{
myText1.Update();
trace(_root.right());
}
As you can see I've highlighted in red the code that is the issue here. Inside the TextComponent.Update() method I'm trying to do a similar trace

trace(m_mcText.right());

The output is "undefined" for the m_mcText movieClip, but it works ok for _root. Has anyone any idea why this is this case. I was under the impression that once I add a method to the prototype, all MovieClips created thereafter will have this method. Has it got anything to do with the movieclip being created using "createEmptyMovieClip", or anything to do with being encapsulated in a class.

Any light on this issue would be much appreciate. I can't get any custom methods working at all.

Dave.

MovieClip.prototype Not Working
Hey people - I am building a stand alone app so it's being exported as version 7 so I can use css to format my xml, but now my prototype function is not working.

this is the one i am using:

Code:
MovieClip.prototype.floatTo = function(speed,endx,endy,isY) {
this.speed = "."+speed; this.endx = endx; this.endy = endy;
this.dist_x = Math.round(endx - this._x);
this.dist_y = Math.round(endy - this._y);
this.vel_x = this.dist_x*this.speed;
this.vel_y = this.dist_y*this.speed;
this._x += Math.round(this.vel_x);
this._y += Math.round(this.vel_y);

if(isY)return Math.round(this.vel_y);
else return Math.round(this.vel_x);
}
Any idea what the deal is. Do I have to do something different with the prototype when it's exported as V7. I am still using AS 1.0.

Anyone know?

Thanks

Animation And MovieClip.prototype
I was able to animate stars based on the MovieClip.prototype approach. Now,
I am trying to animate clouds that are supposed to go across the sky (movie stage). The problem is that they are not going anywhere. Instead, what I see is a constant jerky movement but they stay in the same place.

There's a bit of code on the clouds movie clip. I know there's an error there, but I can't catch it. I am using MovieClip.prototype code again, and I would really like if you helped me along with it.

Thanks

Rewrite MovieClip.prototype?
peepz,

is it posible to rewrite this prototype so i can use it in the flash player V7 ?

im using actionscript 1.0

i have some problems with it :S


ActionScript Code:
MovieClip.prototype.elasticMoveY = function(targety, accely, converty) {
    stepy = stepy * accely + (targety - this._y) * converty;
    this._y += stepy;
}
MovieClip.prototype.elasticMoveX = function(targetx, accelx, convertx) {
    stepx = stepx * accelx + (targetx - this._x) * convertx;
    this._x += stepx;
}

in my flash 5.0 it works fine...

i also want to ad something that it always bounces back to its original position...

thanks for all your help!

MovieClip Prototype And Return
Hi all,

I am trying to put together a movieclip prototype, like


Code:
MovieClip.prototype.generateWord = function() {
words = new Array();
//prepare to load our external .txt
//our ext. variable is wordlist
//and get a random word
lv = new LoadVars();
lv.onLoad = function() {
fl = this.wordlist;
words = fl.split("|");
//get a random word
k = Math.floor(Math.random()*words.length);
word = words[k];
trace("word "+word]);
};
lv.load("data.txt");
return word;
}
which I want to use like

Code:
MC.randomText.text= generateWord();
Now the trace("word "+word]); part works but return word; doesn't I think or am I using return completely wrong???

Please advice

MovieClip Prototype Exception
I am extending the behavior of my movieclips by adding additional onRollover methods. This works well but the trouble is that I need to make exceptions. I would like some Movie clips to ignore the additions I'm making. The MCs that need this new method are created by duplicating a library Movieclip at runtime. How do I make this exception?

Watch Movieclip.prototype
gooday all
i would like to add a new property on MovieClip's prototype and watch() it
however i've got an error that tells me the property i reference does not have static attribute
here is my code, would anyone kindly correct me?
at the last2nd line of my code, if i change to MovieClip.prototype.watch()
it results no effect.......








Attach Code

MovieClip.prototype.myProp = 100;
MovieClip.prototype.ff = function(prop, oldVal, newVal) {
trace("modifying myProp");
return newVal;
};
MovieClip.watch(MovieClip.prototype.myProp,MovieClip.prototype.ff);
mcc.myProp = 100;

Movieclip Prototype Not Responding?
I have an org chart that looks like this:

click to see

It's big - sorry.

Anyway, there are 130 little boxes on that graphic, each one a movie clip. Because I want the same thing to happen on rollover of each movie clip I have put the following on my main timeline:


ActionScript Code:
MovieClip.prototype.scale = function(w,h){        this.onEnterFrame = function(){                this._width = w-(w-this._width)/1.2                this._height = h-(h-this._height)/1.2                if(this._width > w-1 && this._width < w+1 && this._height > h-1 && this._height < h+1){                        delete this.onEnterFrame                }        }}MovieClip.prototype.onRollOver = function(){    startW = this._width;    startH = this._height;    endW = this._width*2;    endH = this._height*2    this.onRollOver = function(){        _root.x +=2;        this.swapDepths(_root.x);        this.scale(endW, endH);    }    this.onRollOut = function(){        this.scale(startW, startH);    }}


This works but only on the SECOND rollover. In other words, the first time the mouse hits it nothing happens. Roll off then roll on again and the code triggers and it scales. Then go away and come back and it is just fine.

Anyone know why the code isn't fired immediately on first rollover?

thanks

*edit* Another small problem - since the movie clips aren't all the same size the code MAKES them all the same size if you roll over them in quick succession. How can I prevent this? Is there a better way of capturing a particular movieclip's starting width and height, double it on rollover, and then returning to that on rollout?

MovieClip.prototype.isDepthTaken
Here's a little prototype to check whether a depth in a movieclip is occupied or not.


ActionScript Code:
MovieClip.prototype.isDepthTaken = function(d:Number){    for(var all in this){        if(this[all] instanceof MovieClip || this[all] instanceof Button || this[all] instanceof TextField){            if(this[all].getDepth() == d) return true;        }    }    return false;}this.createEmptyMovieClip("foo", 99);trace(this.isDepthTaken(99)); // true  

Movieclip.prototype.fadeout
Hello

can I run a function Movieclip.prototype.fadeoutMain and Movieclip.prototype.fadeoutImage simultaniusly?
They do abut the same thing, fade out the object that runs those functions... Only one of those 2 are excecuted when I try to call both...

/henxon

MovieClip.prototype Vs. Function?
Hey guys, I looked around for a clear answer for this and didn't find any.
I've used MovieClip.prototype for a while for declaring a large part of my functions, but I always wonder if having all of these functions in every single movie clip bogs down the flash player. Is it better to use function unless a prototype is absolutely necessary or does it not matter because the function is in memory and not actually being copied into the clips or what?

Muchos Gracias to anyone who can answer,

--EP

MovieClip.prototype And As2 Class
Hi there..

i have two questions..

the first what exactly does the function "MovieClip.prototype" means is it a sort of class?

I ask this question because i have a lot of resizing scripts in my flash movie. i think too much because they are not always working fine anymore.

Is it possible to write a class for resizing? because a lot of the movieclips must be in the middle of the screen. Even when resizing it has to be in the middle. Some of the clips are not moving anymore when resizing. So i thought if i add a class .as file it maybe works better. i never work with classes in flash and that's only because i do not know the real meaning of it. If someone can explane me the meaning and quality of classes. And ofcourse how to add them to the several movieclips.

Thanks

MovieClip Prototype, AttachMovie And Var
I've got a MovieClip.prototype function that loads an mc from the library using attachMovie. I want the mc to be loaded to be determined by a var that I determine based on which button is pressed.

It won't work for some reason. It seems like the prototype won't update the var in the attachmovie.

Example:

Code:
MovieClip.prototype.fadeIn = function() {
i = 1;
loadybox = _root.attachMovie(loadBox, "loadybox"+i, i);
}
var background:String = "back_1";
button1.onRelease = function() {
var background:String = this._name;
Obviously the buttons and backgrounds have the same name. I've tried adding in a
Code:
delete background
to the onRelease, but when I trace it it becomes undefined after deleting.

Any suggestions on how to set a variable to determine which mc will be loaded by button pressing?

MovieClip.prototype Question.
Im making one site and wanna create one prototype that load and do tween of alpha zero to alpha 100. Bellow my code:

ActionScript Code:
//_________________________________________//                                                     prototypeMovieClip.prototype.loading = function(file:String):Void {    this.loadMovie(file);    onEnterFrame = function() {        var lfilet:Number = Math.round(this.getBytesTotal());        var lfilel:Number = Math.round(this.getBytesLoaded());        var lfilep:Number = int((lfilel/lfilet)*100);        if ( lfilet > 4 && lfilep == 100 ) {            this.alphaTo(100,1);            delete onEnterFrame;        } else {            this._alpha = 0;        };    };};//_______________________________________//                                                     usingItvar perfBg:String = xml.childNodes[0].childNodes[0].attributes.bg;conteudo.perfil.bg.foto.loading("imagens/" + perfBg);


After run it the image load normaly but dont show the fade. studing the code results i saw that error is the load variables (lfilet, lfilet and lfilep), the result of lfilet and lfilel always is the same. what can i do to resolve it or with this code create one classe ( i dont know nothing about develop classes, only how to use ).

tks in advance and waiting help.

Movieclip Prototype Not Responding?
I have an org chart that looks like this:

click to see

It's big - sorry.

Anyway, there are 130 little boxes on that graphic, each one a movie clip. Because I want the same thing to happen on rollover of each movie clip I have put the following on my main timeline:


ActionScript Code:
MovieClip.prototype.scale = function(w,h){        this.onEnterFrame = function(){                this._width = w-(w-this._width)/1.2                this._height = h-(h-this._height)/1.2                if(this._width > w-1 && this._width < w+1 && this._height > h-1 && this._height < h+1){                        delete this.onEnterFrame                }        }}MovieClip.prototype.onRollOver = function(){    startW = this._width;    startH = this._height;    endW = this._width*2;    endH = this._height*2    this.onRollOver = function(){        _root.x +=2;        this.swapDepths(_root.x);        this.scale(endW, endH);    }    this.onRollOut = function(){        this.scale(startW, startH);    }}


This works but only on the SECOND rollover. In other words, the first time the mouse hits it nothing happens. Roll off then roll on again and the code triggers and it scales. Then go away and come back and it is just fine.

Anyone know why the code isn't fired immediately on first rollover?

thanks

*edit* Another small problem - since the movie clips aren't all the same size the code MAKES them all the same size if you roll over them in quick succession. How can I prevent this? Is there a better way of capturing a particular movieclip's starting width and height, double it on rollover, and then returning to that on rollout?

MovieClip.prototype.isDepthTaken
Here's a little prototype to check whether a depth in a movieclip is occupied or not.


ActionScript Code:
MovieClip.prototype.isDepthTaken = function(d:Number){    for(var all in this){        if(this[all] instanceof MovieClip || this[all] instanceof Button || this[all] instanceof TextField){            if(this[all].getDepth() == d) return true;        }    }    return false;}this.createEmptyMovieClip("foo", 99);trace(this.isDepthTaken(99)); // true  

MovieClip.prototype.MoveTo
Hy guys!
I'm trying to make a function for making a MC to move on stage from a plase to another smoothly and doesn't work. I've got tha AS from a forum and I tried to customized for my need and doesn'r work the way I want. With this AS MovieClip.prototype.MoveTo the MC it moves but not smoothly. I post the AS too. Can you help guys.

ActionScript Code:
MovieClip.prototype.MoveTo = function(x, y){
x = x-this._x;
y = y-this._y;
if (x <= 0){
        this._x = 0;
    }
    if (y <= 0){
        this._y = 0;
    }
}

Thanx in advace!

MovieClip.prototype Vs Function
I have a function, something like that:


ActionScript Code:
function up_down(mc) {
    mc._yscale = -mc._yscale;
}


I have also a movie clip on the stage, called mc. I write in the first frame:


ActionScript Code:
up_down(mc);


And it works perfectly. But I have laso somthing like that:


ActionScript Code:
MovieClip.prototype.up_down = function(mc) {
    mc._yscale = -mc._yscale;
};


And I also write in the first frame:


ActionScript Code:
up_down(mc);



I don't get it - what's the diffrenc between those two things? Which one should I use?

'MovieClip.Prototype' Doesn't Work :(
Hi !

What's wrong with my following code ?

MovieClip.prototype.onLoad = function() {
this.myX = random(500)+200;
this.myY = random(300)+200;
}
mc1.onEnterFrame = function() {
trace("My original x value "+this.myX);
trace("My original y value "+this.myY);
}

It doesn't show x & y values in output window. Anyone could please tell me the answer ?
TIA

MAhesh K.

Call Movieclip.Prototype From Loop
Can somebody please explain to me why the following isn't working:

Code:
numPics = 2;
pictures = new Array();

for(i=0; i<numPics; i++){
pictures[i] = "picture" + i + ".jpg";
curPic = this.attachMovie("containerMC", "pic"+i, i);
//trace("curPic: " + curPic);
// using prototype does not work, but WHY??
//curPic.loadPic(pictures[i]);
// below syntax also doesn't work:
//this["pic"+i].loadPic(pictures[i]);
// normal function call DOES work:
loadPic(curPic, pictures[i]);
}
MovieClip.prototype.loadPic = function(image){
trace("prototype loadPic called by " + this._name);
// do other stuff
}
function loadPic(myTarget, image){
trace("function loadPic called by " + myTarget);
}
I really want to get the MovieClip.Prototype call to work, but can't figure out how. .
Please help

ASBroadcaster.initialize(MovieClip.prototype);
Anyone know how to do this without having every MovieClip use the same _listeners array?

Enabling Buttons Through MovieClip.Prototype
I'm trying to make this script work which has a function to enable buttons.

// This script is on a seperate layer frame:
// webnav, iden, adv, mult are instances of MCs

btns = [webnav, iden, adv, mult];
MovieClip.prototype.enableBtns = function(btns) {
for (i=0; i<btns.length; i++) {
btns[i].enabled = true;
}
}

// This is on the MC itself
//partial code ...within onClipEvent handler

_root.navbtns_mc.webnav.onRelease = function() {
_root.navbtns_mc.webnav.enabled = false;
enableBtns(_root.btns);
}

The buttons disable but just don't enable again when other buttons are clicked.

The button instances are on the path: _root.navbtns_mc.

Having Problem With Movieclip Tween Prototype HELP
Hello, I am having trouble with movieclip tween prototype.
Supposedly, one object shoud scale down and another object should change its color when mouse is rolled over (and out) on the button. Yet, I only see one action reacting. another one is just stagnant. Could anybody help on this one?
Thank you!

Copyright © 2005-08 www.BigResource.com, All rights reserved