Load flex swf as a child swf

Is there anyway to load a flex (or any swf with AIR capabilties) into a parent swf?

I just found out you can load the flex SWF directly into the swfLoader... I feel very stupid now. Should have tried that a longggg time ago.

Similar Messages

  • Use cs4 make loader load flex swf width/height problem

    hi,all:
      i use cs4 make as3 loader from SharedObject.getLocal, load flex make swf file, so width/height is not Ok
    load cs4 make swf file is Ok,
    why?
    as3code:
    // copy right china summer xiatian qq 11602011
    package{
      import flash.net.SharedObject;
      import flash.utils.ByteArray;
      import flash.display.*;
      import fl.controls.*;
      import flash.net.URLRequest;
      import flash.net.URLRequestMethod;
      import flash.system.ApplicationDomain;
      import flash.system.LoaderContext;
      import flash.net.*;
      import flash.utils.*;
      import flash.external.ExternalInterface;
      import flash.system.*;
      // http://as3corelib.googlecode.com/svn/trunk/src/com/adobe/crypto/MD5.as
      import com.adobe.crypto.MD5;
      import flash.events.*;
          public class MyCacheLoader extends Sprite
              public function MyCacheLoader()
                  Security.allowDomain("*");
                  Security.exactSettings = true;
                  function getStr(s:String):String
                     return ExternalInterface.call("(function(){return window['" + s + "'];})")  || '';
                  function MyLog(s:String):void
                      // ExternalInterface.call("(function(){var o = document.getElementById('myLog');o.value += '" + s + "' + '\n\n';})");
                      ExternalInterface.call("(function(){top.alert('" + s + "');})");
                      // myTestTxt.text = myTestTxt.text + s + "\n\n";
                  var bLoadSwf:Boolean = true;
                  var parm:Object = loaderInfo.parameters;
                  // parm["u"] = "/xuicore/test/myTest.swf";
                  // parm["v"] = "4.4";
                  var szUrl:String = parm['c'] + "/CMHS?jsessionid=" + parm['s'] + "&CMHS=GetOutSpFile&rmpath=rs/&rmf=" + parm["u"] + ".swf",
                      szVer:String = parm["v"], szName:String = parm["u"];// "X" + MD5.hash(parm["u"]);
                  var loader:Loader = new Loader();
                  var so:SharedObject = SharedObject.getLocal(szName);
                  loader.x = loader.y = 0;
                  addChild(loader);
                  function showSwf(byteArray:ByteArray):void
                    // MyLog("开始显示处理: " + byteArray.length);
                    if(0 >= byteArray.length)return;
                    bLoadSwf = false;
                    // loader.visible = false;
                    configureListeners(loader.contentLoaderInfo);
                    var context:LoaderContext = new LoaderContext(false,ApplicationDomain.currentDomain);
                    // context.allowLoadBytesCodeExecution = true;
                    loader.loadBytes(byteArray, context);
                  function displaySwf():void
                     var oData:Object = so.data;
                     // MyLog([szVer, oData.version].join(" = "));
                     if(szVer == oData.version)
                       showSwf(so.data.swf as ByteArray);
                     else downloadSwf();
                  var ldr:URLStream = new URLStream();
                  function downloadSwf():void
                      bLoadSwf = true;
                      // MyLog(szUrl);
                      var ur:URLRequest = new URLRequest(szUrl);
                      ur.data = new Date().getTime();
                      ur.method = URLRequestMethod.POST;
                      configureListeners(ldr);
                      ldr.load(ur);   
                  function configureListeners(dispatcher:IEventDispatcher):void {
                      dispatcher.addEventListener(Event.COMPLETE, completeHandler);
                      dispatcher.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
                      dispatcher.addEventListener(Event.INIT, initHandler);
                      dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
                      dispatcher.addEventListener(Event.OPEN, openHandler);
                      dispatcher.addEventListener(ProgressEvent.PROGRESS, progressHandler);
                      dispatcher.addEventListener(Event.UNLOAD, unLoadHandler);
                      if(!bLoadSwf)dispatcher.addEventListener(Event.INIT,loaded);
                  function removeListeners(dispatcher:IEventDispatcher):void {
                      dispatcher.removeEventListener(Event.COMPLETE, completeHandler);
                      dispatcher.removeEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
                      dispatcher.removeEventListener(Event.INIT, initHandler);
                      dispatcher.removeEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
                      dispatcher.removeEventListener(Event.OPEN, openHandler);
                      dispatcher.removeEventListener(ProgressEvent.PROGRESS, progressHandler);
                      dispatcher.removeEventListener(Event.UNLOAD, unLoadHandler);
                      if(!bLoadSwf)dispatcher.removeEventListener(Event.INIT,loaded);
                  function loaded(e:Event):void{
                          loader.x = loader.y = 0;
                          loader.content.y = loader.content.x = 0;
                          var s:String = "", k:String, obj:Object = loader.content;
                          // for(k in obj)s += k + " = " + obj[k] + ";";
                          // obj.width = "100%", obj.height = "100%";
                          // MyLog([obj.width, obj.height].join(", "));
                          loader.x = -180;
                          loader.scaleX = 1.83;
                          loader.scaleY = 1.05;
                          // loader.content.height = stage.stageHeight;
                          // loader.scaleContent = true;
                          // loader.content.width = stage.width,loader.content.height = stage.height;
                          // loader.content.stage.stageWidth = stage.stageWidth,loader.content.stage.stageHeight = stage.height;
                          // loader.content.stage.scaleMode = "exactFit";
                          setTimeout(function(){
                            // loader.x = loader.content.x = 0;
                            var fullWidth:Number = loader.content.width;
    var fullHeight:Number = loader.content.height;
    var stageWidth:Number = loader.content.loaderInfo.width;
    var stageHeight:Number = loader.content.loaderInfo.height;
    var fixOffStageScaleX = fullWidth / stageWidth;
    var fixOffStageScaleY = fullHeight / stageHeight;
                            loader.content.scaleX = fixOffStageScaleX,loader.content.scaleY = fixOffStageScaleY;
    // loader.content.width = stage.width * 1.59;loader.content.height = stage.height * 1.15;
                            // loader.content.width = stage.stageWidth,loader.content.height= stage.height;
                            // loader.width = stage.stageWidth,loader.height= stage.height;
                            // loader.content.stage.scaleMode = "exactFit";                       
                          }, 3000);
                  var _byteArray:ByteArray = new ByteArray();
                  function completeHandler(event:Event):void {
                      if(bLoadSwf)
                          if(0 < _byteArray.length)
                             so.data.swf = _byteArray;
                             so.data.version = szVer;
                             try{so.flush();}catch (e:Error){}
                             removeListeners(ldr);
                             showSwf(_byteArray);
                          else removeListeners(ldr);
                          bLoadSwf = false;
                          ldr = null;
                      else
                          removeListeners(loader.contentLoaderInfo);
                          // loader.visible = true;
                          // loader.content.width = (height / loader.content.height) * loader.content.width;
                          // loader.content.height = (width / loader.content.width) * loader.content.height;
                          if(isNaN(loader.content.width) || 0 >= loader.content.width)
                            setTimeout(function(){
                             loader.content.width = stage.stageWidth;
                             loader.content.height = stage.stageHeight;
                          }, 4000);
                          // width=loader.content.width;  height=loader.content.height;
                          // MyLog("显示处理完毕");
                  function httpStatusHandler(event:HTTPStatusEvent):void {
                      // MyLog("httpStatusHandler: " + event);
                  function initHandler(event:Event):void {
                      // MyLog("initHandler: " + event);
                  function ioErrorHandler(event:IOErrorEvent):void {
                      // MyLog("ioErrorHandler: " + event);
                  function openHandler(event:Event):void {
                      // MyLog("openHandler: " + event);
                  function progressHandler(event:ProgressEvent):void {
                      // MyLog(bLoadSwf + ": progressHandler: bytesLoaded=" + event.bytesLoaded + " bytesTotal=" + event.bytesTotal);
                      if(bLoadSwf)
                        var urlStream:URLStream = event.currentTarget as URLStream;
                        while (urlStream.bytesAvailable)
                           urlStream.readBytes(_byteArray, _byteArray.length);
                  function unLoadHandler(event:Event):void {
                      // MyLog("unLoadHandler: " + event);
                  displaySwf();
    flex code:
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" horizontalAlign="left" layout="absolute"
    paddingLeft="2"
        paddingTop="2"
        paddingBottom="2"
        paddingRight="2"
        autoLayout="true"
        width="100%"
        height="100%"
    backgroundGradientColors="[0x000000,0xBAD3F9]"
    ">
    </mx:Application>
    must:
    width="100%"
    height="100%"

    loader from SharedObject.getLocal, use SharedObject.getLocal cache bytearray swf data is ok,
    so, Can be seen as not with urlstream
    loader.loadBytes(byteArray, context);
    as3 cs4
    flex sdk 3.3.0.4852

  • Can I load a swf into my Flex app that loads other swf's?

    The code below loads an AS2 swf into my Flex mobile for IOS app and it works.  If that AS2 swf has like a circle in it that runs across the stage, it loads and displays properly when run in FlashBuilder.
    <?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"
                                     initialize="init()">
              <fx:Script>
                        <![CDATA[
                                  import mx.core.UIComponent;
                                  private var request:URLRequest = new URLRequest("http://PATH_TO_AS2_SWF");
                                  private var loader:Loader = new Loader();
                                  private var myComponent:UIComponent = new UIComponent; 
                                  private function init():void{
                                            myComponent.percentHeight = 100;
                                            myComponent.percentWidth = 100;
                                            loader.load(request);
                                            myComponent.addChild(loader);
                                            player.addElement(myComponent);
                        ]]>
              </fx:Script>
              <s:Group id="player"
                                   height="100%" width="100%"/>
    </s:Application>
    But if that AS2 swf loads other swf's, they don't load or display.  My FlashBuilder debugger reports no errors or security sand box violations.   I'm using the most elemental code in my AS2 swf so as to not cause problems.  This is it in its entirety:
    this.onLoad = function(){
              _root.loadMovie("http://[PATH_TO_REMOTE_SWF]");
    The paths to the remote content are fine because swf's load and display fine from AS2 swf when run on it's own - not embedded in Flex app.  They also load and run fine if I cut out the AS2 swf and access directly from my Flex code.  So I know there isn't a path issue.  More likely not accessing the right layer in the AS2 swf from Flex or something.  Or maybe security sandbox violation but I don't see anything reported in the FlashBuilder debug console.  When run console just reports:
    [SWF] SwfMobile.swf - 2,639,761 bytes after decompression
    [SWF] assets/swf/AS2.swf - 1,470 bytes after decompression
    Is there something inherently wrong with loading swf's that load other things?  Even if I have the AS2 swf load jpgs they don't load so the format of the target content at the end of the chain doesn't seem to be the issue.  Just the act of embedding a swf that loads other things seems to be the problem.

    Ah, yes. Using an AVM1 SWF could prove difficult...
    I'm going on about 3 hours of sleep at the moment, but let me toss out a few thoughts I have and hopefully something will stick...
    Ok, so my first thought what to try and cast the loaded content as a MovieClip and call methods on that, but the fact they are AVM1 throws that out the window.
    That leaves LocalConnection, as you mentioned. But this would require you to have code on the receiving end to handle the connection... no good either.
    But what if you created a "bridge" in AS2 that holds all the code for the receiving end of LocalConnection (or has the control logic itself, perhaps even eliminating the need for LocalConnection all together!). I think maybe this is what you were trying to do already by loading a SWF into a SWF? Well instead of loading your bridge at runtime, what if you statically linked it into your project as a class?
    *a few moments later*
    Well it looks like you can in fact link in a a symbol created for AVM1, but it will only come in as a SpriteAsset, and will not include any custom code (which makes sense, since they use entirely different class constructs).
    To do the test, I created a symbol exported for actionscript (AS2/Flash8), then linked it in with a CSS style embed. I then instantiated the class and called describeType on it.
    So in summery, it looks like calling custom code on the bridge is out (I did not test this extensively, that was just my first impression with this simple test). However, if you may be able to perform the actions you need by attempting to cast the loaded content into something AVM2 can recognize. Apparently it does this automatically when linked in statically, so maybe there is something there worth looking into... mainly, can you do what you need using only the base class and no custom code?
    Keep me posted!

  • Flex swf loaded in Flash swf

    Hi,
    I have a Flex swf loaded into a Flash swf.
    I have made the Flex swf transparent, so that the buttons in the Flash swf are visible.
    But im unable to interact with the Flash swf buttons.
    My Flex swf is working happyily
    The Flex swf overlays the Flash swf.
    If i change the scrollRect of the Flex swf so the Flex swf is not overlaying the Flash swf i can successfully interact with the Flash swf buttons.
    Any ideas?
    Regards,
    Kyle

    Thanks Alex,
    I actually found an old post on a forum where you recommended a similar solution (mousesheld.visible = false).
    This seems to work although it messes with dragging (my Popups at least).
    But i can work with that for now, thanks for your help.
    Regards,
    Kyle

  • Loading a flex swf into a spry tab area

    I have a spry tabbed panel in one of the panels I am
    attempting to load an swf that I created using Flex builder. The
    swf runs fine when run standalone but from within the spry tab
    although it does load and run correctly I get a nasty error message
    in both Firefox and Explorer :
    Exception caught while loading
    /azek-landing-page/bin-release/azekLandingPage.html: [Exception...
    "Access to restricted URI denied" code: "1012" nsresult:
    "0x805303f4 (NS_ERROR_DOM_BAD_URI)" location:
    "file:///C:/Sites/interstate/wwwroot/SpryAssets/SpryData.js Line:
    94"]
    I read somewhere that this has to do with Ajax and some cross
    domain issue, but at this point I'm not sure what to do.
    Any suggestions would be appreciated.
    Thanks

    Hi, You probably meant to post your thread in the Flash Forum or perhaps the Flex forum. I'm not sure, but this is the Flash Player Forum.
    http://forums.adobe.com/index.jspa  This gives the list of Forums.
    Thanks,
    eidnolb

  • HELP PLEASE - loading external swf scale problem

    I have a Flex 3 Actionscript Project. Basically all it does it take some flash vars, set the sound volume,  and load an external swf using a loader and add the loader as a child. The problem is I want the loaded external swf to be scaled to fill the entire stage, even if it distorts it, and that doesn't seem to be happening.
    I really need to resolve this. ANY HELP APPRECIATED.
    Marcus

    Thanks for the reply!
    Here's basically what my code looks like (note: I cut some stuff out that wasn't relevant for the sake of clarity).
    private var swfLoader:Loader = null;
    public function MySwfContainer()  
        stage.scaleMode = StageScaleMode.EXACT_FIT;
        stage.align = StageAlign.TOP_LEFT;
        var request:URLRequest = new URLRequest(swfUrl);
        swfLoader = new Loader();
        swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,SWFLoader_Complete);
        swfLoader.load(request);       
    private function SWFLoader_Complete(event:Event):void
        addChild(swfLoader);
    What I am observing is that if a swf larger than the stage area is loaded it clips it rather than scale it down and make it fit.
    Marcus

  • Loading external swfs extending from classes in the same shared codebase

    Hey there!
    I'm currently developing a game in flash and want to be able to divide up my .fla assets in a way that means artists can work on a game menu .fla in isolation from the game.fla and rest of the game code.
    If I could briefly explain how I've approached this so far, I would be extremely if people could shout in my general direction and tell me I am stupid, or even better still, give me helpful advice as to where I am going wrong and how I can correct it!
    My project is setup like this:
    HighScoreMenu.fla -> document class HighScoreMenu extending GameMenu class.
    game.fla ->document class game.as
    game.as class loads the published HighScoreMenu.swf and manipulates the menu i.e. animates on and off screen via inherited functions in the GameMenu class.
    Now this seemed to work to begin with, until my code evolved and upon going to publish my HighScoreMenu.fla flash started complaining about symbols being used in Game.as that were in Game.fla...  If I'm only publishing the HighScoreMenu which extends from GameMenu then why is it even looking to compile Game.as?
    Can you spot the problem in the way I am doing this, or is there a better approach I should try?
    Any advice greatly appreciated!
    Stevie.

    No it doesn't seem to, however though they both have a reference to the HighScoreManager so there is some overlap there between menu and game code, but the menu classes don't reference any symbols on the game.fla...
    Just to clarify, I have an fla HighScoreMenu.fla, which has a child symbol HighScoreMenu which uses the following class.
    public dynamic class HighScoreMenu extends GameMenu
         //convenient storage for competition Manager object
         private var _highScoreManager:HighScoreManager;
    The game then loads this class as follows:
    I load the swf "HighScoreMenu.swf" and once its loaded I obtain the menu class like so:
    var cls:Class = Class( applicationDomain.getDefinition("Menus.HighScoreMenu") );
    var object:* = new cls();
    ...and create a new instance of the menu.
    Is there anything fundamentally wrong with approaching it in this way?

  • How to load external SWF used sharing library.

    Hi~~~
    Before ask the question, plz understand my bad English..
    Recently I try to load the Swf file that is maded by Flash CS 6.0.
    Especially it used shared library..
    When I try to load this SWF, I used FileStream instead URLRequest.
    This is because the target SWF File located same device with the Swf Application.. So when I use the URLRequest
    it give me the warning - Sandbox security violation.
    But by using FileStream, the warning did not occur.
    This is the sample code below..
      var myFile = new File(path);
      var myStream = new FileStream();
      myStream.open(myFile, FileMode.READ;
      var myBytes:ByteArray = new ByteArray();
      myStream.readBytes( myBytes );
       mSwfLoader.loadBytes( fileStream, context );
       mSwfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadedComplete);
    As you can see, I made a event listener to get the content of the Loader, after receving Complete Event(I guess.. after decording?).
    But I can't receive any event call, so I removed symbol used sharing library in the SWF.
    And this gave me the result as I respected... So I guess the problem caused by using sharing Library..!
    (In parenthease, I can see the valid result in running debug time on the Flash CS6..)
    What should I do? I respect that using sharing libary give saving memory.  So I want to using it as possible.
    Thanks for your reading...!

    Here is one way:
    http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7f9c.html
    HTH,

  • How to embed Flex swf into existing Flash?

    Hello,
    I am brand new to Flex, so I desperately need your help!
    I have an existing Flash file, written in Flash 8. When I
    open this file, it plays in Flash Player 9, the latest player I
    have installed on my machine.
    This Flash file tries to dynamically load about.swf, a stub
    file created by the designer. It works.
    I am a programmer, so I want to create my own about.swf in
    Flex 2 and then substitue the existing about.swf written in Flash
    with my about.swf written in Flex. The problem is that the existing
    Flash file just displays a blank when I try loading about.swf
    written in Flex.
    Is there any way to load SWF file written in Flex 2 into an
    Flash file written in Flash 8?
    Thank you for your help!!!
    Evgueni

    I think no.
    Flash 8 uses Actionscript 2.0, but Flex 2.0 uses AS3. I think
    these will be incompatible, as they use different VMs.
    If the two swf's exist individually, in their res[pective VM,
    you can communicate between them using LocalConnection.
    Tracy

  • Accessing resources in loaded/external SWFs

    I've been looking around for an effective way of solving this
    issue, but without much like. What I'm trying to accomplish is
    creating a container for my newest Flash site in main.swf and
    loading other swf files that provide resources that modify mcs,
    functions etc. of the main.swf. I plan to have main.swf hold my
    background, logo etc. then each subrelated page as contact.swf,
    index.swf to be placed on top of that swf.
    I did find this thread:
    http://www.kirupa.com/forum/archive/index.php/t-241538.html
    but all I managed to get from it is how to reference elements in
    the child from the parent using Loader.content. What I'm trying to
    figure out is how to reference from the child to the parent. ie. if
    I want to modify the background of the main.swf which is contained
    in a function called changeBackground().
    To add some more complexity I am trying to keep as much of my
    code in .as files that are placed in the Document class. So for
    each main.fla I have a main.as and index.fla is index.as. In my
    index.as script I need to determine how to access objects/functions
    contained in main.as.
    I HOPE that I've explained that all properly. If I'm being
    confusing or using inappropriate terms - apologies.

    First, you need a loadComplete function in your icMain class
    to get called after the swf is loaded. You set up that relationship
    already in this line:
    indexLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,
    loadComplete);
    so you need this:
    private function loadComplete(event:Event):void
    then, move these functions into the loadComplete function as
    you have to wait until the swf is loaded before setting the
    reference:
    var indexPage:indexPage = indexLoader.content as indexPage;
    indexPage.icMain = this;
    In your indexPage class, you need to move your set mainSWF
    function outside of the indexPage function. Also, the type of
    object you are passing, according to your code, should be icMain.
    So, instead of this:
    public function indexPage():void
    public function set mainSWF(icMain:MainSWFDocumentClass):void
    _icMain = icMain;
    Do this (notice I changed the name of your variable to avoid
    name conflict. using the convention of starting class names with a
    Capital letter would help too):
    private var _mainSWF:icMain;
    public function indexPage():void
    public function set mainSWF(mainSWF:icMain):void {
    _mainSWF = mainSWF;
    Here is the rewritten icMain class:
    package
    public class icMain extends Sprite
    public function icMain():void
    var indexRequest:URLRequest = new
    URLRequest("index/index.swf");
    var indexLoader:Loader = new Loader();
    indexLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,
    loadProgress);
    indexLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,
    loadComplete);
    indexLoader.load(indexRequest);
    private function loadComplete(event:Event):void
    var indexPage:indexPage = indexLoader.content as indexPage;
    indexPage.icMain = this;
    And here is your rewritten indexPage class:
    package {
    public class indexPage extends Sprite
    private var _mainSWF:icMain;
    public function indexPage():void
    public function set mainSWF(mainSWF:icMain):void {
    _mainSWF = mainSWF;

  • Bring loaded external swf to the front

    Hi,
    I am now implementing to create a website using side scrolling platform game approach. Since the player/actor (character that moves according to keyborad events) should always be at the top layer, I am having difficulties to get my loaded swf on top of the player. I am currently using Flash cs6 (as3).
    Basically, in my main stage, there are 3 layers. 1 for actionscript, the scond one for player and lastly for background.
    Layer player contains player mc and background mc.
    Background mc contains visual and collisions layers.
    Anything that got to do with visual, i have to put it in visual layer.
    In visual layer i have backgroundcontainer mc
    So, as i put the button in the backgroundcontainer mc to call the external swf, the loaded external swf appears in the container.
    (I am using load/unload snippet code to call the external swf)
    I want the external swf to appear on top of the player.
    for (var fl_ChildIndex_2:int = 0;
            fl_ChildIndex_2 < this.numChildren;
            fl_ChildIndex_2++)
        this.getChildAt(fl_ChildIndex_2).addEventListener(MouseEvent.CLICK, fl_ClickToBringToFront_2);
    function fl_ClickToBringToFront_2(event:MouseEvent):void
        this.addChild(event.currentTarget as DisplayObject);
    Any help would greatly appreciated 

    If you want an object to move atop all others you can just use addChild(thatobject), where thatobject is the item you want to move atop anything else.  I don't know what object(s) your loop is attempting to act on, but it appears to be trying to change the index of all child objects rather than just one.

  • Problem loading one SWF into another in Flash AS3

    I am trying to load an SWF file in another SWF file. The child SWF file works fine when run standalone like if I set visibility of an item to true or false, it works fine. But when the SWF is loaded into a parent SWF, I am not able to execute such commands, neither I get any errors...

    are both swfs as3 swfs?
    is the code in the loaded swf and is that code referencing objects in the loaded swf?

  • Loading external SWF with masked content - get size of masked area

    I am loading an external swf using the SWFLoader component. The swf that is being loaded is masked so that only a portion is being shown. However, when it's loaded the actual size of the swf (loader.content.width && loader.content.height) is the complete swf including the masked area. Therefore, the loaded swf does not display properly in the itemrenderer Is there a way to to grab the size of the just the masked area as opposed to getting the size of the entire swf's contents (area not masked)?
    One item to note that is complicating the issue, is that these are swf files that have already been created and there are many of them. In some instances, the size of the stage matches up with the size of the masked area. In other instances, the stage is larger (or possibly smaller) than the masked area movieclip as well as possibly the actual size of the movieclip (w/o the mask).
    I am currently loading the external swf in using a Loader. Once loaded, I make a copy (screen shot) of the swf by creating a bmp of the loader.content.This is done as I don't want to have any animations being shown on screen at this moment. I am setting the size of the bmp using using loader.content.width & loader.content.height. I then set the SWFLoader.source to the bitmap.

    Here's the code I am using to load the swf:
         <fx:Script>
                <![CDATA[
            protected  function application1_applicationCompleteHandler(event:FlexEvent):void {
                 loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onSWFLoaded);
                 loader.load(new URLRequest("c:\\Flex Testing\\FA warns Mr. Jones.swf"),  context);
            private function  onSWFLoaded(event:Event):void {
                bmData=new  BitmapData(loader.content.width, loader.content.height, true, 0x990000);
                 bmData.draw(loader.content, new Matrix());
                bmp=new  Bitmap(bmData);
                swfLoader.source=bmp;
                 addElement(swfLoader);
                with (swfLoader)
                    setStyle('verticalAlign', "middle");
                     setStyle('horizontalAlign', 'center');
                     verticalCenter=0;
                    horizontalCenter=0
                     scaleContent=true;
                    maintainAspectRatio=true;
                     addEventListener(MouseEvent.CLICK,onClick,false,0,true)
                     useHandCursor = true;
                    buttonMode = true;
                     width=200;
                    height=200;
                 loader.unload()
                loader=null;
               ]]>
    </fx:Script>

  • Flex swf in a spry tabbed panel

    I have a spry tabbed panel in one of the panels I am
    attempting to load an swf that I created using Flex builder. The
    swf runs fine when run standalone but from within the spry tab
    although it does load and run correctly I get a nasty error message
    in both Firefox and Explorer :
    Exception caught while loading
    /azek-landing-page/bin-release/azekLandingPage.html: [Exception...
    "Access to restricted URI denied" code: "1012" nsresult:
    "0x805303f4 (NS_ERROR_DOM_BAD_URI)" location:
    "file:///C:/Sites/interstate/wwwroot/SpryAssets/SpryData.js Line:
    94"]
    I read somewhere that this has to do with Ajax and some cross
    domain issue, but at this point I'm not sure what to do.
    Any suggestions would be appreciated.
    Thanks

    I have a spry tabbed panel in one of the panels I am
    attempting to load an swf that I created using Flex builder. The
    swf runs fine when run standalone but from within the spry tab
    although it does load and run correctly I get a nasty error message
    in both Firefox and Explorer :
    Exception caught while loading
    /azek-landing-page/bin-release/azekLandingPage.html: [Exception...
    "Access to restricted URI denied" code: "1012" nsresult:
    "0x805303f4 (NS_ERROR_DOM_BAD_URI)" location:
    "file:///C:/Sites/interstate/wwwroot/SpryAssets/SpryData.js Line:
    94"]
    I read somewhere that this has to do with Ajax and some cross
    domain issue, but at this point I'm not sure what to do.
    Any suggestions would be appreciated.
    Thanks

  • Loading external swf, how to deal with errors within the loaded swf?

    I have a Flex app that basically lets you browse a bunch of thumbnails that represent swf files, when you click a thumbnail it opens a window that loads the actual swf into an image control. The problem I have is that these swfs can be uploaded by our clients, so they may have actionscript errors being thrown, etc. We can't really predict what they may do. Is there a way I can load these swf in such a way as to ignore any errors that the loaded swf may generate within itself.
    For example, one such swf reads some text from a text file to display, but when they are viewing it in this manner the file isn't there so a stream error is generated. My parent Flex app doesn't care about this error and I don't want to see it thrown up in an actionscript error box (I have debug verison loaded on my PC obviously) or interfere with the parent app in any way.
    Would application domains help at all? Would it make a difference if I loaded the swf into a separate domain? Or is there some way I can generically trap any error coming from the loaded swf and just ignore them?
    Any help appreciated.
    Thanks,
    Marcus

    There is no way to catch errors thrown at random times.  Remember that most folks have the release player which does not show error dialogs.
    Alex Harui
    Flex SDK Developer
    Adobe Systems Inc.
    Blog: http://blogs.adobe.com/aharui

Maybe you are looking for