I am creating a custom control. The idea is to use 4 sliders to set the RGBA values and a rectangle to display the resulting color. I have created a Dependency Property for the color result so I can bind to it. That is working so far. What I don't understand is how to combine the 4 slider results into a single color value. I know how to do this, just not where to do it. There doesn't seem to be any code behind for custom controls. Where do I implement the logic for my custom controls? What am I missing here? Thanks.
You need to override OnApplyTemplate method and call GetTemplatePart for each template part control and store these in private fields. Then add dependency properties for each of the RGBA channels and maybe use TemplateBinding to bind slider values to the properties. Finally in the callbacks of your dependency properties set the Color property value.
Related
This works on model which don't have any color:
this.viewer.setThemingColor(node, red, this.model);
But not on model with objects which have a color.
In the docs you can read:
Highlight an object with a theming color that is blended with the
original object’s material.
Blended? What does it mean? How do I set a color to an object if it already has a color?
P.S:
Typescript typedefinition to the Viewer would really be helpfull.
Update
Think it has something to do with the type of object.
I have run both isolate and setThemingColor (red) on the same items.
In the screenshot below, the red door in lower right corner is selected:
It has a "material" heading.
In this screenshot the door next to it (turquoise) is selected. It's missing the material heading.
Do I need to "apply" material or something to make it change color?
Did you supply a THREE.Vector4 object as color or the second argument? Just dug into the code and it wasn't any type check logic and would lead to your error if the wrong type is given. Also make sure you put in the right model object as the third argument, otherwise the render won't know which model to apply the colors when you have multiple models.
You can details about the usage of this method below:
https://forge.autodesk.com/en/docs/viewer/v6/reference/javascript/viewer3d/#setthemingcolor-dbid-color-model
Edit:
If the component is lacking a material pls see here on how to add a custom one: https://forge.autodesk.com/blog/using-dynamic-texture-inside-custom-shaders
PS: We are working on TypeScript definitions for Viewer and Forge SDK and they could be released soon. Stay tuned!
I'm having a MovieClip on the stage with an "Adjust Color" filter applied to it through the properties panel not through action script, however, I need to read the filter values from AS3 to be able to use them on other classes.
I know how to apply the effect through AS3 but not to read it back if its applied from outside the code.
Thanks in advance :))
There's a filters property, which is an array of the current filters.
trace(target.filters);
The 'adjust color' filter creates a ColorMatrixFilter object. This class does not actually expose the properties brightness, contrast, saturation or hue - these are niceties that the UI provides, which actually translate to the more complex data found in the matrix array.
Where is good place to load image in custom itemrender for list. I try to do it in createChildren where i create my holder for image, but data is not set yet.. I think in data function is not ok, because is calinig every time when user scroll.
You need to set the data/url to the image in commitProperties.
You didn't tell us what the image is and how it relates to your itemRenderer. Here are a few options:
If your image will not change based on the data then create your image class in createChildren(). Set the property on it in the createChildren() method; if it is static. If it is something that may change you may consider setting it in commitProperties().
If your image will change based on the data; then you should change it either in the set data method or in a dataChange event handler. I prefer the latter, but that is just preference. An itemRenderer is re-used as the list is scrolled. So the data that your renderer represents changes with it; and so should your visual display.
If lots of the elements of your dataProvider may use the same image; you can write conditional logic to determine whether or not the image should be loaded again. This would prevent the image from reloading again unnecessarily.
Since flex memory management is poor, objects once instantiated dont die very easily (even when they go out of scope), one would need to check on various properties of components. I am using one such thing to know if the screen (which is a display object) is in current view. For this I am turning on a boolean property (currently visible), and I am setting it true on show event of the display object.
What I need to know is, which event (something opposite of show, e.g left?) could be used when the screen is replaced by another display object?
Something like focusIn and focusOut from dotnet.
Or if there is some property which could directly tell me if the display object is currently in view (hasFocus doesnt seem to be giving me expected results).
Thanks.
You can Use PropertyChageEvent check the documentation and base of the newValue and kind property you can do some action :
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/events/PropertyChangeEvent.html
hope this help
Name of the event is: removedFromStage.
I want to know if it's possible, and if so how, to apply a property of a var to multiple vars at once. I'm making a point-n-click game where i want to apply the buttonMode property to multiple variables (of MovieClips).
I don't know if this is even possible or how simple or advanced this is, but it would be damn handy.
I have searched on Google and this site for a possible answer, with different search terms/keywords, but can't find anything close. I also tried different things with an asterisk such as *.buttonMode = true and movieClip.*.buttonMode = true but no success.
Any help would be very much appreciated.
All you really need to do is bind a specific property of all these movieclips to a bindable variable.
For more information on bindable variables visit :
1. http://www.flexafterdark.com/docs/ActionScript-Bindable
2. http://jacwright.com/blog/54/actionscript-3-bindable-dynamic-objects/
Bindables come in handy whenver you want many objects to refer to a property , and on the change of this property, some property in the object(s) which have binded to this bindable variable will change.