如何在Flex中缩放图像以适合画布?我的代码如下:
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"
horizontalAlign="center"
width="100" height="100"
verticalGap="0" borderStyle="solid"
initialize="onLoad()"
horizontalScrollPolicy="off"
verticalScrollPolicy="off">
<mx:Canvas width="100%" height="100%" id="PictureBox" horizontalScrollPolicy="off"
verticalScrollPolicy="off" />
<mx:Label id="NameLabel" height="20%" width="100%"/>
<mx:Script>
<![CDATA[
private function onLoad():void
{
var image:SmoothImage = data.thumbnail;
image.percentHeight = 100;
image.percentWidth = 100;
this.PictureBox.addChild(image);
var sizeString:String = new String();
if ((data.fr.size / 1024) >= 512)
sizeString = "" + int((data.fr.size / 1024 / 1024) * 100)/100 + " MB";
else
sizeString = "" + int((data.fr.size / 1024) * 100)/100 + " KB"; …Run Code Online (Sandbox Code Playgroud) 有没有办法隐藏预加载器.我的一个想法是创造一个空的新的,但肯定有一个更简单的方法来做到这一点.
这可能听起来像一个愚蠢的想法,但在某些情况下,隐藏预加载器可能会很好.特别是如果它不需要很多工作.
我对Flex/ActionScript比较陌生,但我一直在使用我的util包中为每个函数创建一个文件的模式 - 文件名与函数名相同.就像文件是convertTime.as一样:
package util{
public function convertTime(s:String):Date{
...
}
}
Run Code Online (Sandbox Code Playgroud)
这样我就可以通过以下方式轻松导入函数:
import util.convertTime;
...
convertTime(...);
Run Code Online (Sandbox Code Playgroud)
我喜欢这种方式比导入类对象然后调用挂起它的静态方法更好,如下所示:
import util.Util;
...
Util.convertTime(...);
Run Code Online (Sandbox Code Playgroud)
但是,我做的越多,我最终会得到的文件越多,将一个函数放入文件中似乎有点浪费/愚蠢,特别是当函数很小时.还有另一种选择吗?或者这两个选项是我唯一的选择吗?
更新:经过一些研究,我也在下面发布了自己的答案.
我有一个单例类用于全局访问配置信息.这个名为ConfigurationData的单例类扩展了EventDispatcher.这是一个类(请注意,我保留了一些像变量声明一样的东西来保持这个简短):
/**
* Dispatched when the config file has been loaded.
*/
[Event (name="configurationLoaded", type="flash.events.Event")]
/**
* Dispatched when the config file has been loaded.
*/
[Event (name="configurationLoadFailed", type="flash.events.Event")]
public class ConfigurationData extends EventDispatcher{
// Event name constants.
public static const CONFIGURATION_LOADED:String = "configurationLoaded";
public static const CONFIGURATION_LOAD_FAILED:String = "configurationLoadFailed";
// The singleton instance.
private static var singleton:ConfigurationData;
/**
* Don't call the constructor directly, use getInstance() instead.
*/
public function ConfigurationData(pvt:PrivateClass){
// init
}
/**
* Get the singleton …Run Code Online (Sandbox Code Playgroud) 替代文字http://www.mattdell.com/hostedfiles/flexchartissue.bmp
我遇到一个问题,即刷新数据时,Flex Pie Chart上的图表标签不会消失。在上图中,图表的左/前是默认情况下图表的加载方式。通过从下拉列表中选择另一个项目,图表将更改为右/后图表,但“处于风险中”标签不会消失。对于“工作中”不消失的另一个选择也是如此。
还有其他人发生过这种事吗?我找不到任何相关信息!
-马特
由于我无法控制的要求(不要问,这太荒谬了)我需要创建一个名为'Math'的AS3类,它引用Global AS Math类.所以,例如:
package my.package
{
public class Math
{
public static function pow( a:Number, b:Number ):Number {
// How do I call the Global.as$Math#pow(..) function?
return Math.pow(a,b);
}
}
}
Run Code Online (Sandbox Code Playgroud)
上面的代码显然是错误的 - 导致无限递归.我不知道怎么说我想委托给Global.as $ Math课而不是这个Math课......
我当前的尴尬解决方案是委托另一个传递给Global Math类的类(不是名为Math).有一个更好的方法吗?
谢谢!
这个看起来很基本,但我不知道怎么做 - 其他人?
我有一个看起来像这样的字符串:
private var url:String = "http://subdomain";
Run Code Online (Sandbox Code Playgroud)
我需要什么正则表达式,所以我可以这样做:
url.replace(regex,"");
Run Code Online (Sandbox Code Playgroud)
结束了吗?
trace(url); // subdomain
Run Code Online (Sandbox Code Playgroud)
或者有更好的方法吗?
我从http://www.3dfreeair.com下载一些动画.那么如何在没有Adobe AIR的情况下运行?我怎样才能在linux操作系统中安装?
我是初学者所以不要误会我.我对空气一无所知.PLZ伙伴们为我提供技术支持.
HI,
我试图从我的动作脚本代码调用一个javascript函数,但它没有工作;
AS3:
if (ExternalInterface.available)
{
try
{
ExternalInterface.addCallback("changeDocumentTitle",null);
}
catch(error:Error)
Run Code Online (Sandbox Code Playgroud)
js(使用swfobject的内部速度文件)
function changeDocumentTitle()
{
alert('call from SWF');
}
Run Code Online (Sandbox Code Playgroud)
有谁知道会发生什么?