访问动态加载的影片剪辑(阶段>滚动面板> myloader>影片剪辑) [英] access dynamically loaded movieclip (stage > scrollpane > myloader > movieclip)

查看:157
本文介绍了访问动态加载的影片剪辑(阶段>滚动面板> myloader>影片剪辑)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要做的是访问

   snapText = scrollPane.source.textSnapshot;

从外部瑞士法郎。我尝试过:

from an external swf. I've tried:

  trace("-->: "+scrollPane.source.textSnapshot.getText(0, 1000));
  trace("-->: "+myLoader.content.textSnapshot.getText(0, 1000));
  trace("-->: "+mc.textSnapshot.getText(0, 1000));
  trace("-->: "+mc.getChildAt(0).textSnapshot.getText(0, 1000));
  trace("-->: "+mc.getChildByName(myLoader).textSnapshot.getText(0, 1000) );
  trace("-->: "+scrollPane.content.textSnapshot.getText(0, 100));

所有这些都是无果而终。 BTW:

all of which were fruitless. BTW:

  mc.getChildAt(0).textSnapshot.getText(0, 1000)

引发错误:

  1119: Access of possibly undefined property textSnapshot through a reference with static type flash.display:DisplayObject.

虽然我知道的方法是存在的。

although I know the method is there.

以上所有code运行在功能checkHandler:

all of the above code is run in the function checkHandler:

 myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, checkHandler);

因此​​SWF应该已经完全地加载。 该文本也有,我已经检查与闪客。 与装载机的影片剪辑也被类似创建

so the swf should have been completly loaded. The text is also there, I've checked with an swf decompiler. the movieclip with the loader is created like this

 scrollPane = MovieClip(root).scrollPaneOnStage;
 myLoader.load(new URLRequest("tmp1.swf"));
 mc.addChild(myLoader);
 scrollPane.source = mc;

在此先感谢!

thanks in advance!

更新 - 仍然没有得到解决

我现在访问的SWF为指出HotN。

I'm now accessing the swf as pointed out by HotN.

  function checkHandler(evt:Event):void {

         libMC  = evt.target.content as MovieClip;
         libMC.gotoAndStop(0); 
          trace(libMC.textSnapshot.getText(0, 100));
         snapText = libMC.textSnapshot;
        scrollPane.source = mc;
    }

这导致在第一个错误,因为在AS3脚本加载器不能加载一个AS2的电影(即AVM1)。所以我创建了一个 AVM2 瑞士法郎,而导致错误:错误#2000:没有活动的安全上下文作为一个解决方案,我使用的 http://www.igorcosta.org/?p=231 加载SWF,但仍的访问的TextSnapshot:

This resulted at first in an error, because the loader in an as3 script cant load an as2 movie (ie. AVM1). so I created an AVM2 swf which led to the error: Error #2000: No active security context. As a solution I used a class from http://www.igorcosta.org/?p=231 to load the swf, but still cant access the textSnapshot:

  trace(libMC.textSnapshot.getText(0, 100));

犯规返回任何东西并且不抛出一个错误!

doesnt return anything and doesnt throw an error!

BTW:虽然我可以改变的swf格式,我不能真正改变文件本身,因为它是自动生成的

BTW: while I could change the format of the swf, I cant really change the file itself since it's automatically generated.

推荐答案

因此​​,这花了我enterily太久,但我想通弄明白了。

So this has taken me enterily too long, but I got it figured out.

      //... {

        loader = new Loader();  
        loader.contentLoaderInfo.addEventListener(Event.COMPLETE, checkHandler);
        loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onError);
        var context:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain); 
        context.checkPolicyFile = false;
        loader.load(new URLRequest("tmp1.swf"), context);


      //..... }

      function checkHandler(evt:Event):void {

        loader.contentLoaderInfo.removeEventListener(Event.COMPLETE,checkHandler);

        libMC  = loader.content as MovieClip;

                    //works now!
            libMC.textSnapshot.getText(100, 200);

        scrollPane.source = libMC;


    }

这样的伎俩是使用类似建议这么多次的标准装载函数。然而,闪存莫名其妙打乱了我的本地PC,这就造成了错误#2000的安全性/沙箱设置:没有活动的安全上下文。然而,它仍然能正常工作时,上传到远程服务器,这很奇怪。您可以设置本地播放设置为只访问本地文件下的文件>发布设置,但是没有帮助在所有在我的情况下...

so the trick was using the standard loader function like suggested so many times. however flash somehow messes up the security/sandbox settings on my local pc, which resulted in a Error #2000: No active security context. however it still worked fine when uploaded to a remote server, which is strange. you can set the local playback settings to "access local files only" under File > Publish Settings, but that didnt help at all in my case...

这篇关于访问动态加载的影片剪辑(阶段>滚动面板> myloader>影片剪辑)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆