首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >转换bitmapData

转换bitmapData
EN

Stack Overflow用户
提问于 2009-12-08 10:15:45
回答 1查看 475关注 0票数 0

我正在尝试加载几个jpeg图像动态XML到fla的bitmapdata对象。我可以在这个.swf文件的舞台上看到它们。

但是,我将其加载到另一个.swf中,这是我在单击其中一个菜单选项时要调用的主要内容。

我得到了这个错误:错误#1034:类型强制失败:无法将com::this @1daf4ca1转换为flash.display.MovieClip。

有人知道怎么转换吗??

代码语言:javascript
运行
复制
private function initBitmapFile(file:String):void
    {
        loadBMP = new Loader();
        loadBMP.load(new URLRequest(file));
        loadBMP.contentLoaderInfo.addEventListener(Event.COMPLETE, handleLoadedBitmap);
    }



private function handleLoadedBitmap(event:Event):void
{
  bitmapData = Bitmap(LoaderInfo(event.target).content).bitmapData;
 }

    public function Fashion()
    {
        loadXML = new LoadXML(PHOTOFILE, handleLoadedPhotos);
    }   


    private function handleLoadedPhotos(event:Event):void
    {
        xmlItems = new XML(event.target.data);
        listItems = new ParseXML(xmlItems);
        var test:MovieClip = new MovieClip();

        var getListItems = listItems.getXMLListElements();

        for each (var item:XML in getListItems) {
            tabPhotos.push({ url:item.url });
        }

        for (var i:uint=0;i<tabPhotos.length;i++) {
            loadBitmap = new LoadBitmap(tabPhotos[i].url);
            addChild(loadBitmap);
        }
    }

menuOption.addEventListener(MouseEvent.CLICK, handleOptionClicked);
private function handleOptionClicked(event:MouseEvent):void
    {
        switch(event.target.name) {
            case "Fashion" : 
                loader.load(new URLRequest("fashion.swf"));
                break;
            case "Beauty" :
                loader.load(new URLRequest("beauty.swf"));
                break;
            case "Contact" :
                trace("Contact");
                break;      
        }

        // to know when next page is finished loading
        loader.contentLoaderInfo.addEventListener(Event.COMPLETE, handleFileLoaded);
    }

    private function handleFileLoaded(event:Event):void
    {
        // Contains the page we're going to display
        nextPage = event.target.content; // It crash Here!!!


        // If there's a current page, check when clicked on to next page is loaded 
        if (currentPage != null) {
            trace('Animate currentpage to disappear...');
            // Animate to dispappear the current page
            var tweenX = new Tween(currentPage, "x", Regular.easeOut, currentPage.x, 500, 1, true);
            var tweenAlpha = new Tween(currentPage, "alpha", Regular.easeOut, 1, 0, 1, true);

            tabTween.push(tweenX);
            tabTween.push(tweenAlpha);

            // Show the next page 
            tweenX.addEventListener(TweenEvent.MOTION_FINISH, currentPageGone);

        // If no current page, show and animate next page
        } else {
            trace('show next page')
            showNextPage();
        }


    }
EN

回答 1

Stack Overflow用户

发布于 2009-12-12 17:33:44

nextPage是什么类型的对象?也许你可以试试这种方式。

代码语言:javascript
运行
复制
 private function handleFileLoaded(event:Event):void {
     // Contains the page we're going to display
     // nextPage = event.target.content; // It crash Here!!!       

     var nextPage:DisplayObject = event.target.content as DisplayObject;
 }

只是一个想法,告诉我它是否有助于干杯

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1864184

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档