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

Similar Messages

  • 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.

  • Get external swf width height

    Hi,
    I'm am trying to load an external swf file using a different swf that is on a different domain. I have noticed that it is possible to use addChild on the external swf, but when I try to get its contents width and height using contentLoaderInfo I get a security sandbox error.
    It seems it is possible to fix it by using  Security.allowDomain("*") and Security.allowInsecureDomain("*") in the external file.
    And now it's get tricky, the external swf file is a file that users upload to my site so I don't have control on the code so I can't add the "allowDomain" part.
    The second swf (the host file that loads the external file) is a file that I let others to embed on their site.
    The intresting thing is that when I share the host swf on facebook there is no problem, and I don't even need to add the code for "allowDomain" on the external file.
    I it makes a different, I use HTTPS protocol to access to the external swf.
    I tried to load the crossdomain.xml file, but it didn't help.
    What can I do? the only data I need to get on the external swf is its width and height to scale it to the host file.
    Thank you

    Thank you.
    Now it looks i am getting close but not exacly there.
    Everytime I get near something else doesn't work properly.
    Now I get the dimension after two things:
    I added 'secure="false"' to the https' crossdomain and added LoaderContext to when I load the external event:
    context.securityDomain = SecurityDomain.currentDomain;
    context.checkPolicyFile = true;
    Now you probably ask what's the problem.
    well I have no idea why, but it looks like the external swf file I load (which is as2, but I still didn't check if it matters) keeps on jumping between its first frame and second frame ( The swf has two frames). If you having hard time to imaging what I mean, lets  say this jumping between frames is really not recommended for people with Epilepsy.
    It has a stop() action, but sadly the player doesn't care.
    let me remind you that if I only addChild the Loader (without the context)  it looks fine, but I need the width and height to resize the swf.
    anyone knows what can cause this?
    and thx again martinjamesroberts1 for the link, it put me on the right track.

  • WebcamPublisher Hidden width/height Problem!

    Is it me, or do the WebcamPublisher, AudioPublisher, and AudioSubscriber components have hidden widths and heights?  They seem to be taking up space in my layout!  I have gone in and physically set their dimensions to "0", yet they still appear to be taking up a few pixels of space.
    For example:
    <s:VGroup width="200" height="200">
         <rtc:WebcamPublisher width="0" height="0" id="webcamPub" />
         <rtc:WebcamSubscriber width="200" height="200" webcamPublisher="{webcamPub}" />
    </s:VGroup>
    results in the WebcamSubscriber being pushed down a few pixels:
    +-----------------------------------------+ <---- VGroup
    +-----------------------------------------+  <---- WebcamSubscriber
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    +-----------------------------------------+
    +-----------------------------------------+
    This is not going to work well and is a bit frustrating to say the least!
    Am I doing something wrong, or is there a solution to this problem?
    Thanks in advance!
    Matt

    Hi ,
    It depends on your requirement. If you need to create the webcampublisher only under certain scenario within a component, then you might want to use Actionscript rather than using mxml to create with the component. However, if you don't have the restriction of dynamic creation , you can use mxml.
    Lastly, putting anything in Actionscript gives you much more power to change,modify and destroy things than in mxml but then creating in mxml is more easier with just a line of code written by you.
    Hope this helps
    Thanks
    Hironmay Basu

  • Jump menu + cfgrid image width height problems

    2nd day and no answer of anyone, please help! Just to simple
    questions:
    1. HOw could I build a cfselect jump menu, since JavaScript
    does not work with cfforms?
    2. Does anyboy knows why the thumbnail inside a cfgrid does
    crop beyond 75px x 70px dimension? HOw could I put a 120px x 94px ?
    Thank you!

    once I removed the "auto" setting everything worked just fine, the images came in at the proper pixel size, and the thumb nail images where proportional in size seeing how I had a height set of 40 px the width took care of itself.
    Any Ideas on where I can find a good tutorial on client login and password to access pages with their content?

  • How to change index.template.html to put a HTML table side by side with Flex swf displayed in IE

    I created my own index.template.html using <object> tag to hold Flex swf file, but it only works for FireFox, not IE.
    I did not use the original FlexBuilder's index.template.html and the JavaScripts to generate the HTML wrapper.
    Here is my index.template.html:
    <html lang="en">
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <title>My App</title>
        </head>
        <body scroll="yes">
        <table cellpadding="0" cellspacing="0" width="982px" border="0">
            <tr width="982px"><td>This app is still under development. Currently, you can... </td></tr>
        </table>
        <p>
        <table>
            <tr>
                <td>
                    <div style="width:192px;height:130px;border:1px solid rgb(0, 0, 0);">
                    <!-- div style="border-style:solid;" -->
                    <table align="left" border="0" >
                        <tr>
                              <td >
                                  <span style="color:#242F6D;font-weight:bold;font-size:12px;">Stock:</span>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                  <select style="font-size:11px;">
                                      <option>ADBE - Adobe</option>
                                      <option>BAC - Bank of America</option
                                </select>
                              </td>
                        </tr>
                        <tr>
                            <td >
                                  <span style="color:#242F6D;font-weight:bold;font-size:12px;">Shares:</span>
                            </td>
                        </tr>
                        <tr>
                              <td>
                                  <input type="text" name="shares" style="font-size:11px;"/>
                              </td>
                        </tr>
                        <tr>
                              <td>
                                  <button type="button" style="color:#242F6D;font-weight:bold;font-size:10px;">Add To My App</button>
                              </td>
                        </tr>
                    </table>
                    </div>
                    <p>
                    <div style="width:192px;height:310px;border:1px solid rgb(0, 0, 0);">
                    <table border="0">
                        <tr>
                            <td style="color:#242F6D;font-weight:bold;font-size:10px;">
                                You may enter your values
                            </td>
                        </tr>
                        <tr>
                            <td >
    <textarea id="quoteShare" style="width:186px;font-weight:bold;font-size:11px;" rows="13" >
    </textarea>
                            </td>
                        </tr>
                        <tr>
                            <td>
                            <button onclick="callFlex()" type="button" style="color:#242F6D;font-weight:bold;font-size:10px;">Get Values of My App</button>
                              </td>
                        </tr>
                    </table>
                    </div>
                <td>
                <td>
                    <table align="left" border="0" >
                        <tr valign="top">
                            <td valign="top">
                                <object type="application/x-shockwave-flash" data="ComponentTester.swf" WIDTH="850" HEIGHT="460" />
                              </td>
                          </tr>
                    </table>
                <td>
            </tr>
        </table>   
        </body>
    </html>

    I just found 1 tricky solution.
    Declare a variable containing the asset URL in the HTML, before the <!--Adobe Edge Runtime--> part. (Sample below.)
    In the script (_edge.js), use this variable instead of the asset URL string . (replace the string constant with the variable)
    In the server script, generate the HTML by changing the variable definition.
    This is ugly...
    I would appreciate any help.
    Thanks.
    === HTML sample:
    <!DOCTYPE html>
    <html>
    <head>
              <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
              <meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
    <script>
    // Define the asset URL
    var cardImage = 'card_01.png';
    </script>
    <!--Adobe Edge Runtime-->
        <script type="text/javascript" charset="utf-8" src="animtest_edgePreload.js"></script>
        <style>
            .edgeLoad-EDGE-1381868 { visibility:hidden; }
        </style>
    <!--Adobe Edge Runtime End-->
    </head>
    ====

  • 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!

  • Loading library.swf (unpacked from swc) using loader() and using it's assets

    I try to load libary.swf from an swc file in order to use it's library items.
    i load the library.swf using urlrequest and loader() and then use getDefinition() to fetch the class definition
    of the UIMovieclip element.
    i simply created the swc file by adding library assets to an swf file, converting them to a flex component and extending each compoent with the UIMovieClip class.
    when i load the swf file from a url (http) i get the following error:
    VerifyError: Error #1053: Illegal override of UIMovieClip in mx.flash.UIMovieClip.
    when i load the file locally, i get no error. any ideas why?
    <?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" minWidth="955" minHeight="600" creationComplete="init()">
        <fx:Script>
            <![CDATA[
                import mx.core.UIComponent;
                import mx.flash.UIMovieClip;
                private var _context: LoaderContext;
                private var _request: URLRequest;
                private var _loader:Loader;
                private var _library:Object;
                private var _executeFunction:Function = null;
                public function _setExecuteFunction(f:Function):void {
                    this._executeFunction=f;
                public function handleLibInitialized(e:Event):void {
                    this._library=e.target.applicationDomain;
                    var a:Class = this._library.getDefinition("lobby_page_component");
                    var b:MovieClip = new a() as MovieClip;
                    var c:UIComponent = new UIComponent();
                    c.addChild(b);
                    this.addElement(c);
                public function init():void {
                    Security.allowDomain("*");
                    var url2:String="http://url/for/library.swf"; <- http provides an error
                     var url2:String="/path/to/library.swf"; <- local path works
                                 this._context = new LoaderContext(false,ApplicationDomain.currentDomain);
                    this._request = new URLRequest(url2);
                    this._loader = new Loader();
                    this._loader.contentLoaderInfo.addEventListener(Event.INIT,this.handleLibInitialized);
                    this._loader.load(this._request,this._context);
            ]]>
        </fx:Script>
    </s:Application>

    hello,
    thanks for trying to help.
    if this is the case, why it happens only when i load the library.swf file from an http location instead of a local location ?
    how can i make sure that my adobe flash has the same UIMovieClip version?
    kfir

  • Need to find "real" width/height of loaded SWF

    So, I'm creating a player that will eventually be able to
    play back both FLV and SWF files. While testing the SWF
    functionality, I noticed some funkiness with resizing the SWF once
    loaded into a movieClip.
    Yes, I already do know that loading (via MovieClipLoader)
    needs to have finished before I can get the actual width and height
    of the SWF in question... that's not the issue.
    The issue is that I will not know ahead of time what the SWF
    dimensions are. Which should be ok, as long as I can get accurate
    dimensions after the SWF has loaded. However, I do not have control
    over the source SWFs - they could come from anywhere (many content
    providers), and in the event that the remote SWF uses masking, the
    width and height may not quite be accurate.
    Here is an example - as a test, I have my player load
    http://www.magicarchive.com/jawsbunnies.swf
    into a movieclip via MovieClipLoader. Peachy-keen, it works. I then
    want to resize the movieclip to be 400px wide by 300 tall. Doing
    this by setting _width and _height (or _xscale and _yscale) makes
    the visible area of the movie too small because of masking or
    whatever (before scaling, tracing _width and _height on the source
    movie shows width = 856.4 and height = 637.45... after resizing the
    swf in a movieclip to 400wide x 300 tall, the actual visible movie
    seems to be more like 334wide x 254tall). I can't even center the
    smaller-than-I-want-it-to-be clip because I can't determine its
    real width.
    So, how might I find the "real" width/height of the visible
    area? Is it a case of requiring some accompanying metadata from my
    SWF providers? I've also tried using hitTest, and while the hitTest
    area is slightly smaller than the width and height, it is still
    slightly larger than the real visible dimensions, so testing the
    hittable area to determine the visible area won't work, either. I'd
    like to try determining SWF dimensions without having to bother
    providers, though.
    When I put this same SWF into an HTML page with Dreamweaver,
    it automatically sizes to 720x540, which seems to be the "real"
    visible dimensions. How do I get to those dimensions once the SWF
    is loaded into a movieClip, though?
    Thanks for any help.

    Doh. I read in another post that "there is no way to
    determine what size at which an SWF was exported".
    So, there is no way I can determine the real visible
    dimensions of an SWF I have no control over?
    It seems like there SHOULD be a way to do this - since for
    example, if I embed an SWF into an HTML page (via Dreamweaver),
    Dreamweaver automatically determines the correct "Stage" size. This
    is what I need to do, only within AS...

  • 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,

  • Load time issues FLEX swf vs. FLASH swf

    Hello,
    We are building FLex and Flash apps running on Flash 10.1.  In our situation, the load time for a 1080x768 swf is slower when building in Flex than in flash.  We have tried useing the preinitialize event to set at least a loading message, but the delay happens before the preinitialize event.  It seems to take 1-2 seconds to load the FLex API perhaps?  The only visula we can see is the background color of the stage.  Even with a simple nearly empty main canvas, the load is slow enough to be noticable.  More importanly it is faster when using a FLASH swf ( or pure AS3), so it must be related to the FLex aspect.  Is there anyway to cache the common classes or maybe exclude some that are not used?
    Thanks,
    Jeff Schuenke

    The main point of RSLs is to gamble on improving download time of the SWF at
    networks speeds.  The gamble is that someone has already loaded the RSL so
    it gets picked up off the browser cache at hard-drive speeds.  If it isn't
    true, you pay a higher penalty because you are loading an RSL that has code
    in it you aren't using.  That's why the total payload is more.  For the
    record, only the SWF or the SWZ gets loaded, not both.  But even then the
    total payload would be more.
    At home, my DSL/WIFI network gets me about 70KB/sec, so saving 300K would be
    a noticable savings.  If you are loading off a hard disk, 300K probably
    won't be felt.
    The startup sequence of a SWF over a network (http or https):
    -start streaming in SWF bytes
    -when the first frame is downloaded (generally about 80-100K) see how many
    bytes are left to download and if there is a lot, show a progress bar
    -load any RSLs and wait for their download and initialization
    -update the progress bar until the rest of the SWF downloads
    -after the SWF downloads:
        -initialize styles
        -initialize resources
        -prepare embedded fonts
        -setup managers for popups, tooltips, dragging if needed
        -instantiate Application
            -verify and initialize all classes needed by Application
            -dispatch Application preinitialize
            -instantiate the initial set of children for the Application
            -dispatch Application initialize
        -update progress bar to show "initializing"
        -start validation of Application and its children
        -continue to do so until all children are measured and layed out
        -dispatch Application creationComplete
        -add Application to stage (actually systemManager)
        -dispatch Application applicationComplete
    The startup sequence of a SWF on a hard drive is different.  The entire SWF
    must be sucked into memory, unzipped (SWFs are zipped by default) and only
    then do we get to the steps where we show a progress bar, check for RSLs,
    etc.
    At 3MB, there might be a noticeable hit.  You can find a big image file and
    zip it to see if it comes out to about 3MB.  Then use the file system to
    copy it and see how long that takes and then unzip it and see how long that
    takes.
    Another place that causes delay is in the validation of children.  If the
    children's size are not stable right away (because data is coming in that
    affects their size) then several validation passes might be taking place.
    A common error is to create every child in the app, even ones that aren't
    seen or needed right away.  That adds work at validation time and delays the
    startup process.
    I would recommend that you use the performance profiler in Flex Builder to
    see where all the time is being spent.
    However, 3MB is a big SWF. Use of modules to chop off stuff not needed until
    "later" is recommended and will probably be the answer.

  • 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

  • How can I make server use single class loader for several applications

    I have several web/ejb applications. These applications use some common libraries and should share instances of classes from those libraries.
    But applications are being deployed independently thus packaging all them to EAR is not acceptable.
    I suppose the problem is that each application uses separate class loader.
    How can I make AS use single class loader for a set of applications?
    Different applications depend on different libraries so I need a way that will not share library for all applications on the domain but only for some exact applications.
    When I placed common jar to *%domain%/lib* - all works. But that jar is shared between all applications on the domain.
    When I tried to place common jar to *%domain%/lib/applibs* and specified --libraries* attribute on deploying I got exception
    java.lang.ClassCastException: a.FirstDao cannot be cast to a.FirstDaoHere http://download.oracle.com/docs/cd/E19879-01/820-4336/6nfqd2b1t/index.html I read:
    If multiple applications or modules refer to the same libraries, classes in those libraries are automatically shared.
    This can reduce the memory footprint and allow sharing of static information.Does it mean that classes should be able to be casted ?

    You didn't specify which version of the application server you are using, but the config is similar as long as you know what to look for. Basically, you need to change the classloader delegation. Here's how it is done in 8.2
    http://download.oracle.com/docs/cd/E19830-01/819-4721/beagb/index.html

  • I have created some music tracks as aiff files which I want to load onto my iPod Shuffle 4th Generation, but it won't play them - it just bleeps at me. I have changed them to AAC which works - what settings do I need to use to make aiffs work?

    I have created some music tracks as aiff files which I want to load onto my iPod Shuffle 4th Generation, but it won't play them - it just bleeps at me. I have changed them to AAC which works but would rather use aiffs. Can anyone tell me what settings do I need to use to make aiffs work? The info on the iPod says that it accepts aiff files!!

    I have created some music tracks as aiff files which I want to load onto my iPod Shuffle 4th Generation, but it won't play them - it just bleeps at me. I have changed them to AAC which works but would rather use aiffs. Can anyone tell me what settings do I need to use to make aiffs work? The info on the iPod says that it accepts aiff files!!

  • Loading multiple swfs using air 3.6 for ios

    Adobe, can you please provide us with the code to load multiple swf files for ios. Please provide examples. The code below loads multiple swfs, but the swfs stall, so this does not seem to be a solution.
    Code description: A flash file made up of 4 frames with forward and back buttons that navigate from frame to frame. The code loads three different swf files in frames 2, 3 and 4.
    Frame 1:
    var myLoader:Loader;
    var loaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
    if(myLoader == null){myLoader = new Loader(); addChild(myLoader); }
    else {myLoader.unload();}
    Frame 2:
    myLoader.unload();
    myLoader.load(new URLRequest("file1.swf"),loaderContext);
    Frame 3:
    myLoader.unload();
    myLoader.load(new URLRequest("file2.swf"),loaderContext);
    Frame 4:
    myLoader.unload();
    myLoader.load(new URLRequest("file3.swf"),loaderContext);

    I've just tried loading, unloading and then loading again same SWF with 2 library objects linked for AS3 export. It worked both on simulator and on device in debug mode. When I look inside swf it does contain AS3 code.
    So is my swf a pure asset SWF? Or Intellij Idea 12 that I'm using does stripping automatically?
    And then I've read your comment at http://forums.adobe.com/message/5217325#5217325 and run 'swfdump' utility on my .swf file. Looks like there's no ABC2 code, that's why app was able to load, unload and load again the same swf.
    public dynamic class net.games.bg extends flash.display.MovieClip
      native public function bg():*;
      native public var one:flash.display.MovieClip;
      native public var three:flash.display.MovieClip;
      native public var two:flash.display.MovieClip;
    public dynamic class net.games.z1 extends flash.display.MovieClip
      native public function z1():*;
    I can access objects as instances through root  or as objects through getDefinition.
    private var aLoader : Loader;
    private function init():void
                load1();
            private function load1():void
                aLoader   = new Loader();
                var url:URLRequest = new URLRequest("levels/expirementlevel1.swf");
                var loaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
                aLoader.load(url, loaderContext); // load the SWF file
                aLoader.contentLoaderInfo.addEventListener(flash.events.Event.COMPLETE, handleSWFLoadComplete1, false, 0, true);
            private function handleSWFLoadComplete1(e:flash.events.Event):void {
                var levelObjectsMC:flash.display.MovieClip = e.target.loader.content;
                for (var i:uint = 0; i < levelObjectsMC.numChildren; i++){
                    trace ('\t|\t ' +i+'.\t name:' + levelObjectsMC.getChildAt(i).name + '\t type:' + typeof (levelObjectsMC.getChildAt(i))+ '\t' + levelObjectsMC.getChildAt(i).x);
                var LibraryClass:Class = e.target.applicationDomain.getDefinition("net.games.z1") as Class;
                var myLibraryObject:flash.display.MovieClip = new LibraryClass as flash.display.MovieClip;
                trace(' load 1 ' + myLibraryObject);
                aLoader.unload();
                load2();
                //addChild(levelObjectsMC);
            private function load2():void
                aLoader   = new Loader();
                var url:URLRequest = new URLRequest("levels/expirementlevel1.swf");
                var loaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
                aLoader.load(url, loaderContext); // load the SWF file
                aLoader.contentLoaderInfo.addEventListener(flash.events.Event.COMPLETE, handleSWFLoadComplete2, false, 0, true);
            private function handleSWFLoadComplete2(e:flash.events.Event):void {
                var levelObjectsMC:flash.display.MovieClip = e.target.loader.content;
                for (var i:uint = 0; i < levelObjectsMC.numChildren; i++){
                    trace ('\t|\t ' +i+'.\t name:' + levelObjectsMC.getChildAt(i).name + '\t type:' + typeof (levelObjectsMC.getChildAt(i))+ '\t' + levelObjectsMC.getChildAt(i).x);
                var LibraryClass:Class = e.target.applicationDomain.getDefinition("net.games.z1") as Class;
                var myLibraryObject:flash.display.MovieClip = new LibraryClass as flash.display.MovieClip;
                trace('load 2 x ' + myLibraryObject.x);
                aLoader.unload();

Maybe you are looking for