Calling function flex SWF loaded into Flex

Hi, just a few days in flex development and a question about SWFLoader.

Is it possible to call a function from flex to a SWF file loaded by SWFLoader control?

For example, I have a SWF animation with a button, loaded into a Flex application and I would like that when the user clicks the button, it will call a function in the flex application.

If possible, can we send parameters with the function call?

Thank you for all your help.
Mika

There are two possibilities, depending on what type of SWF you load. If you load a SWF9, then check on ApplicationDomain. If you load SWF8 or earlier, then read this technical note:
http://www.Adobe.com/go/749eaa47

Tags: Flex

Similar Questions

  • v2 combo in swf loaded into flex goes crazy

    When I anactionscript 2 swf with a v2 combobox
    and I load into a flex application using a swfloader
    The combo gets crazy and you click a currentItem item becomes another element that you clicked on.

    If anyone has come across that?
    does anyone have a solution?

    Thank you
    Eyal

    This has been acknoladged as a bug by adobe
    http://bugs.Adobe.com/jira/browse/SDK-13131

  • call functions in SWFs in a tilelist?

    I used the code below to load SWF files into my tileList and set their colors using setData() in each swf. Everything seems to work except "source: e.currentTarget.content". Sovereign wealth funds seem to be mixed at random whenever it runs. Their colors are properly defined and all the other info tilelist is correct. What did I do wrong with "source: e.currentTarget.content"? I can exchange "source: e.currentTarget.content" with "source: myXMLList [loadPosition] .source" gives me the correct swf but then the colors are not defined.

    for (var f: int = 0; f < myXMLList.length (); f ++) {}
    var ldr:Loader = new Loader();
    ldr.contentLoaderInfo.addEventListener (Event.COMPLETE,
    {function(e:Event):void}
    Object (e.currentTarget.content) .setData (myXMLList [loadPosition] .parameter [0], myXMLList [loadPosition] .parameter [1]);
    myTileList2.addItem ({label: myXMLList [loadPosition] .label path .path: myXMLList [loadPosition], source: e.currentTarget.content, cost: myXMLList [loadPosition] .cost, category:myXMLList[loadPosition].@category});})
    loadPosition ++;
    });
    var urlReq:URLRequest = new URLRequest (myXMLList [f] .source);
    LDR. Load (urlReq);
    }

    Oh, I've been letting you know how to get the values of the correct settings, i.e. the values of the parameters for the corresponding Chargers. These parameter values would be in the call "setData" as you mentioned in the first post.

  • Loading a SWF file into the feeder of a third person

    Hello again.

    I have a Master SWF, which has several buttons on its stage.  These buttons are loading a remote SWF to an interactive chart in the master left upper corner of the film.  These loaded clips inside are several clickable areas which I would like to use to load yet another movie in the bottom half of the Master clip... so it loads a remote SWF to third party scene.

    I'm having a problem of simple targeting.  I'm not sure how to call a movie to load into a loader on the stage of a different clip.  I use 'parent'... but I got something wrong:

    _________________________________

    var unitSwfLoader:Loader = new Loader();
    unitSwfLoader.x = 25;
    unitSwfLoader.y = 390;

    function getUnitSWF(e:MouseEvent):void
    {
    unitSwfLoader.load (new URLRequest ("units /" + e.currentTarget.name + ".swf"));
    parent.addChild (unitSwfLoader);
    }

    You can use root to reference the main timeline from anywhere.  You may have only thrown like a movieclip:

    MovieClip (this.root) .addChild (unitSwfLoader);

  • getURL works not when the swf is loaded into another swf

    Okay, I need help with something relatively simple which for some reason that I was not able to find information about everything?

    I hope that this will be something easy to correct.

    I basically the following:

    • my main movie "Home.swf".
    • another film "Sub.swf".

      I loaded "Sub.swf" in "Home.swf" via an empty movieclip.

      In "Sub.swf", I have some links that, when clicked call getURL and open an HTML page in the browser.

      But for some reason any the getURL does not work and I think its because the getURL is called from a movie loaded into "Home.swf".

      I tried to change the actionscript code for:

      _root.getURL('/MyPage.html');
      _parent.getURL('/MyPage.html');

      but neither (_root / _parent) seems to work?

      Need some help here please.

      Thank you very much.

      Kind regards
      M.

    It is not the getURL that's the problem. It's your _level0.imgMC.MC5 that is the problem.

    in Sub.fla, replace _root _level0 and add the code below your delivery code:

  • How to control the video swf loaded in the loading component?

    I have an external swf file loaded into the loading component. The external swf loaded into the component loading stops at departure. I want to play by a button outside the loading component that is located in the main swf movie. CAN SOMEONE HELP ME CONTROL THE VIDEO SWF LOADED INTO THE COMPONENT OF LOADING EXTERNAL?

    You can target the SWF via the content property of the UILoader.  If the name of the instance the UILoader is ldr...

    MovieClip (ldr.content) .play ();

  • 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 ();

  • Need to control the scaling a swf loaded when called from a file containing swf

    Flash Professional 11 (build 11.0.2.489)

    Problem: when a SWF is loaded into a SWF containing the swf called scales to fill the window. When the stand alone SWF is played from a HTML or SWF format, it does not adapt and display correctly. I tried to adjust the dimensions of the stage, publish settings, etc. nothing works.

    My swf container has a Clip called contentContainer and three buttons. The buttons just addChild (selected swf) and removes the current swf child.

    Is there a way to control the scaling of a swf file loaded into another swf?

    The relevant code after calling the functions of office is as follows:

    function onCompletePreloading (): void
    {
    contentContainer.addChild(_swfClipsArr[0]);


    IntroButton.addEventListener (MouseEvent.CLICK, setContent);
    drilldownButton.addEventListener (MouseEvent.CLICK, setContent);
    EnterDatesButton.addEventListener (MouseEvent.CLICK, setContent);
    }

    function setContent(event:MouseEvent):void {}
    var _swfToAdd:MovieClip;
    {switch (event.target.name)}
    case "IntroButton":
    _swfToAdd = _swfClipsArr [0];
            break;     

    case "drilldownButton":
    _swfToAdd = _swfClipsArr [1];
            break;  

    case "EnterDatesButton":
    _swfToAdd = _swfClipsArr [2];
    break;

        }

    contentContainer.removeChildAt(contentContainer.numChildren-1);
    contentContainer.addChild (_swfToAdd);
    trace (_swfToAdd.customID);

    }

    instead use:

    contentContainer.addChild (_swfToAdd);

    use:

    addChild (_swfToAdd);

    or, if you use this parent to a design:

    var mc:MovieClip = new MovieClip();

    mc.addChild (_swfToAdd);

  • Detect if a swf file is loaded into another swf

    Is there a way for my flex swf to detect if it has been loaded into another swf parent or if it is running standalone?

    Any help appreciated.

    Marcus

    SystemManager.isTopLevel and isTopLevelRoot

  • Question of embedding fonts when SWF is loaded into the charger

    Hello.

    I ran into a problem of the incorporation of police where all the text fields with embedded police disappear when the SWF file is loaded as a child into a parent SWF. When the SWF file is read directly as stand-alone or inside a container of page HTML, text fields display perfectly with embedded fonts. Just not if the SWF is loaded into another SWF. It's basically the way I joined the police:

    [Inside the document class]

    [Embed (source="/Library/Fonts/Arial.ttf", fontName = "FontVerdana", mimeType ="application/x-font-truetype")]

    public static FontVerdana: Class const;

    var theFont * = new FontVerdana();

    var myText:TextField = new TextField();

    var fmt:TextFormat = new TextFormat();

    FMT.font = theFont;

    myText.embedFonts = true;

    myText.setTextFormat (fmt);

    Incidentally, I either work on a Mac using Flex 3.5. Anyone encountered this problem? What can be done to fix this?

    See you soon,.

    Harry

    Check out my blog on embedded fonts

    --

    Alex Harui

    Flex SDK Team

    Adobe System, Inc..

    http://blogs.Adobe.com/aharui

  • Unable to access MovieClips and functions in a loaded SWF

    Hello world

    I'm just trying access anything whatsoever within the loaded SWF and all I get is 'null '.

    I have the code in the SWF parent who must tell the SWF movieclip child what to do, but nothing works. It's a piee of cake into AS2, and I can't seem to get anything of crossover in AS3.

    Here is my code:

    import com.greensock.TweenMax;
    import flash.display.MovieClip;
    
    var myLoader:Loader = new Loader();
    var url:URLRequest = new URLRequest("SWCS_S3_500x250_exp_panel_2.swf"); // in this case both SWFs are in the same folder 
    myLoader.load(url);  // load the SWF file
    panel2.addChild(myLoader);   // add that instance to the display list, adding it to the Stage at 0,0
      
    panel2 = myLoader.content as MovieClip;
    
    photo_about.alpha = 0;
    photo_downloads.alpha = 0;
    
    //panel2.content_about.alpha = 0;
    //panel2.content_downloads.alpha = 0;
    
    function closeSection():void
    {
              panel2.controlsMC.forcePause();
    
              TweenMax.to(photo_about, .5, {alpha:0});
              TweenMax.to(photo_downloads, .5, {alpha:0});
              TweenMax.to(photo_home, .5, {alpha:0});
      
              TweenMax.to(panel2.content_about, .5, {alpha:0});
              TweenMax.to(panel2.content_downloads, .5, {alpha:0});
      
              TweenMax.to(panel2.controlsMC, .5, {autoAlpha:0});
              TweenMax.to(panel2.content_home, .5, {alpha:0});
    }
    
    

    Panel2 traces null and all clips loaded in draw property undefined errors.

    Can someone please tell me what I'm doing wrong? I would be happy to see what Miss me and feel like this should be a piece of cake.

    Thanks for any help!

    You do not add the content of the scene to 0.0, you add it to panel2 to 0,0.  Then you take panel2 and assign to something that probably does not exist at the time wherever you set it.  You must wait until the loader load before trying to do something with its content, otherwise it has no content (null).  Similarly, you can not control anything in the loaded swf file, until it is fully charged.  So to assign an event listener for the property contentLoaderInfo the loader to determine when loading is complete, and have the event handler works deal from interacting with it.

    var myLoader:Loader = new Loader();

    var url: URLRequest = new URLRequest ("SWCS_S3_500x250_exp_panel_2.swf");

    myLoader.contentLoaderInfo.addEventListener (Event.COMPLETE, processLoadedSWF);

    myLoader.load (url);

    function processLoadedSWF(evt:Event):void {}

    deal with the swf loaded here

    but you do not want to be assigned to the panel2 object that contains the charger

    }

    With regard to the control of anything anyone inside of the swf you are loading, is an AS1/2 or an AS3 swf?

  • Could not use DB function call to insert a row into a table OBIEE

    Hello

    At the prompt of the OBIEE report, I create a DB function in a variable column of the guest, so whenever I'm in the dropdown variable ob column call the function DB call.

    The function call is insert a row into a table in the database. However, it seems impossible to insert the row into the table.

    I have test the function in the sqlplus and it works, if the function has no problem. The problem is OBIEE failed to insert something in the datebase, it can only read from it.

    Any ideas on how I could fix it?

    Thank you!

    Hello
    Use your Evaluate function and the variable correctly. In the case where u called this function evaluate in the report in a column, and he has 100 files it contains, it will call db 100 times.

    Kind regards
    Anitha.B

  • How to load external swf files into the AIR

    I try this code its working at the computer, but when I publish this .apk or .ipa file, my external swf file does not open

    (I included my external file as well)

    places_btn.addEventListener (MouseEvent.MOUSE_DOWN, newvid);

    function newvid(event:MouseEvent) {}

    trace ("you clicked me");

    var loadit = new Loader();

    addChild (loadit);

    loadit. Load (new URLRequest ("scene02.swf"));

    }

    01.jpg

    Add this in your newid function:

    You forgot to put the beginning of your original function:

    var loadit = new Loader();

    addChild (loadit);

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

    loadit. Load (new URLRequest ("scene02.swf"), _lc);

  • video SEO is not even when SWF is loaded into SWF

    Copy the following code is based on the _droptarget info in the Actionscript 2.0 language reference. It works fine by itself but the breaks when the SWF is loaded into another SWF. Notice that I use the _lockroot property to keep the _root of the loaded clip.

    I've isolated the problem to the "if" condition The player does not seem to recognize the equivalence of the names. But when you debug with Trace, the names are the same.

    The goal is to have the drag snap object to the target object when the target but snap to its origin, if not on target. It works in 6, but the drag object snaps back to its original 7 - as if he had not fallen on the target object.

    A solution and the explanation is in the attached code:

  • . Loaded SWF loses functionality (Flash 8 Loader component)

    Hi all, long time listener, first - time calling...

    I have a file with a Loader and ProgBar component. The charger draws in a SWF with buttons. The buttons control the sound objects to play MP3 files. When the second swf loads, do not play the MP3. The music is incorporated, not loaded on the outside. If I call the direct URI of the swf file, the dumb thing plays! But loads the swf file loaded via the Loader component..., the display of buttons their bearings... but the sounds won't play... it fails to test the animation too...

    I am sure this is just a fundamental vice that I created (the missing brace syndrome), but I have no idea what it is, and any help would be greatly appreciated.

    Thanks Lon... Sorry I haven't decided to go back but yesterday, it was my birthday and I'm hanging with family all day...
    IM such a BONE head... it's here (referring to the above displayed code...)

    Instead of mySound = new Sound();

    mySound = new Sound (_root);

    Thank you guys for your help... two obviously that would have set the MovieClipLoader thingie too

    Peace

    Stephen McDaniel
    New Century Graphics

Maybe you are looking for

  • When my iphone was purchased

    When and where to buy my iphone

  • AVI to play on a dvd player

    I don't remember since my bad memory since the accident. Until I got to where I used nero express to create a data dvd. Ive chatted with before tech and they said that it will work on the Vision. I don't know what I removed but I use just use express

  • RE: SCANNING AND RETOUCHING WITH A PRINTER ALL-IN-ONE HP DESKJET 2540.

    I have a new HP 2540 all-in-one printer and it works beautifully! The only thing is that when I scan a document and want to change I can't. This printer does not come with a built-in OCR program? Help, please! Thank you

  • Quick help please - App in the Simulator

    Hi guys,. I hope that for a quick resolution here to get my apps submitted before the deadline for the free playbook I went through all the tutorials and successfully signed my android applications and managed to get the icon to the simulator by clic

  • The computer why not my password?

    I put my computer to require a password on wake up. I expect to have to put a password, after he was arrested, put in standby or sleep. But instead to require a password, it shows my account icon and a touch of the space bar allows me to access my ac