A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: objectType.prototype.onLoad() ??

  1. #1
    Junior Member
    Join Date
    Mar 2001
    Posts
    12
    Say I got 250 different objects that I would like to perform an action when they load.
    e.g. set a specific color if the objects name is this or that, or the object is within a specific container.
    Pasting in "onClipEvent(load){doThis(withTheseParameters) }, is one thing. And would help a while...
    But...
    Then you need a small modification in this code, the parameters that is sent, or the name of the function it calls, whatever...on with find mc, paste code, find mc, paste code etc.
    So..
    I've just discovered 'prototype', and guess it lies here somewhere... but it's not as if I have the solution yet.

    If you got this far;
    Can I set a prototype that will make every movieclip perform a specific function when it is loaded?

  2. #2
    Senior Member
    Join Date
    Sep 2000
    Posts
    910
    Hi AnyKey....yes, you can....a simple example...have a MovieClip "prototype" like this on your main timeline....

    Code:
    MovieClip.prototype.changeColor = function () {
    	if (_x >= 300) {
    		col = new Color(this);
    		col.setRGB(0xFF0000);
    	}
    }
    ...now on your movieClips have this.....

    Code:
    onClipEvent (load) {
    	changeColor();
    }
    ...any movieClip whose "x" position was greater than 300 would change to red.....

    Hope that helps...

    -pigghost-

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center