我目前正在嘗試將一個簡單的Illustrator插件放在一起,並且來自設計背景,這被證明是一項非常艱鉅的任務,我對JS有經驗,但對Flex沒有經驗。從Textinput傳遞給控制器文件
我想要做的是在Illustrator中有一個面板,帶有一個輸入欄和一個按鈕。您在輸入中輸入內容並按下按鈕,並將具有所需文字的文本框添加到畫布。
但是,如何將mx:Textinput的值傳遞給Controller.as文件?我無法在網上找到答案。
這是我main.mxml文件:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" historyManagementEnabled="false">
<mx:Script>
<![CDATA[
private var c:Controller = new Controller();
]]>
</mx:Script>
<mx:VBox height="100%" width="100%" verticalAlign="middle" horizontalAlign="center">
<mx:Label text="myVariable"></mx:Label>
<mx:TextInput name="TextValue"/> // I want the text value to be passed to the Controller class so I can pass it on to my JSX function
<mx:Button label="Run" click="c.run()"/>
</mx:VBox>
</mx:Application>
這是我Controller.as文件:
package
{
import flash.external.HostObject;
public class Controller
{
[ Embed (source="myScript.jsx" , mimeType="application/octet-stream")]
private static var myScriptClass:Class;
public function run():void {
var jsxInterface:HostObject = HostObject.getRoot(HostObject.extensions[0]);
jsxInterface.eval(new myScriptClass().toString());
//calling from AS to JSX
jsxInterface.myJSXFunction (myVariable); //This is where I want the value to be passed to
}
}
}
Thx求救! :) – timkl 2012-07-28 18:08:56