| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|
#1 |
|
Registered User
Join Date: Jul 2004
Location: Canada
Posts: 10
|
I have a JSFL file I wrote that recursively runs through all the layers,frames, and elements, to pick up all the instance name and text name and change them to lowercased names.
I do this because I have tons of code in Actionscript1.0 and I need to solve the case-sensitivity problem in order to update them to Flash 7. So instead of going through by hand I thought I could batch them with a JSFL script. I use a recursive function to pick up all the instance. In order to get all the elements inside of an object, I need to change the document.selection to select an object and enter its edit mode.( It will be greatly appreciated if anyone can give another solution without using "enterEditMode") Here is the problem. When I change the document.selection and execute document.enterEditMode, an alert msg appears: "enterEditMode:no selection ". I am pretty sure I have already assign an element to the "document.selection". Any suggestion welcomed. Code: function searchAndReplace(currElement) { // if no instance in the current frame, then exitEditMode //var exitEditFlag = true; fl.trace("Start to search and replace in the symbol/document: " + currElement) //assigns the layers array to the variable "theLayers" var theLayers = fl.getDocumentDOM().getTimeline().layers; //creates an array to hold all the elements that are instances of "myMovieClip" //counter variable // var x = 0; //begin loop through all the layers for(i = 0 ; i < theLayers.length; i++) { var theFrames = theLayers [i ].frames; //begin loop through all the frames in a layer for(j = 0 ; j < theFrames.length; j++) { var k = 0; var theElems = theLayers [i ].frames [j ].elements; //begin loop through all the elements in a frame for(k = 0 ; k < theElems.length; k++) { var theElemType = theElems [k ].elementType; if( theElemType == "instance") //if the element is of type "instance" { // if a instance exists in the current frame, then call the recursive function //exitEditFlag = false; // change the instance name var tmpStr = theElems [k].name; if(tmpStr != "" && tmpStr != null) { theElems [k].name = tmpStr.toLowerCase(); fl.trace(tmpStr + "==>" + theElems [k ].name); } // enter the editting mode of the current element var currSelectionArray = new Array; currSelectionArray [0] = theElems [k]; fl.getDocumentDOM().selection = currSelectionArray; var hasSelected = fl.getDocumentDOM().selection; //if(hasSelected != 0 ) //{ fl.getDocumentDOM().enterEditMode("inPlace"); // recursive function is called searchAndReplace(theElems[k ].name); //} //else //alert(theElems[k ].name + " hasSelected = 0"); } // else if( theElemType == "text") // if it is a text { var tmpStr = theElems [k ].name; if(tmpStr != "" && tmpStr != null) { theElems [k].name = tmpStr.toLowerCase(); fl.trace(tmpStr + "==>" + theElems [k ].name); } } } } } fl.getDocumentDOM().exitEditMode(); // Now the loop reaches the ending condition }; // main code var currElement = fl.getDocumentDOM().name; var count =0; searchAndReplace(currElement); |
|
|
|
|
|
#2 |
|
lala
Join Date: Feb 2002
Location: on the road
Posts: 2,859
|
this is a weird one. even though i trace the length of the selection array after assigning it, and it gives me 1, when looking at the ide my selection had not changed from the fill that was selected. i think your best bet is to take this to the extendFlash list run by flashguru (flashguru.co.uk) or the extending flash forum, where you will have more people than me looking at it.
|
|
|
|
|
|
|
|
|
#3 |
|
Registered User
Join Date: Apr 2004
Posts: 28
|
Code:
function allNamesToLower()
{
var currentDoc = fl.getDocumentDOM();
for( var i = 0; i < currentDoc.timelines.length; i++ )
{
var myCurrTimeline = currentDoc.timelines[ i ];
for( var j = 0; j < myCurrTimeline.layers.length; j++ )
{
var myCurrentLayer = myCurrTimeline.layers[ j ];
for( var k = 0; k < myCurrentLayer.frames.length; k++ )
{
var myCurrentFrame = myCurrentLayer.frames[ k ];
for( var l = 0; l < myCurrentFrame.elements.length; l++ )
{
var myCurrentElement = myCurrentFrame.elements[ l ];
// Here's the simple code to change the name to lower case.
var newName = myCurrentElement.name;
myCurrentElement.name = newName.toLowerCase();
}
}
}
}
}
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|