Type Casting Loaded Swf

I'm having trouble type casting an MXML created swf as in I
can't seem to get it to work.
Here is what I'm doing:
1. Created a LoaderTest.swf that loads AppToLoad.swf
2. Made AppToLoad implement ISomeInterface
3. Once AppToLoad.swf is loaded in LoaderTest.swf, attempt to
type
cast it as ISomeInterface
Code (all code is in the same root package):
<!-- Begin ISomeInterface -->
package
public interface ISomeInterface
function doSomething():void;
<!-- End ISomeInterface -->
<!-- Begin AppToLoad -->
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute" implements="ISomeInterface">
<mx:Script>
<![CDATA[
private var myInterface:ISomeInterface;
public function doSomething():void
trace("doSomething");
]]>
</mx:Script>
</mx:Application>
<!-- End AppToLoad -->
<!-- Begin LoaderTest -->
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute" applicationComplete="start()">
<mx:Script>
<![CDATA[
import mx.managers.SystemManager;
private var ldr:Loader;
private function start():void
ldr = new Loader();
var ldrContext:LoaderContext = new LoaderContext(false,
ApplicationDomain.currentDomain);
ldr.contentLoaderInfo.addEventListener(Event.INIT,
handleLoaded);
ldr.load(new URLRequest("AppToLoad.swf"), ldrContext);
private function handleLoaded(e:Event):void
trace("handleLoaded");
var content:Object = LoaderInfo(e.target).content;
trace("content = "+content);
var typedContent:ISomeInterface = content as ISomeInterface;
trace("typedContent = "+typedContent);
var typedApplication:ISomeInterface = (content as
SystemManager).application as ISomeInterface;
trace("typedApplication = "+typedApplication);
]]>
</mx:Script>
</mx:Application>
<!-- End LoaderTest -->
Output from running LoaderTest:
[SWF] C:\EDGE\testFolder\bin-debug\LoaderTest.swf - 555,437
bytes
after decompression
[SWF] C:\EDGE\testFolder\bin-debug\AppToLoad.swf - 554,844
bytes after
decompression
handleLoaded
content = [object _AppToLoad_mx_managers_SystemManager]
typedContent = null
typedApplication = null
Any idea what I'm doing wrong?
-JP

I'd be interested in seeing the solution as well, but a quick
workaround is to cast it to the unbind operator.
This is how I've always done it... Maybe you can get it to
work with implements:
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="
http://www.adobe.com/2006/mxml"
>
<mx:Script>
<![CDATA[
import mx.events.FlexEvent;
import mx.managers.SystemManager;
import mx.core.Application;
// * gets rid of type checking so we can leave strict
enabled
[Bindable]public var _appLoaded:*;
private var load_finish_playlist:int = 0;
private var load_finish_name:String = "";
private function
onCurrentApplicationComplete(oEvent:Event):void
_appLoaded = Application(oEvent.target.application);
if(load_finish_playlist > 0) {
setPlaylist(load_finish_playlist);
if(load_finish_name != "") {
setPlayerName(load_finish_name);
private function onCompleteAppLoader(oEvent:Event):void
var smAppLoaded:SystemManager =
SystemManager(oEvent.target.content); //get a ref to the loaded app
//listen for the application.complete event
smAppLoaded.addEventListener(FlexEvent.APPLICATION_COMPLETE,
onCurrentApplicationComplete);
public function setPlaylist(id:int):void {
if(_appLoaded) {
_appLoaded.change_playlist(id);
} else {
load_finish_playlist = id;
public function setPlayerName(name:String):void {
if(_appLoaded) {
_appLoaded.set_name(name);
} else {
load_finish_name = name;
public function stopPlayback():void {
_appLoaded.stop_playback();
public function startPlayback():void {
_appLoaded.start_playback();
]]>
</mx:Script>
<!-- <mx:SWFLoader id="player" x="0" y="0" source="
http://...../flash/mixplayer3.swf"
complete="onCompleteAppLoader(event);" trustContent="true"/>
--> <mx:SWFLoader id="player" x="0" y="0"
source="@Embed('../assets/Player.swf')"
complete="onCompleteAppLoader(event);" trustContent="true"/>
</mx:Canvas>

Similar Messages

  • Error #2124: Loaded file is an unknown type when loading any SWF file

    Hi all,
    We are using IBM WebSphere Application Server (WAS) 6.1 along with Apache web-server for hosting our Flash RIA application.
    Our Flash RIA application used to be single monolitic SWF file and it worked OK for us.
    But now there is a new need to load dynamically external SWF files into our main SWF file, but every time we try to load SWF file on this configuration IOErrorEvent is thrown with error text  "Error #2124: Loaded file is an unknown type"
    Simplest MXML application fails to load SWF file with this error, although external images are loading fine.
    <?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">
        <fx:Script>
            <![CDATA[                       
                protected function swfloader1_ioErrorHandler(event:IOErrorEvent):void {               
                    mx.controls.Alert.show("SWF load failed " + event.text);
            ]]>
        </fx:Script>
        <mx:SWFLoader source="test.swf"             
                      ioError="swfloader1_ioErrorHandler(event)"/>           
    </s:Application>
    We already tried to specify the MIME type for file extension ".swf" at IBM WebSphere 6.1 admin console, tried 2 values "application/x-shockwave-flash" and "application/swf" - did not solve the problem.

    Hi JabbyPandaUA
    I had the same problem and I could fix it by adding the following tags to my web.xml:
    <mime-mapping>
                <extension>swf</extension>
                <mime-type>application/x-shockwave-flash</mime-type>
    </mime-mapping>
    try it and tell me, good luck!

  • Calling functions / setting variables in loaded SWF

    You know how you can create a Movieclip object, add a
    function or variable to it, then call that function or change that
    variable from within the SWF that includes it? I wanna be able to
    do that, only with SWFs that are loaded at run time.
    My "main" SWF is simply a menu-type thing. The user clicks a
    button in my MAIN.SWF, and the MAIN.SWF then loads the SWF that's
    associated with that button, using the AS 3.0 prescribed
    Loader()-URLRequest()-addChild() method that everyone always asks
    about.
    This works great. But now I've got some custom objects and
    such (ie., not just strings) within my MAIN.SWF that I'd like to be
    able to share with the loaded SWFs. Preferably, I'd like to use an
    accessor-type function (ie.,
    LoadedSWF.GiveMeTheCoolObject(MyCoolObject);), though at this point
    I'm willing to hack into the object itself (ie.,
    LoadedSWF.CoolObject.CoolField = MyCoolObject.CoolField;) if that's
    what it takes.
    I've tried just calling the functions and setting the fields,
    but the AS 3.0 compiler doesn't care for that sort of nonsense on
    it's generically-defined objects. Notice also that, at run time, a
    call to LoadedSWF.hasOwnObject("GiveMeTheCoolObject") returns true.
    So my big-brained colleagues, what's the magic?
    In advance, thanks for the help!
    Scott

    Kglad,
    quote:
    Originally posted by:
    kglad
    from that error message it appears your function is expecting
    a member of the MyCoolObject class, correct?
    and MyCoolObject is not an instance of that class. so, you
    need to fix that. ie, create a member of that class and use that
    class member as the function parameter.
    Heh, that's what the error message says all right. But the
    object actually IS a MyCoolObject class object. I stared at this
    thing for hours, and MyCoolObject IS an instance of that class. I
    tried various casting combinations (including casting it to an
    Object and passing that) but had no luck whatsoever.
    So I googled this particular runtime error message ("Error
    #1034: Type Coercion failed: cannot convert ") and found a ton of
    links to other people having a similar issue. Typically, the
    problem was just as you said, someone passing a button as a string,
    that kinda thing. But one guy had a problem with an object he
    derived from the Event class. After hours spent trying to get it to
    work, he tried overriding the base class' clone() method and got it
    to work:
    http://www.asserttrue.com/articles/2006/10/14/custom-events-in-actionscript-3-0
    As for my project, I took a long hard look at the overall
    architecture of my project and decided that it was best if all the
    "real work" took place in the MAIN.SWF file. This approach would
    solve a couple of other problems, and it just makes sense in a
    "separate the display from the data" mentality.
    So (and this is the interesting part) I changed the API for
    the LOADED.SWF to accept String pairs (ie.,
    LoadedSWF.AddToDisplay(Name:String, Data:String) ) instead of
    accepting MyCoolObj. Ran it, and Viola, now we're working without
    any run time exceptions. After that glorious moment, I created a
    couple of other APIs that just accepted base classes (one an int
    type, the other a function type) and was happily on my way.
    From this, I gather that passing non-base class (ie, derived
    class) objects to loaded MovieClips via custom function APIs is...
    maybe not as straightforward as we'd expect. In the grand scheme of
    things though, not a big deal: As far as I'm concerned AS3 rocks.
    Again Kglad, thanks for all the help: Your input on how to do
    this was the big push that I needed to get over the last technical
    hurdle of this project.
    To those who are reading this topic for the "how do I call
    functions and/or set variables in a loaded SWF?"
    The short answer is to cast the loaded SWF's content object
    as a MovieClip and then call the function or alter the variable:
    //Load the SWF (you've seen this code a million times)
    var LoadedSWFObj:Loader = new Loader();
    var MyURL:URLRequest = new URLRequest("LoadThisSWF.SWF");
    LoadedSWFObj.load(MyURL);
    //This is within your Event.COMPLETE handler:
    //Cast it as a MovieClip object and work with that.
    var LoadedSWF:MovieClip = LoadedSWFObj.content as MovieClip;
    // or another way to cast it is:
    var LoadedSWF:MovieClip = MovieClip(LoadedSWFObj.content);
    //Call yer function:
    LoadedSWF.CallMe();

  • How do I interact with a loaded swf?

    Hi,
    I have a "lesson" that I'm building that will display a series of "pages" based on an XML file. I have simple navigation buttons that work to page through the XML file. but I'd like to use load an external SWF file with buttons to use as my navigation panel. Everything is AS 3.0. The code to load the navigation movie looks like this:
    // load navigator
       navLoader = new Loader;
       navLoader.contentLoaderInfo.addEventListener(Event.INIT, handleInit);
       navLoader.x = 50;
       navLoader.y = 200;
       lessonSprite.addChild(navLoader);
       navLoader.load( new URLRequest("Navigator1.swf"));
    The loaded navigation movie has two buttons. How do I add an event listener to those buttons so that they call a function in the parent movie so I can detect when the user clicks on the button named "GoNext" in the loaded movie?  I've tried several ways but I've had no luck. Could someone please point me in the right direction? This navigation panel is only one application of this sort of communication that I'll need in other parts of this type of lesson so I really need to figure out how to detect user interaction interaction with the loaded movie. Guess I need to know how to call a function in the parent movie from the loaded movie.
    Thanks,
    Peter H.

    Hey Pete,
    The answer that you seek and the simplest one as well will be from the MouseEvent. that  you will most likely have applied to your loaded swf.
    As long as both swfs are in the same domain, you wont have any issues with security and therefor, the MouseEvent. which bubbles up, will be able to reach your swf file which has loaded it.
    You can then write your code in your loaded swf to simply listen to the loadedMovieClip  by targeting the contents of navLoader just like this,
    navLoader.content.addEventListener(MouseEvent.MOUSE_DOWN,onDown)
    protected function onDown(me:MouseEvent){
    now providing you have given your two buttons names in your loaded swf, you will be able to perform addition tasks by receiving the name of the target.
    protected function onDown(me:MouseEvent){
    var btnClip:Movie= me.target as MovieClip
              var btnName=btnClip.name
    if(btnName==(button1)){
         //do the following
    }else{
           //it was button two
    button1 was just a random name in this case .
    This will do the trick

  • Setting External Loaded SWF dimension

    hi guys...,
    i'll be straight to point,well i'm now working on a project using action  script 3 now what i'm trying to make is a Main SWF that load whatever  other swf into it the tricky thing is that i used 1 xml document read  the external swf source and it's setting(such as it's x,y position and  it's width and height) and i'm having problem setting the loaded swf width and  height btw it's an desktop application and not a website application.,
    here is my code:
    //variable list
    var swfList:XMLList; //hold all the zone list from the xml
    var totalZone:uint; //total of zone there is in the xml
    var myURLLoader:URLLoader = new URLLoader();
    var swf:Movie Clip;//hold the loaded swf
    var swfLoader:Loader = new Loader();//loader instance used to load the external swf
    var myCounter:uint = 0;
    //load the xml file
    myURLLoader.load(new URLRequest('myXMLFile.xml'));
    myURLLoader.addEventListener(Event.COMPLETE, processXML, false, 0, true);
    function processXML(e:Event):void
        removeEventListener(Event.COMPLETE, processXML);
        XML.ignoreWhitespace= true;
        var myXML:XML = new XML(e.target.data);
        swfList = myXML.SWF;
        totalSWF = myXML.SWF.length();
        loadSWF();
    function loadSWF():void
        swfLoader.contentLoaderInfo.addEventListener(Event.INIT, swfSetting);
        swfLoader.load(new URLRequest(swfList[myCounter].@source));
    function swfSetting(e:Event):void
        //making new instance of sprite to hold the new loaded swf
        swf = new MovieClip();
        //casting the loader content into a movieclip
        swf = e.target.content;
        addChild(swf);
        swfLoader.unload();
        swf.x = swfList[myCounter].@left;
        swf.y = swfList[myCounter].@top;
        swf.width= swfList[myCounter].@width;
        swf.height= swfList[myCounter].@height;
        addChild(swf);
        if(myCounter < totalSWF)
            myCounter++;
            trace('myCounter: ' + myCounter );
            loadSWF();
    and here is what the result ( it make the width and height of the loaded swf to 0):
    swfLoader.contentLoaderInfo.width : 320
    swfLoader.contentLoaderInfo.height : 240
    module: MyVideo/flvplayer.swf
    x:0
    x container:0
    y:0
    y container:0
    xml width:550
    width container:0
    xml height:400
    height container:0
    myCounter: 1
    swfLoader.contentLoaderInfo.width : 550
    swfLoader.contentLoaderInfo.height : 400
    module: AnalogueClock.swf
    x:50
    x container:50
    y:0
    y container:0
    xml width:250
    width container:250
    xml height:200
    height container:200
    myCounter: 2
    swfLoader.contentLoaderInfo.width : 800
    swfLoader.contentLoaderInfo.height : 30
    module: MyNewsticker/newsticker.swf
    x:0
    x container:0
    y:0
    y container:0
    xml width:300
    width container:0
    xml height:50
    height container:0
    most of my loaded swf beside the analouge clock is full action script code and in case of the analouge clock it is a swf that has a movie clip on it's stage (the other are fully created from action script 3.0)
    please do help me..,
    cause i'm already really desperate and going crazy by this problem..,

    sorry i copied the code from the other swf i used to do try and error test..,
    basically the container is the same as swf varibale
    here the code so you would'nt get confused:
    //variable list
    var swfList:XMLList; //hold all the zone list from the xml
    var totalZone:uint; //total of zone there is in the xml
    var myURLLoader:URLLoader = new URLLoader();
    var swf:Movie Clip;//hold the loaded swf
    var swfLoader:Loader = new Loader();//loader instance used to load the external swf
    var myCounter:uint = 0;
    //load the xml file
    myURLLoader.load(new URLRequest('myXMLFile.xml'));
    myURLLoader.addEventListener(Event.COMPLETE, processXML, false, 0, true);
    function processXML(e:Event):void
        removeEventListener(Event.COMPLETE, processXML);
        XML.ignoreWhitespace= true;
        var myXML:XML = new XML(e.target.data);
        swfList = myXML.SWF;
        totalSWF = myXML.SWF.length();
        loadSWF();
    function loadSWF():void
        swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, swfSetting);
        swfLoader.load(new URLRequest(swfList[myCounter].@source));
    function swfSetting(e:Event):void
        //making new instance of sprite to hold the new loaded swf
        swf = new MovieClip();
        //casting the loader content into a movieclip
        swf = e.target.content;
        addChild(swf);
        swfLoader.unload();
        swf.x = swfList[myCounter].@left;
        swf.y = swfList[myCounter].@top;
        swf.width= swfList[myCounter].@width;
        swf.height= swfList[myCounter].@height;
        addChild(swf);
        if(myCounter < totalSWF)
            myCounter++;
            trace('myCounter: ' + myCounter );
            loadSWF();
    well in my code i did cast the loader into a movie clip and then set it's width and heigt,right???
    wouldn't it just give me the same result??
    if it's not can u describe what u mean in more detail??
    some example about accessing the loader content would be really appreciated

  • Acessing loaded swf movieclip sctructure on as3

    Hi, I'm using external swf files to add skins to an
    application. Currenlty,I'm loading isolated elements successfully
    by the use of the Loader class. However, now I want to load a more
    complex skin structure that will have some movieclips already
    placed on the loaded swf stage. The question is: when I load an swf
    that athe edit time, I placed some elements on stage and gave them
    instance names, how can I access this external swf movieclip
    structure? It's something like this:
    1. First, I create the external file by placing some elements
    on its stage, naming these elements instances, like "console_bar"
    and "console_button".
    2. Then, I load this swf using the Loader class (into a
    loader called "playerConsole", for example) and, whe it finishes
    loading I try to access the elements placed on stage:
    this.addChild(playerConsole);
    playerConsole.console_bar.x = 0; // won't work - how can I
    access this instance?

    This code generates an error when I try to compile:
    1119: Access of possibly undefined property console_bar
    through a reference with static type
    flash.display:DisplayObject.

  • Type casting problem in the JSP

    Hi,
    I am type casting an Object variable to a interface Variable. I am not getting any error if i have the same code in the servlet but i am getting ClassCast Exception if i have the same code in the Scriplets part of the JSP.
    The code is as follows
    String strKey = " SomeString";
    Context context = new InitialContext();
    java.lang.Object obj = null;
         obj = context.lookup(strKey);
         ContentBroker objCB = null;
         objCB = (ContentBroker)obj; // Error is happening here
    ContentBroker is an inteface.
    I have included the jar files of ContentBroker in the classpath.
    Can anyone please tell me how to eliminate this error.?
    thanks in advance,
    Saravanan

    In that case it's a classloader issue.
    Since the object is bound in the context, I assume that you have made the class available to your server, and you have the class in WEB-INF/classes or in a jar inside WEB-INF/lib.
    Since they're being loaded by two different classloaders, the classes are seen as different by the JVM, thus the ClassCastException.
    Try removing the class from the web-app and let us know what happens.
    BTW. Which servlet container are you using?

  • Load swf from a tree

    Could someone show me how to load swf file from a link on a
    tree node? The tree would come from embeded xml.
    Thanks

    I am getting 1034 Type coercion error. I have Googled it this
    error must have hundreds of links. Is it a bug in Flex 3? Here is
    the code. The problem only occurs when I link to a swf.
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="vertical"
    verticalAlign="middle"
    backgroundColor="white">
    <mx:Script>
    <![CDATA[
    import mx.events.ListEvent;
    import mx.managers.*;
    import mx.flash.*;
    import mx.controls.treeClasses.*;
    private var t:Tree;
    private var dataObj:Object;
    private var suffix:String;
    private function tree_itemClick(evt:ListEvent):void {
    var t:Tree = evt.currentTarget as Tree;
    var dataObj:Object = evt.itemRenderer.data;
    if (dataObj.hasOwnProperty("@src")) {
    swfLoader.source = dataObj.@src;
    } else if (t.dataDescriptor.isBranch(t.selectedItem)) {
    swfLoader.source = null;
    panel.status = "";
    private function tree_labelFunc(item:Object):String {
    var suffix:String = "";
    if (tree.dataDescriptor.isBranch(item)) {
    suffix = " (" + item.children().length() + ")";
    return item.@label + suffix;
    private function swfLoader_complete(evt:Event):void {
    panel.status = (swfLoader.bytesTotal/1024).toFixed(2) +
    'KB';
    ]]>
    </mx:Script>
    <mx:XML id="dp" source="data/dp.xml" />
    <mx:HDividedBox width="100%" height="100%">
    <mx:Panel width="200" height="100%">
    <mx:Tree id="tree"
    dataProvider="{dp}"
    labelFunction="tree_labelFunc"
    showRoot="false"
    width="100%"
    height="100%"
    itemClick="tree_itemClick(event);" />
    </mx:Panel>
    <mx:Panel id="panel"
    width="100%"
    height="100%"
    backgroundColor="white">
    <mx:SWFLoader id="swfLoader"
    scaleContent="true"
    width="100%"
    height="100%"
    complete="swfLoader_complete(event);"/>
    <mx:ControlBar>
    <mx:LinkButton label="{swfLoader.source.toString()}"
    />
    </mx:ControlBar>
    </mx:Panel>
    </mx:HDividedBox>
    </mx:Application>

  • How to manage ApplicationDomain for loaded SWFs across different domains?

    I've been getting this following error -- when I'm loading a subsidiary SWF into a main one. The sub swf contains the overlays. OverlayOne is a subclass of Overlay.
    TypeError: Error #1034: Type Coercion failed: cannot convert OverlayOne@18684f89 to Overlay.
         at HSRawVideoPlayer/setCurrentOverLay()
         at HSRawVideoPlayer/showOverlay()
         at HSRawVideoPlayer/dotRoll()
    I googled and found that I should probably be setting the applicationDomain of the loader context of the loaded swf to be that of the loading SWF (as per Senocular's article on the subject) -- although I thought that in cases of conflict this would resolve to the loading SWFs ApplicationDomain, so not necessary.
    But I've also read that this won't work across different domains, and that's the situation here -- the client wants the urls of loading and loaded swf's to be fully qualified . Will setting the ApplicationDomain of the loaded SWF to be that of the parent solve the problem above, even if they are in different domains? Can someone show me a short code snippet? Thanks!

    Hi,
    DSS has inbuilt functionalities to compare the transactions against the in built rules.If the transactions take place not in accordance with the in-built rules,it is treated as a "violation" and is reporetd.
    Virsa is an example of DSS tool.Here you can build rules for access and process ;constantly compare the actuals Vs the rules;report the violations.
    In SAP R3 for example,the T/code:pfcg is tailored for access control,while the invoice parking [f-63] is tailored for process control.Using VIRSA,you can address to risks involved both,namely,access and process control.This is an example of how DSS can help in Risk integration.
    In these tools,we have an Engine for building the rules-based on this we build the rules.These rules are stored in a table.when a transaction-for which we have built a rule - takes place,the system compares the rules VS actuals.The inconsistencies if any are reported as violations.
    Hope this helps.
    Regards,
    Ramesh

  • Using a transition on an externally loaded swf

    Hi, I would have no problem doing this the old fashioned way,
    but for some client-requested reason it has to be in AS3. Here's
    what I have:
    var myLoader:Loader = new Loader();
    addChild(myLoader);
    var url:URLRequest = new URLRequest("movie.swf");
    myLoader.load(url);
    //Fade-in 9 seconds
    TransitionManager.start(myLoader, {type:Fade,
    direction:Transition.IN, duration:9, easing:Strong.easeOut});
    Apparantly, myLoader isn't the instance name of the loded
    swf. I have no idea what it is though. Can someone help me? Thanks!

    The loaded swf is at loader.content, but you can only access
    it once the loading has completed and the loader has been added to
    the display list. For example, CODE 1 will not work, but CODE 2
    will.
    //CODE 1
    var myLoader:Loader = new Loader();
    addChild(myLoader);
    myLoader.load(new URLRequest("movie.swf"));
    var loadedSwf:MovieClip = MovieClip(loader.content); //ERROR
    //CODE 2
    var myLoader:Loader = new Loader();
    addChild(myLoader);
    myLoader.load(new URLRequest("movie.swf"));
    myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,
    loadCompleted);
    var loadedSwf:MovieClip;
    function loadCompleted(ev:Event):void {
    loadedSwf = MovieClip(loader.content);
    trace(loadedSwf);
    PS. I recommend using the Tweener library for tweening in
    ActionScript. It is much better than the Adobe functions and there
    is a tutorial at:
    http://gotoandlearn.com/player.php?id=45

  • Trying to call a root level function from within a loaded swf

    I'm not very familiar with AS3... I'm trying to have a loaded swf file call a function from the parent to unload itself when it comes to the end (on the timeline, not as a button). I'm assuming I need to be calling the function (that is used for the close button) from the loaded swf (perhaps I'm mistaken though?).
    Here's the code from one of my buttons that loads an swf. I'm guessing I need to call the closeSWF function from the timeline of my loaded movie but having no luck figuring out how to do that.
    Any help would be appreciated.
    // 01 ------------------------------------------------------
    function loadWeaving(ev:MouseEvent):void {
      // load SWF
      var movieClip:MovieClip = new holder_mc;
      //add it to the stage
      addChild(holderSWF);
      holderSWF.x=0;
      holderSWF.y=0;
      var requestEN:URLRequest = new URLRequest("WhatIsWeaving_Eng.swf"); // english
      holderSWF.load(requestEN);
      close_bt.addEventListener(MouseEvent.CLICK, closeSWF);
      function closeSWF(infoObject:Object):void {
      trace("close SWF");
      removeChild(holderSWF);
      // reset switch
      close_bt.visible = false;
      showAllButtons();
      infoObject.currentTarget.removeEventListener(infoObject.type, closeSWF);
      setChildIndex(close_bt,numChildren - 1);
      close_bt.visible = true;
      hideAllButtons();
      // - start timer last
      myTimer.addEventListener(TimerEvent.TIMER, closeSWF);

    You're exactly right. If you attach an event listener to the Loader before you add it to the stage, you can then use event.currentTarget to refer to the loader. And this is definitely the better way to do it if you're planning to use the loaded swf from multiple places or could ever need to do this in the future.
    So:
    protected function initLoader():void {
         var loader:Loader = new Loader();
         loader.addEventListener('closeMe', closeLoader);
         loader.load(new URLRequest(...));
         addChild(loader);
    protected function closeLoader(e:Event):void {
         var loader:Loader = e.currentTarget as Loader;
         if (loader) {
              loader.unloadAnstop(true);
              loader.removeEventListener('closeMe', closeLoader);
              removeChild(loader);

  • Loading SWFs: Classes do not match

    I've written an AIR app which loads coompiled SWFs and manipulates them.  The problem I've run into is that I cannot access the custom objects in the SWF because their class definition does not match the class definition in the AIR app.
    I have a library project that I develop all the classes in.
    The SWFs are published from Flash using the Source Path of this library, and the AIR app has the library project listed in its Build Path Libraries in FB 4.5.
    Example:  vManager is a ViewManager, a custom class used in the SWF to do various things.  It is accessible to the AIR runtime, but the AIR runtime thinks it's some other class that doesn't exist anymore:
    From the AIR runtime:
    trace(describeType(contentMC.vManager).toXMLString());
    <type name="gdit.controls::ViewManager" base="Object" isDynamic="false" isFinal="false" isStatic="false">
      <extendsClass type="Object"/>
      <constructor>
        <parameter index="1" type="flash.display::DisplayObjectContainer" optional="false"/>
      </constructor>
      <accessor name="state" access="writeonly" type="gdit.controls::ViewStateButton" declaredBy="gdit.controls::ViewManager"/>
      <accessor name="directiveText" access="writeonly" type="gdit.controls::IndexedTextField" declaredBy="gdit.controls::ViewManager"/>
      <accessor name="states" access="readonly" type="__AS3__.vec::Vector.&lt;gdit.controls::ViewStateButton>" declaredBy="gdit.controls::ViewManager"/>
      <method name="addViewState" declaredBy="gdit.controls::ViewManager" returnType="void">
        <parameter index="1" type="flash.display::Sprite" optional="false"/>
        <parameter index="2" type="Array" optional="false"/>
      </method>
      <method name="setDefaultViewState" declaredBy="gdit.controls::ViewManager" returnType="void">
        <parameter index="1" type="Array" optional="false"/>
      </method>
    </type>
    From the SWF:
    trace(describeType(vManager).toXMLString());
    <type name="gdit.controls::ViewManager" base="Object" isDynamic="false" isFinal="false" isStatic="false">
      <extendsClass type="Object"/>
      <constructor>
        <parameter index="1" type="flash.display::DisplayObjectContainer" optional="false"/>
      </constructor>
      <variable name="defState" type="String">
        <metadata name="__go_to_definition_help">
          <arg key="file" value="G:\Flash\ASLib\src\gdit\controls\ViewManager.as"/>
          <arg key="pos" value="527"/>
        </metadata>
      </variable>
      <accessor name="state" access="readwrite" type="gdit.controls::ViewStateButton" declaredBy="gdit.controls::ViewManager">
        <metadata name="__go_to_definition_help">
          <arg key="file" value="G:\Flash\ASLib\src\gdit\controls\ViewManager.as"/>
          <arg key="pos" value="2302"/>
        </metadata>
        <metadata name="__go_to_definition_help">
          <arg key="file" value="G:\Flash\ASLib\src\gdit\controls\ViewManager.as"/>
          <arg key="pos" value="2378"/>
        </metadata>
      </accessor>
      <accessor name="defaultState" access="readonly" type="__AS3__.vec::Vector.&lt;flash.display::DisplayObject>" declaredBy="gdit.controls::ViewManager">
        <metadata name="__go_to_definition_help">
          <arg key="file" value="G:\Flash\ASLib\src\gdit\controls\ViewManager.as"/>
          <arg key="pos" value="577"/>
        </metadata>
      </accessor>
      <accessor name="states" access="readonly" type="__AS3__.vec::Vector.&lt;gdit.controls::ViewStateButton>" declaredBy="gdit.controls::ViewManager">
        <metadata name="__go_to_definition_help">
          <arg key="file" value="G:\Flash\ASLib\src\gdit\controls\ViewManager.as"/>
          <arg key="pos" value="694"/>
        </metadata>
      </accessor>
      <accessor name="directiveText" access="writeonly" type="gdit.controls::IndexedTextField" declaredBy="gdit.controls::ViewManager">
        <metadata name="__go_to_definition_help">
          <arg key="file" value="G:\Flash\ASLib\src\gdit\controls\ViewManager.as"/>
          <arg key="pos" value="3075"/>
        </metadata>
      </accessor>
      <method name="addViewState" declaredBy="gdit.controls::ViewManager" returnType="void">
        <parameter index="1" type="flash.display::Sprite" optional="false"/>
        <parameter index="2" type="Array" optional="false"/>
        <metadata name="__go_to_definition_help">
          <arg key="file" value="G:\Flash\ASLib\src\gdit\controls\ViewManager.as"/>
          <arg key="pos" value="1220"/>
        </metadata>
      </method>
      <method name="setDefaultViewState" declaredBy="gdit.controls::ViewManager" returnType="void">
        <parameter index="1" type="Array" optional="false"/>
        <metadata name="__go_to_definition_help">
          <arg key="file" value="G:\Flash\ASLib\src\gdit\controls\ViewManager.as"/>
          <arg key="pos" value="1577"/>
        </metadata>
      </method>
      <metadata name="__go_to_ctor_definition_help">
        <arg key="file" value="G:\Flash\ASLib\src\gdit\controls\ViewManager.as"/>
        <arg key="pos" value="793"/>
      </metadata>
      <metadata name="__go_to_definition_help">
        <arg key="file" value="G:\Flash\ASLib\src\gdit\controls\ViewManager.as"/>
        <arg key="pos" value="193"/>
      </metadata>
    </type>
    Both of these statements trace in  the AIR runtime.  Note that the SWF class is much larger:  this is because the AIR version is referencing a class definition that is roughly 4 versions old.
    I've tried wiping out the class def after publishing the SWF, and the AIR app still refers neither the current version of the class in the Library project, nor the version compiled in the SWF. 
    There are no errors or warnings in the Lib project, the main AIR project, or the SWF.  I've tried cleaning both projects, referencing the SWC directly, nothing seems to correct this issue.
    Maybe I'm integrating the library project incorrectly in FB?  I don't know, but if anyone does:  please let me know!
    Thanks

    Thanks for your response.
    I am still not clear. Print method is a implementation of the pageable interface why does PrintBlank implement Printable. what shows the print method is a implimentation of method of pageables Is the Print method part of class PrintBlank . I see that it is outside of the brackets of PrintBlank .
    also is the order of process class PrintBlank calls PrintJob's print method this does not take any paramters.
    PrintJob then calls Pageable's print method which sends the parameters Graphics g, PageFormat format and int pageIndex.
    Thanks

  • TotalFrames of dynamically loaded swf

    I've been trying for 2 days now to find the total number of frames of a dynamically loaded .swf.
    Here's an example code:
    var loader:Loader = new Loader;
    loader.load(new URLRequest("mop.swf"))
    master_mc.addChild(loader);
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, xmlLoadedF);
    function xmlLoadedF(event:Event):void
        trace(loader.content.totalFrames);
    I am truly puzzled.
    Any help would be greatly appreciated.

    I think this might be complicated by loading an AS2 movie into an AS3 document.
    The error message is telling you that there is no totalFrames property and in fact AS2 movies would have a _totalframes property.
    So you could try that.
    Also I'm not sure if event.currentTarget.content returns a MovieClip or a DisplayObject. If it is a DisplayObject (which is most likely) then it too wouldn't have  totalFrames property. So you might need to cast it as a MovieClip. Something like this:
    MovieClip(event.currentTarget.content).totalFrames
    And or it could be some combination of these two above issues? I don't know really, I'm just grasping at straws. But I don't see any way to know when a clip is done playing other than to compare its currentFrame to totalFrames.

  • Unexpected fatal error while loading SWF

    I'm trying to install Muse through AAM and I get this error code in the log
    Got an unexpected fatal error while loading SWF: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="app:/Adobe AIR Application Installer.swf" errorID=0]

    Does the suggestion posted in your other thread helps?
    http://forums.adobe.com/message/5109761#5109761
    If not, try the steps here.
    http://forums.adobe.com/message/5086018#5086018
    Thanks,
    Vinayak

  • Could not type cast in java embedding

    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();
    org.xml.sax.InputSource in = (org.xml.sax.InputSource) getVariableData("Invoke_1_getRoutingAndFrameJumpers_OutputVariable","getRoutingAndFrameJumpersResponse");
    Document doc = db.parse(in);
    In the above code I am trying to type cast the variable getRoutingAndFrameJumpersResponse into org.xml.sax.InputSource so that i can parse.
    I am not getting any error during compilation
    but I am unable to type cast some run time error is coming in the line were I am type casting but I am not able to see the runtime error.
    How can I see the runtime error in java embedding, how to type cast a variable into xml so that I can parse it.

    Hi Arun,
    Could you try using the bpelx:rename extension in an assign activity enables a BPEL process to rename an element through use of XSD type casting.
    <bpel:assign>
    <bpelx:rename elementTo="QName1"? typeCastTo="QName2"?>
    <bpelx:target variable="ncname" part="ncname"? query="xpath_str" />
    </bpelx:rename>
    </bpel:assign>
    Cheers
    A

Maybe you are looking for

  • Not Apple's greatest upgrade

    Not the smoothest OS upgrade Apple has released. Maybe they were just trying not to make Windows Vista look so bad. My upgrade took me 13 hours (an unlucky number that!), but did finally work. The take home message is: IF YOU CAN'T AFFORD AN EXTERNAL

  • What is an .ODB file???

    I have an .ODB file sent by a client. It is supposed to be an Oracle database. When I opened it in a hex editor, it seems that it was created using OracleLite 9. How do I open and connect to this file from my Win2K box? HELP! Doug

  • How to view web pages off line

    how do you save web pages so they can be viewed on line?

  • Adding a Dialog instance to a live production database.

    We are adding a number of new App servers to a ECC6 7.0 Live production database but we don't have enough confidence in the in the information in InstGui and install guide that it will not over write the /sapmnt/SID/exe of the running CI. Has anyone

  • SAP general Idea. Please correct me

    Dear All, I heard that MsSAP is a business suit of SAP AG. This ERP package has 5 enterprise applications 1. ECC 2. CRM 3. SCM 4. SRM 5. PLM I think HR and FICO comes under ECC. Then what about other modules? Like MM, SD, PP, PS ETC And BI/BW, BASIS,