在AS3中,您可以将常量传递给编译器
-define+=CONFIG::DEBUG,true
Run Code Online (Sandbox Code Playgroud)
并将其用于条件编译,如下所示:
CONFIG::DEBUG {
trace("This only gets compiled when debug is true.");
}
Run Code Online (Sandbox Code Playgroud)
我正在寻找类似#ifndef的东西,所以我可以否定调试的价值并使用它来有条件地添加发布代码.我发现的唯一的解决办法,到目前为止是在条件编译文档的Adobe和因为我的调试和发布配置是相互排斥的,我不喜欢同时具有DEBUG的想法和释放常数.
此外,这种格式有效,但我假设它在运行时运行检查,这不是我想要的:
if (CONFIG::DEBUG) {
//debug stuff
}
else {
//release stuff
}
Run Code Online (Sandbox Code Playgroud)
我也考虑过做这样的事情,但它仍然不是我希望的优雅解决方案:
-define+=CONFIG::DEBUG,true -define+=CONFIG::RELEASE,!CONFIG::DEBUG
Run Code Online (Sandbox Code Playgroud)
提前致谢 :)
我正在使用Actionscript在s:List组件中设置所选元素,它可以工作,但List不会滚动到所选项目 - 需要使用滚动条或鼠标滚动.是否可以自动滚动到所选项目?谢谢 !
我有一个字符串
var s:String = "This is a line \n This is another line.";
this.txtHolder.text = s; //.text has \n, not a new line
Run Code Online (Sandbox Code Playgroud)
我想将它放入文本区域,但忽略新的行字符.我怎样才能确保文本在分配时打破我想要的位置?
在下面的代码中,我试图加载一些图像,并在它们单独加载后立即将它们放入舞台.但它被窃听,因为只显示最后一张图像.我怀疑这是一个关闭问题.我该如何解决?AS3中的闭包行为与Java Script中的行为不一样吗?
var imageList:Array = new Array();
imageList.push({'src':'image1.jpg'});
imageList.push({'src':'image2.jpg'});
var imagePanel:MovieClip = new MovieClip();
this.addChildAt(imagePanel, 0);
for (var i in imageList) {
var imageData = imageList[i];
imageData.loader = new Loader();
imageData.loader.contentLoaderInfo.addEventListener(
Event.COMPLETE,
function() {
imagePanel.addChild(imageData.loader.content as Bitmap);
trace('Completed: ' + imageData.src);
});
trace('Starting: ' + imageData.src);
imageData.loader.load(new URLRequest(imageData.src));
}
Run Code Online (Sandbox Code Playgroud) 有人可以向我解释Adobe Air,Flex和Flash Builder之间的区别吗?
我去了Adobe网站,它说使用Air我可以为桌面或移动设备构建独立的应用程序.他们对Flex说了同样的话.
它说Flash Builider是一个基于Eclipse的开发工具.那是什么意思?然后它说我可以再次为桌面和移动设备构建应用程序.
有很多重叠,我真的不明白首先要学习什么以及采取什么方向.(我非常了解Flash和AS2和AS3.)
按照ASP.NET上的教程,实现了一个Web API控制器方法,用于执行如下所示的异步文件上载:
public Task<HttpResponseMessage> PostFormData()
{
// Check if the request contains multipart/form-data.
if (!Request.Content.IsMimeMultipartContent())
{
throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
}
string root = HttpContext.Current.Server.MapPath("~/App_Data");
var provider = new MultipartFormDataStreamProvider(root);
// Read the form data and return an async task.
var task = Request.Content.ReadAsMultipartAsync(provider).
ContinueWith<HttpResponseMessage>(t =>
{
if (t.IsFaulted || t.IsCanceled)
{
Request.CreateErrorResponse(HttpStatusCode.InternalServerError, t.Exception);
}
return Request.CreateResponse(HttpStatusCode.OK);
});
return task;
}
Run Code Online (Sandbox Code Playgroud)
通过标准的多部分HTML表单上传文件非常有效.但是,当另一个开发人员尝试通过Flex的FileReference类构造的多部分表单上载文件时,会抛出错误:
MIME多部分流的意外结束.MIME多部分消息未完成.
我不知道问题出在Web API或Flex上.我找到了一些没有任何影响的相关修复程序(使用ASP.Net Web API的多部分表单POST),最近发现了这一个("多部分流.MIME多部分消息未完成"webapi上传错误).如果第二个链接成立,是否有人知道它是否在通过Nuget提供的当前版本的Web API中出现?讨论是在5月份,Nuget的最新版本是8月,所以我认为这个修补程序已经部署,并不是我的问题的根本原因.
我想使用Linux和免费环境开发Adobe Flex应用程序.我更喜欢自由的替代品,但啤酒也可以.;-)
您是否有人使用这样的环境开发Adobe Flex富Internet应用程序?或者我应该面对"事实",即Flex Builder是Flex开发的必备工具,没有它我或多或少会丢失?
我有一个对象,其中包含我想要绑定到表单元素的十几个字段,以便我可以使用该对象将数据发送回服务器进行保存.
我的容器对象的定义:
private static const emptyLink:Object = {
id: -1, title:'',
trigger1:'',trigger2:'',trigger3:'',trigger4:'',trigger5:'',
linkTitle:'', linkBody:'',
answer1:'',answer2:'',answer3:'',answer4:'',answer5:''
};
[Bindable] public var currentLink:Object = emptyLink;
Run Code Online (Sandbox Code Playgroud)
currentLink在运行时分配给ArrayCollection中的特定索引,我只是使用该emptyLink对象进行初始化.
<mx:Panel id="triggerPanel" title="Trigger" width="33%">
<mx:VBox id="tpBoxes" width="100%" paddingBottom="5" paddingLeft="5" paddingRight="5" paddingTop="5">
<mx:TextInput id="trigger1" width="100%" textAlign="left" text="{currentLink.trigger1}" />
<mx:TextInput id="trigger2" width="100%" textAlign="left" text="{currentLink.trigger2}" />
<mx:TextInput id="trigger3" width="100%" textAlign="left" text="{currentLink.trigger3}" />
<mx:TextInput id="trigger4" width="100%" textAlign="left" text="{currentLink.trigger4}" />
<mx:TextInput id="trigger5" width="100%" textAlign="left" text="{currentLink.trigger5}" />
</mx:VBox>
</mx:Panel>
Run Code Online (Sandbox Code Playgroud)
当然,这编译并显示得很好,但每个实例都有运行时警告:
警告:无法绑定到类'Object'上的属性'trigger1'(类不是IEventDispatcher)警告:无法绑定到类'Object'上的属性'trigger2'(类不是IEventDispatcher)警告:无法绑定到类'Object'上的属性'trigger3'(类不是IEventDispatcher)警告:无法绑定到类'Object'上的属性'trigger4'(类不是IEventDispatcher)警告:无法在类上绑定属性'trigger5' '对象'(类不是IEventDispatcher)
并且在更改字段currentLink时不更新对象TextInput.
显而易见的答案是我的对象需要是实现的类的实例IEventDispatcher.答案没有告诉我的是实现该界面的细节(需要什么?什么不是?),以及是否有更简单的方法 …
需要一个只接受数字的代码.在输入时,代码必须检查它是否是数字,如果不是,它必须删除输入的密钥或根本不输入它
因为当你使用sql lite时,如果你尝试在同一时刻执行一个函数它会抛出一个错误,我只是试图创建一个函数来检查它是否正在执行,如果它是在10毫秒再试一次,这个确切的函数工作正常如果我不必将任何参数传递给函数,但我很困惑如何将vars传递回它将执行的函数.
我想要做:
timer.addEventListener(TimerEvent.TIMER, saveChat(username, chatBoxText));
Run Code Online (Sandbox Code Playgroud)
但它只允许我这样做:
timer.addEventListener(TimerEvent.TIMER, saveChat);
Run Code Online (Sandbox Code Playgroud)
它给了我这个编译错误:
1067:将void类型的值隐式强制转换为不相关的类型函数
我怎样才能通过这个限制?
这是我得到的:
public function saveChat(username:String, chatBoxText:String, e:TimerEvent=null):void
{
var timer:Timer = new Timer(10, 1);
timer.addEventListener(TimerEvent.TIMER, saveChat);
if(!saveChatSql.executing)
{
saveChatSql.text = "UPDATE active_chats SET convo = '"+chatBoxText+"' WHERE username = '"+username+"';";
saveChatSql.execute();
}
else timer.start();
}
Run Code Online (Sandbox Code Playgroud)