I'm working on a site prototype that has many rollover images in the navigation. Each image is unique, but the rollover and rollout code is identical. I'm trying to create a single symbol that can be used for all of the rollovers, but need some help figuring this out, as it will significantly speed up my work.
I think the pseudocode would work like this
Question: How do I make step 4-6 work? I have 1-3 working smoothly.
Update: I have #6 solved
Images are all managed by the CSS background-image property rather than the old-school <img src=...>
. So to set an image for an element, the syntax is:
$(sym.lookupSelector("[ElementName]")).css('background-image', [image]);
And there's a second part, which is getting [image] right.
images/[image]
url(images/[image])
P.S. My last dev work was waaaaay back with Director, PHP and ColdFusion. I still get basic principles such as using functions, objects, instances, inheritance etc, but the language has changed. And I have very very little experience with the DOM.
Appendix: How I'm Doing This Manually
There's a background image of the nav showing all of the unselected states
Each item in the nav has a corresponding rollover image, in a series of elements layered on top of nav element. Each rollover has opacity initially set to 0%.
Each image element has rollover, rollout and click triggers. Rollover and rollout triggers are identical for each. There's also a little more code with rollout that provides a quick fade. This means lots of copying identical code. I hate to think about having to change any part of that code.
I came to the same conclusions as yours.
Steps 4-5 I did this way: when I create the symbol instance I give it a special name, like "button_image1". Then in the code you can check this property doing:
var symbolElement = sym.getSymbolElement();
var id = symbolElement.attr("id")
var tokens = id.split("_");
var image = tokens[1];
And set the right image as background.
You can put this code on the creation_complete event of the symbol.