有没有什么方法可以在静态函数中包含动态变量,因为你不能在动态函数中使用"this".
我想做什么:
public static function convertToDynamicString(pString:String):String
{
if(pString == "" || pString == null) return "";
var re:RegExp = /(\{\w+\})/;
var results:Array = pString.split(re);
var dynamicString:String = "";
for each(var pWord:String in results)
{
if(pWord.substr(0, 1) == "{") dynamicString += this[pWord.substring(1, (pWord.length - 1))];
else dynamicString += pWord;
}
return dynamicString;
}
Run Code Online (Sandbox Code Playgroud)
问题:
此["变量名称"]在静态函数中不起作用
有没有办法在Flex应用程序中使用ActionScript实现字典.例如,我想存储这样的东西.
public var orientation:ArrayCollection = new ArrayCollection([
{a: new Direction('0','0','b','0')},
{b: new Direction('a','c','0','h')},
{c: new Direction('0','b','d','e')},
{d: new Direction('c','0','0','0')},
{e: new Direction('f','g','0','c')},
{f: new Direction('0','0','e','0')},
{g: new Direction('0','0','0','e')},
{h: new Direction('0','b','0','i')},
{i: new Direction('l','h','j','m')},
{j: new Direction('i','k','0','0')},
{k: new Direction('0','0','0','j')},
{l: new Direction('0','0','i','0')},
{m: new Direction('0','i','0','0')}
]);
Run Code Online (Sandbox Code Playgroud)
所以,而不是
orientation.getItemAt(3).north
Run Code Online (Sandbox Code Playgroud)
我可以去做类似的事情
orientation.getItemAt('d')north
Run Code Online (Sandbox Code Playgroud)
没有得到以下错误
Implicit coercion of a value of type String to an unrelated type int.
Run Code Online (Sandbox Code Playgroud)
谢谢您的帮助
我面临着同样的问题.有人可以用一个例子来解释我吗?
我的代码是:
var dataList:ArrayCollection = new ArrayCollection([{name:"alauddn"}, {name:"ansari"}]);
private function getItemInd(event:MouseEvent):void{
var item:Object = new Object();
item.name = "ansari";
var ias:int = dataList.getItemIndex(item);
Alert.show(ias.toString() + ": " + item.name);
}
Run Code Online (Sandbox Code Playgroud)
但它返回" -1:
我正在尝试使用FlashDevelop打开一个flex项目(使用Adobe Flex创建).我该怎么做?有人能帮助我吗?
执行此服务30秒后,我收到错误
<s:HTTPService id="svcList" url="http://localhost/index.php" method="GET" result="svcList_resultHandler(event)" fault="svcList_faultHandler(event)" requestTimeout="300">
<s:request xmlns="">
<mod>module</mod>
<op>operation</op>
</s:request>
</s:HTTPService>
Run Code Online (Sandbox Code Playgroud)
这个操作需要比平时更长的时间,因此我将php的最大执行时间更改为120秒.
当通过浏览器请求时脚本正确运行即 http://localhost/index.php?mod=module&op=operation
我已经检查了故障事件对象以获得答案,并在faultDetails中找到它 Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://localhost/index.php" errorID=2032]. URL: http://localhost/index.php
请求是否有执行时间限制?
编辑:requetTimeout已使用.
谢谢
我有一个问题是如何将选定或复制的文本粘贴到flash as3中的舞台或文本区域?我复制了文本,但不知道如何将文本粘贴到文本字段中.救命!
提前致谢!
有没有人对使用iOS的Flex 4.6中的Camera API有任何经验?我遇到了很多设置问题,缺乏文档.我正在尝试设置图片上传组件,用户可以在其中捕获新照片或从库中选择现有照片.
对于捕获,当图像保存为JPEG时,似乎有一个巨大的挂起(例如10秒,应用程序只是无响应),而我正在使用Alchemy swc.
private var cam:CameraUI;
protected function takePhotoHandler(event:MouseEvent):void
{
if(CameraUI.isSupported) {
cam = new CameraUI();
cam.addEventListener(MediaEvent.COMPLETE, mediaEventComplete);
cam.launch(MediaType.IMAGE);
}
}
protected function mediaEventComplete(e:MediaEvent):void
{
cam.removeEventListener(MediaEvent.COMPLETE, mediaEventComplete);
status.text = "Media captured..." ;
var imagePromise:MediaPromise = e.data;
var loader:Loader = new Loader();
if(imagePromise.isAsync) {
status.text = "Asynchronous media promise." ;
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, asyncImageLoadHandler);
loader.addEventListener(IOErrorEvent.IO_ERROR, asyncImageErrorHandler);
loader.loadFilePromise(imagePromise);
} else {
status.text = "Synchronous media promise.";
loader.loadFilePromise(imagePromise);
img.source = loader.content;
saveImage(loader.contentLoaderInfo);
}
}
protected function asyncImageLoadHandler(e:Event):void
{
status.text = "Media loaded in …Run Code Online (Sandbox Code Playgroud) 我有一个具有交替项目颜色的列表.
<s:List id="myList" change="selectionChanged(event)" alternatingItemColors="[0x000000, 0xFFFFFF]" dataProvider="{alResults}" itemRenderer="itemRenders.Results" width="100%"></s:List>
Run Code Online (Sandbox Code Playgroud)
我只是想让项目背景透明.
在ItemRenderer的开始标记中,我尝试了这个,但没有用.
<s:ItemRenderer name="Results"
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
autoDrawBackground="true"
contentBackgroundAlpha="0.2">
Run Code Online (Sandbox Code Playgroud)
我也在数据覆盖方法中尝试了setStyle,但也没有用.谢谢.
调用exampleFunction()和exampleFunction.call()有什么区别?Actionscript上有一个功能,允许您通过'call'方法使用函数.例如,要使用下面的'test'函数,我可以编写test()和test.call()
function test():void {
trace('function was called')
}
Run Code Online (Sandbox Code Playgroud)
有什么不同?
例如,我有一个功能:
function doSomething( a:String, b:Number, c:Array ):void {
trace( a + b + c.toString() );
}
Run Code Online (Sandbox Code Playgroud)
...我有一个对象,其中包含我想要传递参数的所有元素:
var args:Object = { 'dog', 11, myArray };
Run Code Online (Sandbox Code Playgroud)
...而且我希望能够将args的内容传递给doSomething而不对doSomething进行任何更改(假设它是其他人的功能)并且我想以一种不假设我会知道任何关于args的内容.
这可能吗?
apache-flex ×10
flash ×5
air ×1
camera ×1
colors ×1
dictionary ×1
flashdevelop ×1
flex-mobile ×1
flex4 ×1
flex4.5 ×1
httprequest ×1
ios ×1
itemrenderer ×1