Jump to content


Photo

How to script a Rich Symbol's status?


  • Please log in to reply
7 replies to this topic

#1 fbolte

fbolte

    Fireworks Sparkle

  • Members
  • Pip
  • 3 posts
  • Location:Cologne

Posted 23 April 2009 - 06:24 AM

Hi everyone,



i'm scripting some rich symbols by hand, which works pretty well, and I love Fireworks for this possibility.

But:
Right now I have to change/switch all elements in the PNG seperately to achieve a desired state. Is there any way to change a rich symbol's status/state from within the .jsf file? I tried to look through all the child elements of the object »Widget«, but didn't find anything related to the status.

Can anyone confirm, that it's impossible or possible? (And if the latter, maybe tell me, how to)?


thanks for any help,

fab1An



PS: This maybe isn't strictly »design«, but it doesn't fit into the other categories as well, so I posted it here. Admins feel free to move it, if there's a better place for it.

#2 abeall

abeall

    FireworksNut

  • Administrators
  • PipPipPipPipPipPip
  • 523 posts

Posted 23 April 2009 - 08:27 AM

Hi, what exactly do you mean by symbols status/state? Anything you update directly inside the symbol which is not overridden by a symbol property will get changed on all instances of that symbol throughout the document.

PS - This should probably be in Extending Fireworks :)

#3 fbolte

fbolte

    Fireworks Sparkle

  • Members
  • Pip
  • 3 posts
  • Location:Cologne

Posted 23 April 2009 - 11:51 AM

Hi, what exactly do you mean by symbols status/state? Anything you update directly inside the symbol which is not overridden by a symbol property will get changed on all instances of that symbol throughout the document.

I mean the states, that can be defined in the states panel for every page or symbol.

Maybe I should explain in detail what I am trying to do:
Our symbols are a little more complex than all the examples I saw yet. They contain multiple elements (quite some bitmaps) that shall change or be displayed or not, depending on our selection.

Right now, all that can be set with the symbol properties panel (comboboxes and text inputs), but I'm pretty sure, we don't need any possible combination, so I'd prefer just one combobox to select one of X presets. Since it would be much easier to just use the animation states that can be set for any symbol in the states panel. Also, this way it's much easier to define the states than editing the JS code.

As I found out now, the states are for animation purposes, but maybe it's possible to select them from within the code? That would be pretty cool, but I have no high hopes.

Can somebody tell me more?

PS - This should probably be in Extending Fireworks :)


Am I able to move it there? If so, I don't see this option.

#4 abeall

abeall

    FireworksNut

  • Administrators
  • PipPipPipPipPipPip
  • 523 posts

Posted 23 April 2009 - 05:40 PM

Ah, unfortunately there is no way to control what state is visible in the parent document. It will actually sync the symbols states to parents states, for instance if you put the symbol on a layer in the parent which is set to "Share layer across states" and you add a second state in the parent document, you'll notice that the symbol actually show its second state on the second state of the parent.

I definitely think it would be more useful if you could just control the symbol states async to the parent states, and set the visible state from the parent document, so I would encourage you to submit a feature request.

Possible alternatives to achieve what you want is to put all graphics in a layer and toggle the layer visibility (not positive this will work) or to group the elements together and just toggle the group visibility.

#5 fbolte

fbolte

    Fireworks Sparkle

  • Members
  • Pip
  • 3 posts
  • Location:Cologne

Posted 24 April 2009 - 12:17 AM

Ah, unfortunately there is no way to control what state is visible in the parent document. It will actually sync the symbols states to parents states, for instance if you put the symbol on a layer in the parent which is set to "Share layer across states" and you add a second state in the parent document, you'll notice that the symbol actually show its second state on the second state of the parent.

I definitely think it would be more useful if you could just control the symbol states async to the parent states, and set the visible state from the parent document, so I would encourage you to submit a feature request.

Possible alternatives to achieve what you want is to put all graphics in a layer and toggle the layer visibility (not positive this will work) or to group the elements together and just toggle the group visibility.

Thanks for your confirmation. So I'll keep »building states« inside the .jsf file. Being able to just switch states from there would be nice, so I did as you told and submitted a feature request.

#6 lungdisc

lungdisc

    FireworksCommander

  • Members
  • Pip
  • 7 posts

Posted 17 November 2011 - 03:15 PM

I know this topic is from 2009, but someone might end up on this page.

In order to change the current state of a symbol, you just have to get it's dom and then set the current state, like this:

var symbol_dom = fw.getDocumentDOM(element.symbolID);
symbol_dom.currentFrameNum = 2;


#7 jdunning

jdunning

    Fireworks Ninja

  • Members
  • PipPipPipPipPip
  • 173 posts

Posted 22 March 2012 - 02:18 PM

In order to change the current state of a symbol, you just have to get it's dom and then set the current state, like this:

var symbol_dom = fw.getDocumentDOM(element.symbolID);
symbol_dom.currentFrameNum = 2;

But that doesn't update the instance in the parent document, right? For me, the instance still shows the first state after changing it to state 2.

#8 jdunning

jdunning

    Fireworks Ninja

  • Members
  • PipPipPipPipPip
  • 173 posts

Posted 01 February 2013 - 11:47 AM

In case anyone lands here after a web search, I've created an extension that automatically builds a rich symbol from a document's states, without requiring any JavaScript: http://johndunning.c...out/StateSymbol

 

The elements on the states are converted to groups and copied to the first state.  The groups are then shown or hidden based on the selection in the State combobox in the Symbol Properties panel.  So it still doesn't do quite what the OP was looking for, changing the states in the symbol itself, but it achieves the same result and is still fairly easy to edit.