Duplicate a loaded SWF, no Actionscript?

Then... by writing a Flash based game, I have the main SWF file and its associated classes at one time, loading a single SWF file that represents a sprite in the game. I want to use this sprite repeatedly in the game, then I've duplicate after loading and expect that it would work. Unfortunately, after duplicate the loaded SWF file, it seems to be ignoring the actionscript timeline such as gotoAndPlay() calls.

Here is the configuration:

The loaded SWF that contains the animated sprite has a single layer on the timeline and basically has a number of labeled images dedicated to each animation - that is to say, there is a "walk_east" image, which traverses a character walking East, and at the end of this animation, has a command of gotoAndPlay ("walk_east") on one of the frames that it returns at the beginning of this particular animation to repeat the whole ordeal. The image after this one could be "walk_west" and contain West animation walk, etc. The very first frame of the SWF has a simple "stop()" call in there, so nothing no anime until the main SWF file tells the SWF loaded to do it (via a gotoAndPlay() call). This SWF has a base known as "Actor" document class

The main SWF load this SWF using a typical loader. Then, to duplicate the loaded SWF file, I opted to do something like that, where the "clip" is a reference to the loaded SWF loader:

var swfClass: Class = clip.contentLoaderInfo.applicationDomain.getDefinition("Actor");
var clone = new swfClass();

I can create any duplicates, I want, no problem. However, as soon as I start playing a (i.e., "clone.gotoAndPlay ("walk_east"), he comes will travel the entire chronology of the loaded sprite / duplicated SWF - ignoring the various actionscript code on the bases that SHOULD it be repetition of the cycle of specific animation I want... and despite the fact that when played, the same SWF does not display this behavior.")

As well as her duplicate movieclip causes duplicated SWF to lose his actionscript on the timeline?

Someone at - it ideas? This is expected behavior? I can't imagine this is how it should be - I want to only load the SWF sprite just once, to save bandwidth and then reproduce them as many times I want to in the game. This had to be done before... I can't imagine the developers simply reload the SWF even several times if necessary the same SWF to be used several times - that is to say, several enemies of the same type.

Or I just do it more difficult that there must be? Help, please!

RE: "the reason why I use the charger and not simply add the SWF file at the library of the FLA is because the sprites to load are dynamic based on a number of variables and a configuration XML file-driven." The only app knows which fund sovereigns to load at runtime based on things like what level the player entered... »

OK, so? You shouldn't need a charger for the sprites just because they are built dynamically.
You can keep all the config in the XML files, but keep the logic in separate classes that are all referenced in the same FLA file. You say "...". sprites to load are dynamic based on a number of variables... "OK, you can not create these sprites for parts that are in your library dynamically by using the operator"new "? Try a different approach, do not get stuck on the technical problem which is most likely a bug in the VM... If it doesn't, just leave it. Try a different approach.

Tags: Adobe Animate

Similar Questions

  • SWF swf communication - swf loaded swf loading

    Hello
    I read the article by kglad SWF SWF communication when two SWF files uses actionscript 3.0 gratefully, but, probably because of my stubbornness, I have swf loaded at loading swf communication problems to work for me.

    Loading of swf (swf1.swf) as loaded swf (swf2.swf) by casting to a MovieClip loader.content worked well for me.

    I want the swf to call a function on the timeline of the swf file loading.  (Aside, I'm doubting it's possible, but I'm really very uneducated on this topic)

    I copied the article code in swf2.fla as below;

    Create a variable to refer to the main scenario for swf1

    var swf1Main_mc:MovieClip; This assumes that swf1 is a movieclip.

    Create your listener to ensure that loaded swf has been added to the display list and can get a

    the reference to the main timeline (which is always the main timeline of the SWF loading).

    this.addEventListener (Event.ADDED_TO_STAGE, initF);

    function initF(e:Event):void {}

    swf1Main_mc = MovieClip (this.root);

    }

    and add a simple button with an event listener for mouse to invoke a function (in swf2) for example

    function btnClicked(e:Event)

    {

    swf1Main_mc.showME ();

    }

    where showME() is a function in swf1.  for example

    function showME()

    {

    trace ("swf1 called swf2 showME");

    }

    All I get is a runtime error "TypeError: Error #1006: showME is not a function."  to swf2_fla::MainTimeline/btnClicked().

    I took out what little hair remains try different variations in the code then, in desperation, please someone can spot what I'm doing wrong or point me in the right direction?

    Thanks for your time,
    Bob

    A loaded swf file should not try to control its parent.  The child must only be send an event to the parent to take action.  In this way, the child is completely independent of the parent as well as to be able to publish on his own.  To load completion than the parent must assign an event listener to the child for this event, and the event handler function.

    Example:

    Add something to raise the event in the child:

    dispatchEvent (new Event ("eventTriggered")); (if problem dispatchEvent, see: http://www.kirupa.com/forum/showthread.php?p=1899603#post1899603)

    In your SWF to loading/parent, listen for the complete event on the Loader.contentLoaderInfo.  In the complete event handler, add a listener for the event on the loaded swf file.

    triggered when external swf loading event handler
    function loaderCompleteHandler(event:Event) {}
    MovieClip (event.currentTarget.content) .addEventListener ("eventTriggered", eventHandler);
    }

    function eventHandler(event:Event):void {}
    trace ("event sent in loaded swf");
    }

  • How do I know if a loaded SWF file have the source code?

    Hi!, I need to know if a loaded SWF file have the source code. I develop an application running on iOS and admin can upload SWF files that show in the APP, but I must know before show (mobile Adobe AIR APP) or activate (PHP script server), if this SWF file have the source code for no show or enable him not it.,.

    Thank you!

    I have it!

    Only that we need to do is:

    1. If the first tank is:

    F-the swf is uncompressed

    C - compressed with Deflate

    Z - compressed with LZMA

    2. If it is compressed, uncompress it with the right method

    3. search MainTimeline string, if concluded the SWF actionscript so it is not found, the code is not actionscript.

  • Load SWF sound management - issue

    I have a sound problem. I have a flash (swf) loaded into another flash (my main swf) file.

    I want to cut all the sounds in loaded swf. I cut "timeline" sounds (with the loader object soundTransform) successfully, but my problem is with runtime played sounds.

    If the sound is reproduced using actionscript (not manually droped on the stage using the flash and the timeline) and soundTransform does not apply.

    I think I can't use SoundMixer because it would cut my main SWF sound too.

    I worked on it for a week and I would gladly appreciate your help.

    Thank you!

    Yet once, if there is no soundchannel for sound loaded (or other), you cannot control the volume of sound.  You can close the stream if the sound in the loaded swf file is itself responsible and open, but cannot control the individual sounds in the loaded swf file.

    If there is a soundchannel loaded, you can find (using actionscript) and use it.  But if you are unsure if a soundchannel exists, the best you can do is find the sounds, stop them if they are still streaming, restart them with a soundchannel and then cut the.

    but most people can stop just all sounds.  It works for you?

  • How to make a loaded.swf to stop a loop inside a clip

    I have a .swf which loads in a video into a Flash site. The .swf has all the stops needed to play once and stop once loaded. During a test outside the clip, it does what it should, but once loaded, it loops forever and the speed is faster. How do I stop this loop?  (This only happenes to .swf that have been made in CS4, does not happen with older .swfs made in Macromedia)

    Regarding the speed of the loaded swf file, it adapts to the FPS of your FLA file.  Change the frames per second setting in the FLA and then try to publish your new SWF file.  As applying a stop action you might be able to do, but I would check with Ned question first of all in terms of if you use ActionScript 1.0, 2.0 or 3.0.

  • Load swf in sequence files using the table

    I want to load a series of swf files in a scene in the order. I stumbled on the code Actionscript 3.0 in this forum that accomplishes this mission.


    var a: Array = new Array ("1.swf", 2 ".swf", "3.swf");
    var l:Loader;

    function didLoad(e:Event)
    {
    addChild (l);
    doLoad();
    }

    function doLoad()
    {
    If (a.length) {}
    l = new Loader();
    l.contentLoaderInfo.addEventListener (Event.COMPLETE, didLoad);
    l.Load (new URLRequest (a.splice (0,1)));
    }
    }

    doLoad();

    Unfortunately, I also want to be able to load swf files in the video clips from the scene. This code does that. It loads the swf on the other files in order. I want to be able to place the next swf files. I'd appreciate it if someone could tell me how to set the code to load the swf files in the video clips from the scene.

    I got help in another forum and got advice, but that didn't help out me. I can't make it work. No matter how much I play with it:


    var swfArray:Array = ["1.swf', '2'.swf];
    var firstSwf:DisplayObject;
    var secondSwf:DisplayObject;

    loadSwf();

    function loadSwf (): void
    {
    If (swfArray.length > 0) {}
    var loader: Loader = new Loader();
    loader.addEventListener (Event.COMPLETE, loadHandler);
    Loader.Load (new URLRequest (swfArray.shift ()));
    }
    }

    function loadHandler(e:Event):void
    {
    If (e.currentTarget.loaderURL.indexOf ('1.swf') >-1) {}
    firstSwf = e.currentTarget.content;
    addChild (firstSwf);
    } else {}
    secondSwf = e.currentTarget.content;
    addChild (secondSwf);
    }

    loadSwf();
    }

    I have since lost contact with the person who helped me. I read on berries, and I don't think it's my problem or why I can't get my head around it. Maybe it's the loop? In any case, if not the best action plan a better solution would be appreciated. Thank you!

    my bad.  Try:

    var a: Array = new Array ("swf1.swf", "swf2.swf", "swf3.swf");
    var tl:MovieClip =;

    var: index: uint = 0;

    loadF (new Event ("nada"));

    function loadF(e:Event) {}

    If (index<>

    TL ["ldr_" + index] = new Loader();

    TL ["ldr_" + index] .x = index * 200;  or something else

    addChild (tl ["ldr_" + index]);

    TL ["ldr_" + index].contentLoaderInfo.addEventListener (Event.Complete, loadF);

    TL ["ldr_" + index] .load (new URLRequest (a [index]));

    index ++;

    }

    }

  • To access the MovieClip instances in a loaded SWF file

    The situation as follows:

    loadedSWF.swf (published with Flash Player 8 AS2 or AS3 of Alpha Flash Player 9), contains on the symbols of the stage with the instance names: clipA, clipB, clipC, etc... No ActionScript is included in the file.

    In a Flex Builder 2.0 project, a component that extends mx.core.UIComponent load loadedSWF.swf:

    script
    var request: URLRequest = new URLRequest ("loadedSWF.swf");
    loaded var: Loader = new Loader();
    Loaded.Load (request);
    addChildAt(loaded,0);


    loadedSWF.swf successfully is displayed in the component's display list, but MovieClip instances that it contains are inaccessible.

    Its existence is verified:

    script
    trace (getChildAt (0)) / / result: [object Loader]
    trace (getChildAt (0) .root) / / result: [object _system_mx_managers_SystemManager]

    However, even if .root getChildAt (0) returns a mx.managers.SystemManager and mx.managers.SystemManager supports the numChildren property, trace (getChildAt (0).root.numChildren) survey error: 1119: access of the numChildren property possibly not defined through a reference with static type flash.display:DisplayObject.. Other methods like getChildAt(), etc. are also impossible to call. Direct access with getChildAt (0).root.clipA also throws an error, etc...

    Is it possible to access instances of the MovieClip on the stage of the loaded SWF file of a component that loads? I would appreciate any advice on this issue.

    a.Neko


    Note:
    The goal is to be able to load multiple clips into a component in a single loading of SWF file, then to instantiate the separately if necessary with addChild() and addChildAt() methods.

    Solution found:

    (Checked for loadedSWF.swf published with Adobe Flash Professional 9 Alpha Public)

    script (excerpt from Flex 2.0 AS3 component class)

    protected var clip: MovieClip = new MovieClip();

    protected final void requestSWF(value:String):void {}
    var request: URLRequest = new URLRequest (value);
    var asked: Loader = new Loader();
    requested.contentLoaderInfo.addEventListener (Event.COMPLETE, this.onRequestSWFComplete);
    requested. Load (request);
    return;
    };

    protected final void onRequestSWFComplete(event:Event):void {}
    event.stopPropagation ();
    This.clip = event.target.content.clipA; conversion of a local variable.
    this.addChild (this.clip);
    return;
    };

    this.requestSWF ("loadedSWF.swf");

    Result: clipA is added separately to the display of the component list.

    a.Neko

  • Calls to functions from loaded SWF files

    I have a Flex application that uses the SWFLoader object to load an external SWF file (which has also been developed in Flex) in a section of the page. The parent SWF file defines several variables and global functions in ActionScript I would use from all SWF files loaded in the SWFLoader. Is it possible in ActionScript to access the functions and variables that are defined in the SWF file the SWF load/child parent? The two SWF files are on the same domain, so there should not be problems of security.

    Peter thank you very much for your answer. I have tried loading in the same ApplicationDomain, but he did not what I expected from him. I, however, found the solution to my problem. I needed to understand how cross-script from a SWF file loaded the loaded SWF file. I discovered how and published a description of my conclusions on another thread that was no longer relevant to my question. The described solution has allowed me to do what I needed without touching the ApplicationDomain.

  • Can you tell when a loaded SWF has reached its last picture?

    I used loadMovie to load an external SWF into half less of a main "shell" swf When the loaded SWF playback (it's just an animation) finished, I need to fill in a text field with the word "DONE". The text field lies on the _root, and I need a way to know when the loaded SWF file has reached its last picture...

    It would be obviously easy if I had the. FLA of the loaded SWF file because I could write any actionscript code on the last frame of the SWF to fill the textfield _root. Alas, I do not have the source of the loaded SWF FLA, so I need a way to have the "shell" SWF/FLA main know when this loaded SWF has reached its end. Is this possible?

    Thank you!!!

    DIY_Lobotomy,

    > The reality of my situation, it's that there is only a 'menu' of sorts that
    > Gets load in "contentClip". This "menu" has a bunch of links.

    So far so good.

    > When you click on it, each link load a DIFFERENT swf file in 'contentClip '.
    > It's THESE sovereign wealth funds I need to see the end of.

    It is always correct.

    > There is actually more than one, so they're not exactly being
    > loaded directly from my main movie, because they are actually loaded
    > based on a link that is clicked in the movie that is currently loaded
    > in "containerClip".

    The concept is still the same, no matter what happens. Any depth the
    a clip-expenses-other chain goes, you have to keep the notches on each link in the chain.
    When the last link has loaded, you will be able to make your object reference
    in this clip. This film clip - because it's an instance of the
    Class MovieClip - will have the properties _currentframe and _totalframes.
    You'll just check * that * cliip instead named properties
    contentClip in my own example.

    You can run a loop using onEnterFrame or, if you prefer, with setInterva().
    Is not little matter, as long as ask you repeatedly deep
    clip to test its current image against its last picture (this assumes that)
    the test clip is a linear animation matching the end to his
    last image; otherwise, you could check against this arbitrary _currentframe
    The frame number).

    > I hope it was not too complicated! You always have a solution?

    Not too confused to understand, but it might be confusing to the road
    through in practice. Not to be confused, actually, but meticulous... you will
    be careful with your multiple paths. The nested clips are very similar
    folders nested on your hard drive. The instance names relate to the
    folder names.

    Now, if this menu is not an instance name you condition - or if
    the forks on the way has an instance name you can't control - you can
    always refer to nested clips. If you test your file in the
    Debugger Panel, you will see all the instances arranged in hierarchical order.
    You will see that automatic instance names are provided (something like
    ("instance1", "instance2", etc.).

    David Stiller
    Contributor, how to cheat in Flash CS3
    http://tinyurl.com/2cp6na
    "Luck is the residue of good design."

  • Calling functions / set variables in loaded SWF

    You know how you can create a Movieclip object, add a function or a variable, and then call this function or change this variable to the SWF file that includes? I want to be able to do it, only with SWFs that are loaded at run time.

    My "main" SWF is just something the type of menu. The user clicks a button in my HAND. SWF and the HAND. SWF and then load the SWF associated with this button, using the AS 3.0 method Loader () - URLRequest () - addChild () that everyone always asks questions on prescribed.

    It works very well. But now I have a few custom and other objects (ie., not only the channels) in my HAND. SWF I want power sharing with the loaded SWF files. preferably, I'd use a function of the type of accessor (ie., LoadedSWF.GiveMeTheCoolObject (MyCoolObject)); Although at this point, I'm willing to hack the object itself (ie., LoadedSWF.CoolObject.CoolField = MyCoolObject.CoolField ;) if that's what it takes.

    I tried to call the functions and setting the fields, but the AS 3.0 compiler doesn't care for this kind of nonsense on its objects defined by the generically. Also note that, at runtime, a call to LoadedSWF.hasOwnObject ("GiveMeTheCoolObject") returns true.

    So my colleagues big brain, what is the magic?

    In advance, thank you for the help!
    Scott

    Kglad,

    Quote:
    Posted by: kglad
    the error message, seems, your function expects a member of the class MyCoolObject, correct?
    and MyCoolObject is not an instance of this class. so, you have to fix that. That is to say, create a member of this class, and use this class as a parameter of the function member.

    Heh, that's what the error message says all right. But the object IS actually an object of class MyCoolObject. I looked at this thing for hours and MyCoolObject IS an instance of this class. I tried different combinations of casting (including the cast on an object and passing that) but had no luck whatsoever.

    So I googled this particular runtime error message ("Error #1034: has no Type constraint: cannot convert '" ") and found a ton of links to other people with a similar problem. As a general rule, the problem was just as you say, someone passes a button as a string, that kinda thing. But a guy had a problem with an object that it has derived from the event class. Once the hours spent trying to make it work, he has tried to override clone() of the base class 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 it would be better if all the 'real work' is held in the HAND. SWF file. This approach would solve some other problems, and it makes sense in a mindset of "separating the display of data.

    If (and this is the interesting part) I changed the API for the LOADED. SWF to accept the pairs of strings (ie., LoadedSWF.AddToDisplay (String Name, String Data)) rather than accept MyCoolObj. Ran and Viola, now we work without any throw exceptions in. After this moment of glory, I created a couple of other APIs that comes from base classes (a type int, the other a type function) agreed and was happily on my way.

    On this basis, I understand while passing another base class objects (IE, the derived class) to load MovieClips via custom function API is... perhaps not so simple you'd expect. In the grand scheme of things well, not a big deal: as far as I'm concerned AS3 rocks.

    Kglad, thanks again for all the help: your comments on how this was the big push that I needed to get through the last barrier of this project.

    For those who read this topic for the ' how to call functions or set variables in a loaded SWF file?

    The short answer is cast to the SWF file that is loaded as a MovieClip content object and then call the function or change the variable:

    Load the SWF file (you saw this code a million times)
    var LoadedSWFObj:Loader = new Loader();
    var MyURL:URLRequest = new URLRequest("LoadThisSWF.SWF");
    LoadedSWFObj.load (MyURL);

    It is within your Event.COMPLETE Manager:

    Cast as a MovieClip object and work with it.
    var LoadedSWF:MovieClip = LoadedSWFObj.content as MovieClip;

    or another way to perform a cast:
    var LoadedSWF:MovieClip = MovieClip (LoadedSWFObj.content);

    Call yer function:
    LoadedSWF.CallMe ();

  • FLASH AS2 main swf loaded swf playback controls

    Hello

    I have two swf files. The main (main.swf) swf that loads another swf (external.swf).

    The current code in my main swf that loads external swf file is:

    Stop();

    this.createEmptyMovieClip ("holder", 1);

    holder.loadMovie ("content/swf/M01/disclaimer.swf");

    The loaded swf file must unload on a click event, then the main swf movie should resume playing.

    The code in the swf file is:

    on (release) {}

    _level0.gotoAndPlay ("hideMSG");

    _parent.unloadMovie("content/SWF/M01/disclaimer.swf",1);

    }

    The external swf file loads and unloads perfectly, but the film does not seem to take over.

    When I try to use _level0.play, it seems to reload and restart the file main.swf.

    Any help would be greatly appreciated.

    Laura

    No, there is no downtime in this context, there is indeed a play(); which is exactly what I want.

    I managed to get it using variables instead of work.

    Thank you

    Laura

  • Removal of the external loaded swf does not decrease memory

    I'm developing a desktop application using flash builder 4.7, where I am loading swf external swf main, but after his withdrawal, it remains in the process (check in the Task Manager. os: windows 7), process decreases a little, but not as much as it should be. so, whenever I insert again and remove, process increases and after multiple loading, application crash down. I'm removing it like this

    if (_loader.numChildren>0)

         _loader.removeChildren(0,_loader.numChildren-1);

    _loader.unload();

    _loader.stopAllMovieClips();

    _loader.unloadAndStop(true);

    _loader.loaderInfo.removeEventListener(Event.COMPLETE, onComplete);

    this.removeChild(_loader);

    _loader = null;

    I have added custom destroy the external inside swf method and started calling him. I was almost everything, remove (almost say because it might be something I missed, because it's huge project) but still the long process.

    That I created empty swf (new project without code and nothing in it) and tried to integrate and to see what is happening. It was just the same...

    Then I thought again Air SDK may have solved this problem, so I've updated SDK for 19.0.0.207 currently more recent, but still nothing, even if the process now increases above.

    I think that it comes to Flash gc. One of the solutions is to have one and only instance of swf external and removeChild and addChild it whenever you need. It is a bad way to do it. Process will not increase all the time, but in my case I have many SWFs to load and it will slow down my request for computers of RAM low resources it could cause the crash and it is bad to have unnecessary things running in the background process

    so any suggestions are welcome

    No need to stop the video clips and remove... use unloadAndStop() and it will all stop and unload the file... as it is not possible to call the content of charger (clips) stop after the unload method, it is already removed... So, try to use only 3 lines only to unload the file.

  • loaded SWF does not work properly

    I created a maze game (the idea is to draw a line to connect between 2 video clips in the wall of the maze)

    This is the code of the game:

    Stop();

    import flash.display.Sprite;

    import flash.events.MouseEvent;

    We draw or not?

    var drawing: Boolean;

    var isStart = false;

    var drawingSprite:Sprite = new Sprite();

    addChild (drawingSprite);

    drawingSprite.graphics.lineStyle (3, 0 x 000000);

    drawing = false; to start with

    stage.addEventListener (MouseEvent.MOUSE_DOWN, startDrawing);

    stage.addEventListener (MouseEvent.MOUSE_MOVE, draw);

    stage.addEventListener (MouseEvent.MOUSE_UP, stopDrawing);

    function startDrawing(event:MouseEvent):void {}

    drawingSprite.graphics.moveTo (mouseX, mouseY);

    drawing = true;

    }

    draw function (event: MouseEvent) {}

    {if (Drawing)}

    drawingSprite.graphics.lineTo (mouseX, mouseY);

    }

    }

    function stopDrawing(event:MouseEvent) {}

    drawing = false;

    }

    Adds an event listener on the stage with the move of the mouse event.

    stage.addEventListener (MouseEvent.MOUSE_MOVE, detectHits);

    function detectHits(event:MouseEvent) {}

    If the mouse touches the edges of the labyrinth, return to the

    first scene and remove the mouse move event listener to the

    Stadium.

    If (wall_mc.hitTestPoint (mouseX, mouseY, true)) {}

    If (isStart == true) {}

    drawingSprite.graphics.clear ();

    gotoAndPlay (3);

    isStart = false;

    stage.removeEventListener (MouseEvent.MOUSE_MOVE, detectHits);

    }

    }

    If the mouse button point the brush, proceed to the third stage and

    remove the mouse event listener move scene.

    ElseIf (hit_mc.hitTestPoint (mouseX, mouseY, true)) {}

    If (isStart == true) {}

    drawingSprite.graphics.clear ();

    gotoAndPlay (2);

    isStart = false;

    stage.removeEventListener (MouseEvent.MOUSE_MOVE, detectHits);

    }

    }

    }

    mc_start.addEventListener (MouseEvent.MOUSE_OVER, fl_MouseClickHandler);

    function fl_MouseClickHandler(event:MouseEvent):void

    {

    isStart = true;

    }

    works very well and published as swf

    When I try to load this game to another fla

    the market never properly Yes the loaded swf file and the game starts well

    but when I start to draw the line in the maze and without touching any wall it moves on the chassis (lost u)

    The error is always using mouseX and mouseY.  If you had failed to compensate for the placement of the loaded swf file then you will would not compensate for mouseX/Y for one would be the same value as mouseX/Y for those responsible.

    You need to deal with the overall conversion to local or you must build in compensation.  Because it is a fixed value (35), you can set the code in the swf file to use a Compensator variable that is set to zero by default in the swf file (for when he plays his own).  When you load it into another file, then you need to wait after is fully loaded and loading file assign a different value to this trim... in this case it would be-35

    Another way to solve this problem would be to move all the content in the swf 35 pixels to the right and downwards (in itself).  Then it would be unnecessary to adjust the positioning and the mouseX/Y values would be the same for the main movie and the one responsible.  Then, the only problem might be using the SWF itself.

  • Weird, click on load SWF event

    Hi, recently I worked on a project aimed at analysing and disseminating the announcement of VAST3. One thing I have to do is listen to the MouseEvent.CLICK on the loaded SWF file.

    I added the charger to a sprite and add the listener of events on the sprite. When I load the following SWF file, the click event is fired only when I click on the bottom. If I click on the logo of the site, no click event occurs.

    If I downloaded the SWF file on my hard drive, everything works fine. The click event can be triggered whenever I click on the ad.

    The SWF file I load has all the embedded assets.

    I want to know what is causing this problem because with some SWF files I can only listen to the MouseEvent.CLICK event on the _loader.content so that some, like the one below, meets partially for click event on _loader.content and _container.

    I simplified the code as shown below.

    package  {
        import flash.display.Loader;
        import flash.display.Sprite;
        import flash.events.MouseEvent;
        import flash.events.Event;
        import flash.net.URLRequest;
       
        public class Main extends Sprite {
    
            private var _container:Sprite;
            private var _loader:Loader;
    
            public function Main() {
                _container = new Sprite();
               
                _loader = new Loader();
                _loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
                _loader.load(new URLRequest("http://gtms04.alicdn.com/tps/i4/TB1Fzd.FVXXXXaOXXXXeflbFXXX.swf"));
               
                _container.addEventListener(MouseEvent.CLICK, onClicked);
                addChild(_container);
            }
           
            private function onComplete(event:Event):void {
                _container.addChild(_loader);
                _loader.content.addEventListener(MouseEvent.CLICK, loadedSwfClicked);
            }
           
            private function loadedSwfClicked(event:MouseEvent):void {
                trace("loaded swf clicked"); // When I click on the Logo and the animal
            }
           
            private function onClicked(event:MouseEvent):void {
                trace("clicked"); // When I click on the gradient background
            }
        }
    }
    

    One of my colleagues told me that it has something to do with the issue of security. So I need to make a call Security.allowDomain like this:

    private void onComplete(event:Event):void {}

    Security.allowDomain (_loader.contentLoaderInfo.url);

    _container. AddChild (_loader);

    _loader. Content.addEventListener (MouseEvent.CLICK, loadedSwfClicked);

    }

    And the click on the loaded SWF file will appear correctly.

    Because the bottom layer degraded of the only loaded SWF file contains a Bitmap, which is not an InteractiveObject instance, it will not answer the MouseEvent.CLICK listener on the _loader.content.

  • Control loaded swf on the main timeline

    Hello

    I'm working on loading external swf files for ios. I am able to load swf files and assembled visible or invisible in different settings. I have trouble controlling the swf files loaded on the main timeline. Specifically, I would like to have a button on the main timeline, that when you click on will move a swf loaded to frame 1.

    Here is a code that loads a swf file:

    var myLoader1:Loader;

    var loaderContext1:LoaderContext = new LoaderContext (false null, ApplicationDomain.currentDomain),

    if(myLoader1 == null)

    {

    myLoader1 = new Loader();

    addChild (myLoader1);

    }

    myLoader1.load (new URLRequest("folder/file1.swf"), loaderContext1);

    myLoader1.visible = true;

    backbutton.addEventListener (MouseEvent.MOUSE_DOWN, backbutton1);

    function backbutton1(myEvent:MouseEvent):void {? myLoader1.gotoAndStop (1) ;}}  (this line does not work)

    (Once I load file1.swf, in the file1.swf I click a next button to move on to different periods.) My question is: hHow do I code the "backbutton" on the main timeline so that it causes the file1.swf to go to frame 1?)

    Thank you for your help.

    After loading is complete (and assuming that you load an as3 swf), you can use:

    MovieClip (myLoader1.content) .gotoAndStop (1);

Maybe you are looking for