var myStr:String = root.loaderInfo.parameters.benny;
//this code will recieve single value from flashVars.
Run Code Online (Sandbox Code Playgroud)
我想知道如何使用LoaderInfo.parameters来处理更多数据?
我使用了以下代码.
stop();
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, onLoadingAction);
this.loaderInfo.addEventListener(Event.COMPLETE, onLoadedAction);
this.loaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErroAction);
function onLoadingAction (e:ProgressEvent):void
{
trace("loading");
}
function onLoadedAction (e:Event):void
{
this.loaderInfo.removeEventListener(ProgressEvent.PROGRESS, onLoadingAction);
gotoAndStop(currentFrame+1);
}
function ioErroAction (e:IOError):void
{
trace("Dev Ben " + e.toString());
}
此代码支持chrome和firefox.但如果我使用IE运行,它会坚持使用onLoadingAction.
在IE中运行我需要做什么?
public var:NoOfElements = 0;
public function addElement(){
// increases NoOfElements by one in every call
}
public function remvoveElement(){
// decreases NoOfElements by one in every call
}
Run Code Online (Sandbox Code Playgroud)
addElement和removeElement由两个单独的计时器事件调用.并且在每个方法中它修改全局变量NoOfElements.有没有一种方法来同步acionscript中的变量?
我已经通过XML加载了一些图像并附加到动态创建的名为mc0,mc1,mc2 ...等的MovieClip中.
_loader.removeEventListener(ProgressEvent.PROGRESS, onLoadingAction);
count++;
var img:Bitmap = Bitmap(e.target.content);
img.cacheAsBitmap = true;
img.smoothing = true;
img.alpha = 0;
TweenLite.to(MovieClip(my_mc.getChildByName("mc"+count)).addChild(img),1, {alpha:1,ease:Quint.easeIn});
Run Code Online (Sandbox Code Playgroud)
并在ENTER_FRAME处理程序内
for (i=0; i < mc.numChildren; i++)
{
my_mc.getChildAt(i).x -= Math.round((mouseX-stage.stageWidth/2)*.006);
}
Run Code Online (Sandbox Code Playgroud)
Everthing工作正常.但它正在颤抖,所以看起来并不好看.
如何实现平稳运动?
我有一个隐藏的DisplayObject(myObj.visible = false;).我提供了一个听众:
myObj.addEventListener(MouseEvent.CLICK, myHandler);
Run Code Online (Sandbox Code Playgroud)
通过myHandler永远不会开火.似乎MouseEvent.CLICK没有为隐藏的对象提供......我怎样才能听取MouseEvent.CLICK隐藏的对象?
我有一个非常基本的问题.为什么这不起作用?!
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="1000" height="550" minWidth="960" backgroundColor="#F2F0F0">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Label id="test1" x="43" y="259" text="Label"/>
<fx:Script>
<![CDATA[
test1.text = "Yay! This works...!";
]]>
</fx:Script>
</s:Application>
Run Code Online (Sandbox Code Playgroud)
我收到此错误:访问未定义的属性.
谢谢!