As 3 load swf flie problem,help

I have now trapped by a strange problem of loading the swf
file.For some reason I need to use a main swf file to load other
swf file and use the class in it,it's very common.
And now I worte a class blow to explain what problem I met:
package
import flash.display.*;
import flash.events.*;
import flash.geom.*;
public class TestClass extends MovieClip
public var sp:Sprite;
public static var count:Array=new Array();
public function TestClass()
sp = new Sprite();
//drawcrr();
this.addEventListener("test",test);
count.push("");
trace("count in circle is:", count.length);
private function test(e:Event):void
drawcrr();
public function drawcrr():void
sp.graphics.beginFill(0);
sp.graphics.drawCircle(0,0,10);
sp.graphics.endFill();
addChild(sp);
Save it as TestClass.as for next use;
Use the class to link to a fla file as the documentClass then
compile as a swf file name as
kk.swf then make a copy name kk1.swf;
Create a new fla file in the same directory then write the
code blow on the mainTimeLine :
var kk:TestClass = new TestClass();
var URL1:URLRequest = new URLRequest("kk1.swf");
var URL2:URLRequest = new URLRequest("kk.swf");
function domain():LoaderContext
var context:LoaderContext = new LoaderContext();
context.applicationDomain = new
ApplicationDomain(ApplicationDomain.currentDomain);
return context;
var L1:Loader = new Loader();
L1.contentLoaderInfo.addEventListener(Event.COMPLETE,onComplete);
L1.load(URL1);
var L2:Loader = new Loader();
L2.contentLoaderInfo.addEventListener(Event.COMPLETE,onComplete);
L2.load(URL2);
//v.text = flash.system.Capabilities.version;
function onComplete(e:Event)
trace(e.target)
then compile this fla file you will find the flash will put
out below:
count in circle is: 1
count in circle is: 2
count in circle is: 3
[object LoaderInfo]
[object LoaderInfo]
and if you notation the line "var kk:TestClass = new
TestClass();" compile it again
the flash will output :
count in circle is: 1
count in circle is: 1
[object LoaderInfo]
[object LoaderInfo]
It's prove that the same class in the different swf was
loaded by a main swf file,the same class in the different swf file
will be treated as the different class so that I can use them
individually but when I put the code:"var kk:TestClass = new
TestClass();" in the main swf file all this will be break down,I
can't use the class in kk.swf and class in kk1.swf individually
the flash make then as the same class because the static
variable "count" was count to 3.
it prove that all those 3 swf file will use the exactly same
class;So, that's the problem,it will make my programme cause error.
Can some one kindly to tell me why this happened?And how can
I solve this problem.

Sorry about that.
That problem is:
If I use a shell swf to load some swf file and the shell swf
and the loaded swf file have the same name class,The loaded swf's
class will be ignored.
That will make me can't use the loaded swf file's class which
have same name with the shell swf.
However, this problem can be solved by useing the application
domain.Just give the swf you loaded a new application domain in the
shell swf.
But after that I found a new problem appear in front of mine,
that is:
If I use the different application domain in my shell swf how
could they communicate with each other?
For example:
If my shell swf have a class named TEST,and the loaded swf
also have the same name class those two classes both extends the
class named TESTParent and the TESTParent have a public static
variable to count the instance of the class.If I want use those two
TEST
class individually and at the same time made the static
variable in the TESTParent count work as a same class how can I do?

Similar Messages

  • Color external loaded swf in AS3 Help Urgent!

    Hi i have loaded swf from an external path using the following command.
    var cviewer:Loader=new Loader();
    var curlRequest:URLRequest=new URLRequest("clipArts/"+evt.target.name);
    So this is the scenario.
    Suppose say i load Movie1.swf
    I have three movie clips inside Movie1.swf called step0, step1, step2
    I need to change the color of step0, step1 and step 2 from the parent flash file which loads movie1. All the inner movie clips color may be different from each other.
    I am able to change the color of the whole movie clip by using
    var colorInfo:ColorTransform = cviewer.transform.colorTransform;
    colorInfo.color=evt.target.selectedColor;
    cviewer.transform.colorTransform=colorInfo;
    But not of individual ones. I even tried cviewer.step0.transform.colortransform and other stuff to see if it would work. But nothing worked. Help at fastest would be deeply appreciated.
    Regards and thanks in advance.

    try:
    var colorInfo:ColorTransform = MovieClip(cviewer.content).step0.transform.colorTransform;
    colorInfo.color=evt.target.selectedColor;
    MovieClip(cviewer.content).step0.transform.colorTransform=colorInfo;

  • AIR load swf cash problem

    hi folks
    I am building android app.
    I have a problem with loading several .swfs cache. this swf-s have almost same package and class structure/ names.
    App stores ActionScript and assets of first loaded swf and when i try to load second swf, anyway it loads first swf.
    I used
    request.cacheResponse = false;
    request.useCache = false;
    loader.unload();
    loader.unloadAndStop();
    loader = null;
    but no luck, any solutions, suggestions?
    thanks

    I solved problem, swfs that I loading in app have same package names and classes, I changed package names for each swf and everything works fine.
    Main app stores in cash loaded swf-s AS code, I have't found solution how to clean this cash

  • Extract graphics from loaded swf / Big problem

    Hello,
    my English isn't very good, so sorry for mistakes I have swf which consist of many vector graphics.
    You can show it right here: http://www.watchtime24.sisco.pl/moje...orowanka_1.swf
    If I import the swf to the stage, than I can manipulate this graphics. But this is not enough for me. I need to manipulate from Action Script.
    I need to change the colors of this piceses from AS. I tried to use function
    getObjectsUnderPoint(new Point(mouseX, mouseY))
    but it doesn't work. This function doesn't see shapes, graphics or something else.
    Is any solution which can fix my problem ? Has anyone any idea ?

    Hey Mich,
    What you can do is turn eachof the items in your shapes, into a movieClip or sprite or even a bitmap.
    like the boy in the drawing.. take all of thsoe and then convert them into a movieClip.  Then when you do this give them a name and export them for actionscript.  Give this a class Name.
    then when you load the swf, you can actually target those files with this line.
    Say i converted the BOY into a movieClip.
    import flash.system.ApplicationDomain
    import flash.utils.geClasstDefinition
    var myswfHoldingBoy
    var myLoader:URLLoader = new URLLoader()
          myLoader.addEventListener(Event.INIT,onInit)
         var myURLRequest('path to myswfHoldingBoy')
    myLoader.load(myURLRequest)
    privaate function onInit(e:Event){
    //here is where we will extract the boy for the library of the other swf
    var ldrAppdomain= e.target.loaderInfo.applicationDomain
    var boyObject:Class= ldrAppdomain.getByDefinition('class name you gave the boy as i said eralier') as Class
    // now we have boyObject that will be able to be used as a class
    addChild(new boyObject())  // this will addYourBoy movieClip to the stage.  but keep a reference to him so that you can then manipulate him.

  • How to detect the end of a loaded swf file

    Hello Guys
    This is my first time on this forum, come here with a great
    hope
    I have loaded a picture file (jpeg) and a video file (swf)
    into the main flash file using xml
    on frame 3, I load the picture and on frame 7, I load the
    video, there is a stop action on frame 6
    Now when the flash is executed the picture is displayed ( it
    says "Click here to view the video")
    when the user click the picture , the video is loaded and
    starts to play ---- so far everything is working fine
    now what I want to do is, once the video finishes playing (
    not stoped) I want to display the picture again
    can you tell me how to detect the end of an external loaded
    swf files,
    Please help me
    Thanking You
    Shriram

  • Need Your Help with Loading SWF into another Flash Movie!

    Hello,
    I have created TWO Flash movies. They work just fine
    individually, but I get problem when I put one into another one!
    The main Flash is a Menu and the second one if a Photo Album.
    The Menu is series of animation (Moving Objects) which finally
    comes into rest and create the menu. The photo album is another SWF
    file which is called with in the first Flash Movie (The Menu). The
    SWF file is loaded as follow into the Main Flash.
    MovieClip.prototype.drawRect = function(x, y, w, h) {
    this.beginFill(0xFF0000, 100);
    this.moveTo(0, 0);
    this.lineTo(0+w, 0);
    this.lineTo(0+w, 0+h);
    this.lineTo(0, 0+h);
    this.lineTo(0, 0);
    this.endFill();
    this._x = x;
    this._y = y;
    this.createEmptyMovieClip("mc6", 6);
    mc6.lineStyle (3, 0x000000, 100);
    mc6.drawRect(-77, -17, 20, 20);
    mc6._xscale = 100;
    mc6._yscale = 100;
    loadMovie("photoAlbum.swf", mc6);
    Problem arises when I click on the Play Button of the
    photoAlbum.swf (Photo Album) since the execution of the play button
    causes the Flash starts once again from the beginning of the entire
    Flash Movie (Beginning of the animation creating the menu) and it
    simply jumps into the Firm One of my Flash Movie.
    Could you tell me how I can isulate what is in layer 6 (Where
    the photoAlbum is loaded to) from the rest of my Flash Movie?
    I hope I managed to explain my problem. I would like to take
    this opportunity to thank you in advance for your help.
    Cheers,
    Babak

    Hello Anya,
    I have realized the problem arises from the Wait Function
    which causes the Photo Album to pause for a period of time (Two
    Seconds) once a Photo is fully displayed (I have Fade in/out Photo
    Album). I realized everything works OK once I remove the function
    and rather left the Photos to be flipped without any pausing (This
    is an Auto-loading Album which simply Flips the photos!).
    Here is the Wait Function which is causing all the trouble.
    function wait()
    stop();
    var myInterval = setInterval(function ()
    play();
    clearInterval(myInterval);
    }, 2000);
    Thank you so much for your help.
    Cheers,
    Babak

  • Flash cs4 mac - Error opening URL '/:Users:someting.swf' - Not a "loading external content" problem

    Hello.
    I am having a weird problem when trying to test a movie or publish preview -> flash on mac with Leopard os.
    The result is a blank movie with the usuall "movie not loaded" if u right click on it and the output returns the "Error opening URL 'the path of the swf here'.
    This has nothing to do with loading external files or something like that. It happens even in blank movies and it gives the same error if I try to open a swf from flash ide.
    I can publish the project or export the movie with no problem at all.
    I can preview the movie in html. I can run all the swf files in my hard disk, network, usb stick, dvd etc., but when I try to open any of these files from flash ide I got that stupid error.
    Its not something that stops me from working in flash ide but its slow to export movie any time I want to test it.
    Things that I've tried so far but nothing worked:
    Update the flash cs4 to the latest version
    Update the flash players
    Restored the release flash player as default player (I am using as default the debug player)
    Cleared the preferences
    Move the flash cs4 folder to another location in hd
    Saved the fla document first before testing the movie (in different places with or without spaces in document name or folder)
    Give read & write permissions for everyone for flash.app, players and for fla files when saved first before test movie
    Unistall and install the application 3-4 times.
    Test every as version just in case.
    Also I've checked the folders when testing movie and I can see that it creates an swf file, which I can run it outside flash ide (the one that the flash ide player cannot load) with no problem.
    The mac os has the default set up as it came. Nothing chnaged in permissions or security settings.
    Thanx in advance.

    In this particular example I am using this code to start the
    xml file load:
    // now load the XML file that contains the content strings
    var sXMLFile:String = "xml/home.xml";
    var xmlContent:XML = new XML();
    xmlContent.ignoreWhite = true;
    xmlContent.onLoad = onXMLLoadComplete;
    xmlContent.load( sXMLFile );
    But I don’t think the code is the problem here . This
    happens on every file I load when I am using a relative path to the
    content, regardless of how I load the content (XML object,
    loadMovie, MovieClipLoader, etc…) and the same code executes
    perfectly on every other machine in the office(Mac and PC).
    I’m more concerned with the semi-colons and .swf filename
    that Flash is putting into my relative path on the error message.
    Is that normal?

  • HTMLLoader loading local content (SWF files) problem

    Hello guys,
    I'm just finishing my application but I facing a problem.
    I'm currently developing a desktop application using AIR.
    I'm using HTMLLoader to load local SWF files when te user tries to access specific content on the application.
    I successfully accomplished this, but the loaded SWF also loads other files (assets and xml files with translations) and that is not working.
    When a SWF is loaded he just stops on his own loading screen (when loading the XML files).
    All this stuff is happening on my CustomNativeWindow:
    (my CustomNativeWindow "overlays" the main application)
    public function CustomNativeWindow()
             var nativeWindowInitOptions:NativeWindowInitOptions = new NativeWindowInitOptions();
             nativeWindowInitOptions.systemChrome = NativeWindowSystemChrome.NONE;
             nativeWindowInitOptions.renderMode = NativeWindowRenderMode.DIRECT;
             nativeWindowInitOptions.resizable = false;
             nativeWindowInitOptions.maximizable = false;
             nativeWindowInitOptions.minimizable = false;
             super(nativeWindowInitOptions);
             alwaysInFront = true;
             this.activate();
    public function setProperties(contentName:String, contentURL:String, posX:Number, posY:Number, stageWidth:Number, stageHeight:Number):void
              this.stageHeight = stageHeight;
              this.stageWidth = stageWidth;
              this.contentURL = contentURL;
              this.contentName = contentName;
              this.x = posX;
              this.y = posY;
              this.width = stageWidth;
              this.height = stageHeight;
              this.title = contentName;
              this.addEventListener(Event.RESIZE, onWindowResize);
              SWFHTMLLoader();
    private function SWFHTMLLoader():void
              //REQUEST LOAD URL
              var request:URLRequest = new URLRequest(contentURL);
              //HTML LOADER SWF
              htmlLoader  = new HTMLLoader();
              htmlLoader.width = stageWidth;
              htmlLoader.height = stageHeight;
              htmlLoader.addEventListener(Event.COMPLETE, onHtmlLoaderComplete);
              htmlLoader.load(request);
              stage.addChild(htmlLoader);
    private function onHtmlLoaderComplete(e:Event):void
              trace("NATIVE WINDOW HTMLLoader complete");
              onWindowResize();
    private function onWindowResize(e:Event = null):void
              if (htmlLoader)
                        htmlLoader.width = stage.stageWidth;
                        htmlLoader.height = stage.stageHeight;
    Probably something related to security?
    How can I fix this?
    Is kinda urgente... deadline is coming...
    Thank you!

    Thank you kglad for your fast response...
    The reference to the content comes from a XML loaded on the main application.
    var xml:XML =      <Content  en="game" >
                                      <ImageSource>assets/images/gallery/resources/gameone.png</ImageSource>
                                      <ContentSource>content/gameone/gameone.swf</ContentSource>
                                </Content>;
    contentURL = xml.ContentSource;
    So contentURL is: content/gameone/gameone.swf
    Am I in trouble?

  • Problem in loading swf within Flex 1.5

    Hi all,
    I'm working with a flex project.The logo of that project is a
    spinning wheel created with flash tweens. I ve loaded that swf file
    into Flex using a Loader component. But despite of whatever
    framerate i ve specified, the wheel spins in a constant speed,
    which is a little bit slower than the expected speed of the wheel.
    Is there any option in flex to increase the framerate, or is there
    any other way to do this. Pls.help.

    And this for 1.5:
    "In Flex or Flash, a loaded SWF takes on the FrameRate of the
    parent SWF. In flex you can set the framerate value for the main
    application with "framerate" attribute in the
    <mx:Application> tag."
    Tracy

  • Ebay will not load on safari, firefox or camino, but all other sites load without any problem. Can anyone help?

    ebay will not load on safari, firefox or camino, but all other sites load without any problems. Why is this? Can anyone help?

    It should be: Click on Home Folder (the House) and to the right Library is shown, click on the arrow on the Library folder to reveal its contents and then click on Cookies to reveal its contents and then move the Cookies.plist to the Trash as Carolyn suggests.
    Then try eBay again.

  • Problem with loading swf

    Hi,
            I've an AIR application which is loading an swf file to swfloader. Its working properly when its running from builder. But not showing the swf file after exporting  it as an air installer package and run it on  desktop.The swf   file is stored in src itself.The swf file was generated using flash.
    Any help will be appreciated.
    Thanks in advance.

    Hi,
    It might be security issue.Air uses application sandbox.
    You are trying to load the content from non-application sand box to
    application sandbox.
    Any one of the following may give solution to this error.
    1.using HTMLLoader to load swf files.
    2.using loadbytes.
    3.creating sandboxbridge.
    You can check the loadbytes method in the attachment.
    vamshi.
    2009/10/5 newflexcoder <[email protected]>
    >
    Hi,
    >
            I've an AIR application which is loading an swf file to swfloader.
    Its working properly when its running from builder. But not showing the swf
    file after exporting  it as an air installer package and run it on
    desktop.The swf   file is stored in src itself.The swf file was generated
    using flash.
    >
    Any help will be appreciated.
    >
    Thanks in advance.
    >

  • Load .swf help. Loaded clip loses file locations?

    Hi,
    File A is a .swf loader
    File B is the loaded .swf
    File C is the xml file for File B
    I am trying to have file A - load in file B and then have its xml load from C.
    They all sit in the same folder, but it is not working
    I can load file B up and it reads it's xml no problem.
    A loads in B but then B cant find C?!
    If this was AS2, I would just _lockroot on B to solve it.  Any work around for AS3 for this?  Or any tricks I can do to fix this?

    B is a client .swf that I dont have access to, it may be using global varriable or such for its xml load I dont know. (pano.swf)
    A is using simple .swf load code ->
    var req:URLRequest = new URLRequest ("pano.swf");
    var loader:Loader = new Loader();
    loader.load(req);
    addChild(loader);
    (B) pano.swf loads fine into (A) and gives me output saying so, but it cant find its pano.xml file when loaded into A.
    If I open up B as an .swf, it loads C fine.

  • Strange problem in loading swf created in Flash Builder 4 !

    Hi
    I am facing a strange issue in all my flash builder projects.
    Here is a sample flex 4 project: http://flashvisions.com/demos/flexdemo/
    you will see when it loads, it showes the first progressbar as grey and then the next one covering it as per flex4's new preloader mechanism. The example given above is a new flex project, without any code. It shows the first preloader then hangs on that for quiet some time  without any indication that anything is happening. Then it shows the second phaze of preloader after some time. This is happening to all my Flash builder projects.
    can some one suggest anything ? If possible watch this link to a medium bandwidth, not too high : http://flashvisions.com/demos/flexdemo/

    And this for 1.5:
    "In Flex or Flash, a loaded SWF takes on the FrameRate of the
    parent SWF. In flex you can set the framerate value for the main
    application with "framerate" attribute in the
    <mx:Application> tag."
    Tracy

  • Using TextSnapshot class on a loaded SWF on an iPad

    Hello, I am creating an iPad app. I am loading SWF files using a Loader object, then placing them in a movieclip and setting a SWFLoaders source property to this clip. Before I add the clip to the SWFLoader control I am using the TextSnapshot class on it, to retrieve an array with the getTextRunInfo method.
    All this works fine when I test it on my desktop machine. However, on the iPad it causes the app to crash when a control using this clip is added to the stage. Can you still use TextSnapshot with an iPad, is there a workaround for this? Thanks for your help.

    We are a university. most of our books are SWF files. We have been using iPad/FlexBuilder 4.5 to successfully view the contents of these books.
    All navigation (i.e gotoandstop(page), etc work fine. Gestures for pageforward/pageback, zoom, pan work fine also.
    Not sure I understand your comment.
    However, there IS a specific problem with text snapshot. Below is a short code piece used to highlight text on a page.
    If you remove the failing line everything works fine.
    If you "debug" the iPad device everything works fine when you execute the code on the iPad
    if you create a release build, when the application starts and the "findtext" line is executed the "app" freezes. No error message. The try/catch does not seem to catch any error.
    This is something we really need for our app. If this is a bug how should we report it.
    Thanks for your help.
      public function highlightText(txt:String):void {
       var start_pos:int = 0;
       try {
        if (txt == null || txt.length == 0) { return; }
        infoMessage("highlightText: " + txt);
        allText = _libMC.textSnapshot;      
        allTexts.push(allText);  // no reason for this but must do to make work 
        start_pos = allText.findText(start_pos, txt, false);     <<<<<< Failing line ====================================
        infoMessage("start_pos: " + start_pos);
       catch (err:Error) {
        infoMessage("error: " + err.message);   
       finally {
        infoMessage("finally");

  • Using loadMovie to load SWF linked to FLV

    I am having problems getting a movie (SWF) with an linked FLV
    file to play when I use loadMovie to load it in.
    I have an .FLV file named vid_9.flv. I have embedded it into
    a Flash movie named vid_9.swf using Flash 8 Professional. I am
    using "Progressive Download from a Web Server" and no controls.
    When I play the SWF on the stand-alone player (the FLV is in the
    same folder) it works great. Now when I call that SWF into another
    movie using
    swfHolder.loadMovie("SWFs/vid_9.swf");
    it shows it being completely loaded, but then never plays,
    all I get is a white screen. This is my second project in a row
    where this did not work. Any ideas as to why? Thanks for any
    help.

    onLoadComplete executes before the loaded swf's assets are initialized:  use onLoadInit.
    those function definitions in your loaded swf should NOT be in an onLoad method.  if they are defined on the main timeline of the loaded swf, use:
    var url:String = "scene05.swf";
            var movieClip:MovieClip = createEmptyMovieClip("movieClip", 0);
            var listenerObj:Object = new Object();
            listenerObj.onLoadInit = function (target_mc:MovieClip):Void {
                //It should execute these functions that are located in the onLoad event in the loaded swf.
                target_mc.initBackground();
                target_mc.initBackgroundWeg();
                target_mc.initVehicles();
                target_mc.initForeground();
                target_mc.initKnoppen();
            var movieClipLoader:MovieClipLoader = new MovieClipLoader();
            movieClipLoader.addListener(listenerObj);
            movieClipLoader.loadClip(url, movieClip);

Maybe you are looking for