Talk:Gallery.as

From Organic Design wiki
Revision as of 07:02, 10 April 2006 by Nad (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Compiled in Image gallery concepts

I think i'm on the right track. Seems there is some scope or nesting problem. I have successfully created a prototype movie clip but it will not show on the stage.--Rob 14:49, 10 Apr 2006 (NZST)

You can't create a movieclip as a child of a non-movieclip because createEmptyMovieClip is only a method of the MovieClip class. So you can't make a new movieclip with new(), it has to be one of the movieclips own methods.
But the movieclip object does come with a method to inherit from other objects which is the registerClass method, but you have to associate it with another movieclip object or it will no longer be one itself (although, you could use a normal object if it inherited the movieclip properties with obj.prototype=new movieclip). --Nad 15:07, 10 Apr 2006 (NZST)
You can side-step all these complex methods but still use prototypes by just having the movieclip as a property of the object (like object.swf), but the movieclip itself could be created in _root or whatever by your prototype's constructor, but just a ref to it is in your object's swf property. eg...
    function myProtoConstructor( parentMovieClip, layer ) {
        var name = 'swf'+layer; // involving layer makes a unique name within the parent context
        parentMovieClip.createEmptyMovieClip( name, layer );
        this.swf = parentMovieClip[name];
        }
then when you go (eg.) something = new myProtoConstructor( _root, 100 )you use something like a normal object, and adjust its corresponding movieclip via its swf property, eg. something.swf._alpha = 50. Nad 17:06, 10 Apr 2006 (NZST)
Trying to figure out
this.thumb = _parent[name];

Have added the _ to parent as in docs (or not). Does this refer to the name object within the _parent object?--Rob 18:44, 10 Apr 2006 (NZST)

Make sure you understand how . and [] work together as its very important, not just to swf --Nad 18:52, 10 Apr 2006 (NZST)
eg. that foo.bar is equiv to foo["bar"] but foo[bar] (no quotes) is a different kettle of fish - that's what we really want the brackets for!