📜 ⬆️ ⬇️

Jsfl selection

Hello, dear readers.

This is a small note on the topic of filtering the shape elements in the Flash IDE. Almost every flasher is engaged in manual work. Internet on various Russian and English-speaking forums periodically pop up questions about filtering selected objects in the Flash IDE, but almost no one gives solutions. I was also worried about these questions, and I found the answer in jsfl programming in flash programming.

I offer several jsfl scripts on to simplify the processing of selected items:

')
Referred “groups” are flash groups of objects obtained by selecting several objects and performing the “Tools-> Group” menu action.
The concept of "prefetch" I borrowed from AutoCAD, when objects could be selected before the command, rather than first command, then objects.

************************************************** ****************************
selectionOnlyGroup.jsfl
//      . //       . //  raw shape   . fl.outputPanel.clear(); var sel = fl.getDocumentDOM().selection; var arrSelectedOnlyGroups = new Array(); for(i=0;i<=sel.length-1;i++) { var str=""; if(sel[i].elementType=="shape") { str+="isGroup:"+sel[i].isGroup+", members.length="+sel[i].members.length; arrSelectedOnlyGroups.push(sel[i]); } fl.trace("i:"+i+" - "+sel[i].elementType+", "+str); } fl.getDocumentDOM().selectNone(); fl.getDocumentDOM().selection = arrSelectedOnlyGroups; fl.trace(" : "+fl.getDocumentDOM().selection.length); 

************************************************** ****************************
selectionOnlyGroupsWithNoMembers.jsfl
 //   ,     . //         , //    shape      . //        (). //    ,    ,   //          . // ,          . //       ,     . fl.outputPanel.clear(); var sel = fl.getDocumentDOM().selection; var arrSelectedOnlyGroups = new Array(); for(i=0;i<=sel.length-1;i++) { var str=""; if(sel[i].elementType=="shape") { str+="isGroup:"+sel[i].isGroup+", members.length="+sel[i].members.length; if(sel[i].members.length==0) { arrSelectedOnlyGroups.push(sel[i]); } } fl.trace("i:"+i+" - "+sel[i].elementType+", "+str); } fl.getDocumentDOM().selectNone(); fl.getDocumentDOM().selection = arrSelectedOnlyGroups; fl.trace(" : "+fl.getDocumentDOM().selection.length); 


************************************************** ****************************
selectionOnlyGroupsWithMembers.jsfl:
 //   ,    . //         , //    shape      . //     . //        (). //     ,    //         . // ,      shape      . fl.outputPanel.clear(); var sel = fl.getDocumentDOM().selection; var arrSelectedOnlyGroups = new Array(); for(i=0;i<=sel.length-1;i++) { var str=""; if(sel[i].elementType=="shape") { str+="isGroup:"+sel[i].isGroup+", members.length="+sel[i].members.length; if(sel[i].members.length>0) { arrSelectedOnlyGroups.push(sel[i]); } } fl.trace("i:"+i+" - "+sel[i].elementType+", "+str); } fl.getDocumentDOM().selectNone(); fl.getDocumentDOM().selection = arrSelectedOnlyGroups; fl.trace(" : "+fl.getDocumentDOM().selection.length); 

************************************************** ****************************

In general, Flash IDE is difficult to work with the sample, but rather it is almost impossible. All Flash allows you to do is select objects in different ways (click, shift click, double click, frame selection of objects), but when you’ve finished your selection, it’s almost impossible to filter out items from this selection using the menu. Only manual select / unselect.

Here are examples of using scripts:

1. The initial sample is made with a rectangular selection with the mouse. It can be seen that in addition to groups of objects, a part of the line got into the sample:



2. After applying the selectionOnlyGroup.jsfl script:



It can be seen that the partially selected line has disappeared from the prefetch.

3. Separate the elements Modification-> divide:



It is clear that some of the objects were “removed”, but some of the objects continue to “persist” and stand firmly in the group.

4. Apply the selectionOnlyGroupsWithMembers.jsfl script to remove graphic objects from the selection and leave only groups with subgroups:



and again “divide” the selection. We get the result:



It seems like everyone else ... But there is no complete certainty. Let's check the available selection with the selectionOnlyGroupsWithMembers.jsfl script:



It seems like that conceived. All neatly "broken."

I remind you that the goal was not to break objects, but to work with filtering. Objects could not break, and move, for example. I think that there should be no problems with filtering. The main thing is that there is something to filter.

Thanks for attention.

PS

In general, the jsfl theme is undeservedly dispensed with, because in flash there is almost no manual way to correctly refactor an image. Sufficiently high-level methods from the menu do not give access to the internal structure of objects.

Source: https://habr.com/ru/post/137101/


All Articles