1

fl.findObjectInDocByType()で返された情報を使用できないようですfl.getDocumentDOM().selection

document.setTextRectangleを使用して生成された配列からいくつかのテキストフィールドのサイズを変更するために使用したいと思いますfl.findObjectInDocByType()

すべてのtextObjectプロパティに簡単にアクセスできますがdocument.setTextRectangle、現在の選択が必要なため、途方に暮れています。

選択を設定するためのドキュメントの例は次のとおりです。

fl.getDocumentDOM().selection = fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0];

fl.findObjectInDocByType()属性を持つオブジェクトの配列を返します:(object.timeline、、、、)object.layerobject.frameobject.parent

fl.getDocumentDOM().selection=ただし、これらはオブジェクトであり、 ...で必要な配列インデックス番号のプロパティはありません。

var doc = fl.getDocumentDOM();
var textFieldArray = fl.findObjectInDocByType("text", doc);
    for (var i=0; i < textFieldArray.length; i ++){
        fnResizeTheTextField(textFieldArray[i]);
    }

function fnResizeTheTextField(theTextField){
        //force current selection to be theTextField
        //doc.selection MUST be an array, so assign theTextField to an array...
        var selectArray = new Array();
        selectArray[0] = theTextField.obj;
        var theTimeline =theTextField.timeline;
        var theLayer =theTextField.layer;
        var theFrame =theTextField.frame;
        doc.currentTimeline =theTextField.timeline;
        doc.selection = doc.getTimeline().theLayer.theFrame.selectArray;//error
        //resize the text rectangle
        doc.setTextRectangle({left:0, top:0, right:1000, bottom:1000});
    }
}

結果:Error:doc.getTimeline().theLayer has no properties

4

3 に答える 3

2

ObjectFindAndSelect.jsfl スクリプトには、これ専用の関数 fl.selectElement() が既に含まれています。はるかにエレガント:

var doc = fl.getDocumentDOM();
// generate an array of elements of type "text"
var textFieldArray = fl.findObjectInDocByType("text", doc);
    for (var i=0; i < textFieldArray.length; i ++){
        fnResizeTheTextField(textFieldArray[i]);
    }

function fnResizeTheTextField(theTextField){
        //force current selection to be theTextField
        fl.selectElement(theTextField,false);//enter 'edit mode' =false...
        //resize the text rectangle
        doc.setTextRectangle({left:0, top:0, right:1000, bottom:1000});
    }
}
于 2011-12-21T18:25:13.723 に答える
0

私は最近同様の問題を抱えていました.どうやらすべてのグーグルの結果はsetTextRectangle()ここに私たちを向けています. 信じられないほど、jsfl の文書化が不十分です :)

setTextRectangle()ステージ上にないライブラリ アイテム内で使用する必要がある場合は、最初にアイテムを開いて編集する必要があります。

私の問題を解決したコードは次のとおりです。

library.selectItem(libraryItemName);
doc.selection = [tf];//where tf is the reference to textfield we need to edit
doc.library.editItem(libraryItemName);  
doc.setTextRectangle({left:l, top:t, right:r, bottom:b});
doc.selectNone();

より良い解決策がある場合は、投稿してください。誰かの時間を節約できることを願っています。幸運を!

于 2013-01-16T15:39:57.493 に答える
0

私は答えを見つけました。ドキュメント レベルの操作で何かを選択するには、そのオブジェクトのキーフレームにフラッシュ フォーカスを設定する必要もあります。

そのため、fl.findObjectInDocByType() によって作成されたオブジェクトの配列をループ処理する場合、次のコードを使用して、フラッシュがオブジェクトに正しくフォーカスされるようにします。

function fnMakeFlashLookAt(theObject){
        doc.currentTimeline =theObject.timeline;
        doc.getTimeline().currentLayer =theObject.layer;
        doc.getTimeline().currentFrame =theObject.frame;
    }

ただし、これはシンボル内にネストされたオブジェクトでは機能しない場合があります。

于 2011-12-17T00:18:12.017 に答える