PDA

View Full Version : #initclip



ahmed
August 2nd, 2003, 05:09 PM
hey

i did a slider component, and then added three instances of it (RGB) inside another color picker component im making. Now, if i place the the slider component on _root and for..in-loop through it's properties/functions and trace them, all the properties and functions are traced. Inside the color picker component thought, when i do that same loop, only the properties are traced, which i think means the slider component instances aren't initialized. I tried different values for the 'order' parameter of #initclip, but it still did not work :hair:

Does anyone know what's causing this and how to fix it? =)

senocular
August 2nd, 2003, 06:00 PM
you got an example? maybe a quick simple mock-up of whats going on?

ahmed
August 2nd, 2003, 06:48 PM
hmm.. would this help?
// code inside slider component
#initclip

function slider() {
...
...
}

slider.prototype = new MovieClip();

Object.registerClass("slider", slider);

slider.prototype.getValue = function() {
return Math.round(this.cursor._x*this.cp_max/100)
};

#endinitclip
and the code inside the color picker component
#initclip

colpicker = function() {
...
...
}

colpicker.prototype = new MovieClip()

Object.registerClass("colorpicker", colpicker)

colpicker.prototype.getRGB = function() {
return ((0x10000*this.red.getValue())+(0x100*this.green.g etValue())+(this.blue.getValue()));
}

#endinitclip


this.red, this.green and this.blue are instances inside the slider component places inside the the color picker component, and for some reason and i can access the slider's getValue() method. If the slider is places on _root, outside the color picker, it works fine. . . =)


[edit]

added #endinitclip to avoid confusion :bu:

fixed getRGB :trout:

thoriphes
August 2nd, 2003, 07:05 PM
don't you need an
#endinitclip somewhere in there?

ahmed
August 2nd, 2003, 07:06 PM
yes, i do have an #endinitclip at the bottom, i just didnt have it in the code sample i provided =)


[edit]

added #endinitclip to avoid confusion :bu:

thoriphes
August 2nd, 2003, 07:10 PM
i've never dealt with components before, but today may be my lucky day. :)

ahmed
August 2nd, 2003, 07:12 PM
http://www.kirupaforum.com/forums/showthread.php?threadid=27900&highlight=component


download the component h88 made, it'll help you make your own components :)

senocular
August 2nd, 2003, 07:23 PM
0x10000*this.red.getValue())+(0x100*this.redgreen. getValue())+(this.red.blue.getValue()));

whats all that? you have this.red ... this.redgreen and then this.red.blue ... wherent they red green and blue? :!:

but anyway, is it that you need them in the picker constructor?

ahmed
August 2nd, 2003, 07:25 PM
lol. sorry, it's

0x10000*this.red.getValue())+(0x100*this.green.get Value())+(this.blue.getValue()));

and that still doesnt work :)

senocular
August 2nd, 2003, 07:27 PM
but.... you're trying to do this from the constructor?

ahmed
August 2nd, 2003, 07:33 PM
well basically i wanna be able to call the sliders' methods through one of the color picker's methods. so since this.red refers to the 'red' slider, i should be able to call red's getValue through 'this.red.getValue', but it doesnt work :)

senocular
August 2nd, 2003, 07:44 PM
right :) but it will work (or at least should work) as long as you aren't calling it from the constructor. The constructor is run before the contents of that clip (component) are loaded, meaning before the sliders are loaded meaning before their constructors are loaded and before anything is technically defined for them. This by the way is completely independant of initclip stuff. Thats just defining the class period and the initclip does this before frame 1 and before any clip/component, such as your color picker. The constructors are called for the clips themselves when actual clips load - and thats actually before they load and before their contents load. So the colpicker constructor will be called before any of the sliders are created (though their reference at this time exists) and their constructors are run. So, because of that, any of the sliders arent defined for the constructor and you wouldnt be able to use those methods until after they do load. Now that will be basically anytime after the constructor of the colpicker instance. If you need it right away, use an onLoad prototype which will be called after the constructor and after the sliders are defined and have run.

Otherwise, there's probably some referencing issues somewhere gone screwy

ahmed
August 2nd, 2003, 07:48 PM
aah.. i get it, thanks a lot sen =)

Actually, i was calling them from the constructor. Now it all makes sense, thanks again :thumb: