簡體   English   中英

在運行時在flex中加載Flash的符號

[英]load symbol of flash in flex at runtime

大家好,我在運行時從應用程序中的swf文件加載符號時遇到了一個巨大的問題。 我想加載它並將其作為參數傳遞給另一個可以在其中進一步使用的類。 符號名稱從“ o”對象的數組集合中傳遞。 任何人都可以告訴我什么是正確的方法..預先感謝.. !!

以下是參考代碼。

public override function Show(o:ObjectProxy):void
    {
        var _this:Weather;
        var _super:ContentItem;
        var item:WeatherItem;
        var items:ArrayCollection;
        var widgetCount:Number;
        var headlineFontSize:int;
        var conditionsIconThemeLoader:Loader;

        this.m_weatherWidgetContainer = new HBox();

        super.Show(o);

        _this = this;
        _super = super;

        (undefined == o["HeadlineFontSize"]) ? headlineFontSize = 20 : headlineFontSize = o["HeadlineFontSize"];

        if (undefined != o["direction"])
            this.m_textDirection = o["direction"];

        if (o.LargeUrl.Forecast is ArrayCollection)
            items = ArrayCollection(o.LargeUrl.Forecast);
        else
            items = new ArrayCollection([o.LargeUrl.Forecast]);

        widgetCount = this.m_computeWidgetSpace(items.length);

        conditionsIconThemeLoader = new Loader();

        conditionsIconThemeLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, function(e:Event):void
        {
            for(var i:uint = 0; i < widgetCount; i++)
            {
                var symbolClass:Class = e.currentTarget.loader.contentLoaderInfo.applicationDomain.currentDomain.getDefinition(int(items[i].condition)) as Class;
                var symbolInstance:Sprite = new symbolClass();

                item = new WeatherItem();
                item.Show(items[i], headlineFontSize, symbolInstance, widgetCount);

                _this.m_weatherWidgetContainer.addChild(item);
            }
        });

        conditionsIconThemeLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, function(e:IOErrorEvent):void
        {
            Alert.show("Failure loading " + WidgetStylesheet.instance.Weather_Widget_Theme + ".swf");
        });

        // Attempt to load theme weather icon file
        conditionsIconThemeLoader.load(new URLRequest("assets/animation/" + WidgetStylesheet.instance.Weather_Widget_Theme + ".swf"));

        super.media.addChild(this.m_weatherWidgetContainer);
    }

這是答案

public override function Show(o:ObjectProxy):void
{
    var _this:Weather;
    var _super:ContentItem;
    var conditionsIconThemeLoader:Loader;
    var loaderContext:LoaderContext;

    this.m_weatherWidgetContainer = new HBox();
    this.m_weatherWidgetContainer.percentHeight = 100;
    this.m_weatherWidgetContainer.percentWidth = 100;
    super.Show(o);

    _this = this;

    (undefined == o["HeadlineFontSize"]) ? this.m_headlineFontSize = 20 : this.m_headlineFontSize = o["HeadlineFontSize"];

    if (undefined != o["direction"])
        this.m_textDirection = o["direction"];

    if (o.LargeUrl.Forecast is ArrayCollection)
        this.m_items = o.LargeUrl.Forecast;
    else
        this.m_items = new ArrayCollection([o.LargeUrl.Forecast]);

    conditionsIconThemeLoader = new Loader();
    loaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);

    conditionsIconThemeLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, this.m_loaderSuccess);
    conditionsIconThemeLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, this.m_loaderFail);

    // Attempt to load theme weather icon file
    conditionsIconThemeLoader.load(new URLRequest("assets/animation/" + WidgetStylesheet.instance.Weather_Widget_Theme + ".swf"), loaderContext);

    this.m_weatherWidgetContainer.addEventListener(FlexEvent.CREATION_COMPLETE, this.m_drawHorizontalLine);

    super.media.addChild(this.m_weatherWidgetContainer);
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM