View Full Version : How do I access custom MovieClip parameters?
titohov
04-28-2008, 07:33 AM
Hi,
In AS2 you could right-click on a movieclip in your library and select "Component Definition..." Once there you could create custom parameters that would appear in the "parameters" tab. It's basically a way to set initial values of parameters for the movieclip.
This used to work fine in AS2, but now I get this error when trying it in AS3:
1120: Access of undefined property test
Is there a special way you have to access the parameter list now?
Thanks for any help on this!
alpsoy
04-28-2008, 01:00 PM
Ok, if your parameter is myVar, inside the MovieClip try this to access that parameter :
this["myVar"]
xwielder
04-28-2008, 01:19 PM
I'm not sure what you mean by "Custom parameters". Are you referring to MovieClip attributes beyond the scope of the MovieClip class? Or are you referring to defining values within the scope of the class?
matbury
04-28-2008, 02:28 PM
The best way to add properties and functions to a class is to sub-class it. Try extending the MovieClip class and adding your properties in the .as file.
titohov
04-28-2008, 04:59 PM
Sorry, I should have been more clear. I'm basically trying to create custom parameters like a component would have. I'm doing a custom number stepper and I want the user to be able to define values right on the MC in flash (without having to edit an external class). If you look at the NumericStepper component by Adobe, you'll see that you can configure values for min, max, stepValue, etc. I'm looking to do the same thing. Basically just provide initial values that can be used when my MovieClip gets instantiates.
I tried this["myVar"] but it doesn't seem to work.
Slowburn
04-28-2008, 09:21 PM
try referencing the Component-Inspector and how to build custom components.
This should provide you with all the info you need to do what you want.
alpsoy
04-28-2008, 09:45 PM
I've prepared an example, I think this is what you are looking for.
Download the attachment, choose the movieClip on the stage and open parameters panel.
There is a String value there and export swf.
It will trace the value. You can change and try it again.
Enter edit mode of movieClip and look at actions panel, you will see the code that handles the String and traces it.
Then open library, right click the movieClip and choose component definition.
You will see the definition parameters there.
The rest of it depends on you :)
titohov
04-29-2008, 12:03 AM
Thanks for the file Alpsoy! Appreciated.
It seems to work fine if you drag the movieclip out of the library and change the parameter's value. It will trace the value correctly when you test movie.
Check this out though. If you drag out the MC and just rely on its default value ("defaultValue" in your file), it traces undefined. Doesn't that seem strange? It's like you have to manually change the predefined value to something else to get it to work. Is that normal? It seems like you should be able to use the default values.
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.