Load swf and get a SimpleButton in it

I load a swf and want to get a button in the swf. But the button I get is NULL. I am sure the button's name is right and exists. Could somebody help me to solve this problem?
package
import flash.display.MovieClip;
import flash.net.URLRequest;
import flash.display.Loader;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.display.SimpleButton;
import flash.display.LoaderInfo;
public class MyClass1 extends MovieClip
  public function MyClass1()
   super();
   var swfLoader:Loader = new Loader();
   addChild(swfLoader);
   var bgURL:URLRequest = new URLRequest("secondFlash.swf");
   swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadProdComplete);
   swfLoader.load(bgURL);
   var currentSWF:MovieClip = new MovieClip();
   function loadProdComplete(e:Event):void {
     var loaderInfo:LoaderInfo = e.target as LoaderInfo;
      var mv:MovieClip= MovieClip(loaderInfo.content);
    var btn1 = mv.getChildByName("btn1") as SimpleButton;
    trace("mv"+mv);
    trace("btn1="+btn1);

The code you show works fine for me.  How is btn1 created/named in the second swf file?  If you create it dynamically and do not assign a name property to it, it does not have the name you think it does.

Similar Messages

  • Load swf and play movieclip inside it

    I want to load  a swf and play a moveclip inside it, but the SWFLoad.content always is null. Does sombody know how to resolve this problem?
      private var SWFLoader:Loader;
      public function myApp3()
       SWFLoader = new Loader();
       var request:URLRequest = new URLRequest("FlashAS3_2Flex.swf");
       SWFLoader.load(request);
       this.addChild(SWFLoader);
       var currentSWF = MovieClip(SWFLoader.content);//SWFLoader.content is null
       currentSWF.myClip.gotoAndPlay(1);

    The code you show works fine for me.  How is btn1 created/named in the second swf file?  If you create it dynamically and do not assign a name property to it, it does not have the name you think it does.

  • Loading SWFs and setting z-index

    I have a project that involves 10 SWFs files. I know how to load them using one container. The problem I have is that when a new SWF loads, it covers the main navigation's drop menus from main container. The navigation bar on main container is a movie clip labeled nav_btns.
    Can someone help me set the z-index of main container and other SWFs as they load?
    Here is my code, which works when loading SWFs
    import flash.display.MovieClip;
    import flash.display.Loader;
    import flash.net.URLRequest;
    import flash.events.Event;
    var Xpos:Number=10;
    var Ypos:Number=115;
    var swf:MovieClip;
    var loader:Loader=new Loader();
    var loader1:Loader= new Loader();
    var defaultSWF:URLRequest = new URLRequest("homePage.swf");
    loader.load(defaultSWF);
    loader.x=Xpos;
    loader.y=Ypos;
    addChild(loader);
    function buttonClick(event:MouseEvent):void {
    removeChild(loader);
    var newSWFRequest:URLRequest= new URLRequest("Movies/"+ event.target.name+".swf");
    loader.load(newSWFRequest);
    loader.x=Xpos;
    loader.y=Ypos;
    setChildIndex(this, -1);
    addChild(loader);
    nav_btns.homePage.addEventListener(MouseEvent.CLICK, buttonClick);
    nav_btns.homePage.txt.text="HOME";

    add (or re-add) the menu to the display list after you add the loader.

  • Exporting Flash(SWF) and Getting No Audio

    Hello All,
    I'm new to these boards and have only posted once previously.
    I'm recording lectures with Captivate 3 for University
    professors speaking in front of a class using power point. I have
    one Captivate project with about 570 slides. When I publish this
    project to SWF and play it in html and/or the skin player there is
    no audio.
    There is audio when I play each slide or when I preview the
    project but no audio when I publish it.
    I have audio selected as MP3 96 kbps, 44.10 KHz in the
    preferences of Publish but there's just nothing.
    Any ideas of what could be going wrong?
    Also, I'm not sure if I should post this in the Recording
    category but during some of these long recordings, part of the
    lectures end up recording blank white slides. There is audio as the
    professor is speaking and surely there's an image on the computer
    with power point but Captivate is recording pure white. Troubling.
    THANKS!

    I have the same problem here. I only have 47 slides, and
    about 12 have audio. The total size of the .cp file is 15 mb. I
    only hear audio when I am looking at the slides and press F3. None
    of the slides are muted. I have made sure that the "Include Audio"
    checkbox is checked. I do not have audio in preview mode or in the
    published swf or exe file. I am at a loss here.

  • Trying to load firefox and get warning that file can harm my pc

    I am having a problem loading firefox. I get a message that this type of file can harm my computer. I click save but still it does not download.

    To experiment more safely, could you create a new Firefox profile? The new profile will have your system-installed plugins (e.g., Flash) and extensions (e.g., security suite toolbars), but no themes, other extensions, or other customizations. It also should have completely fresh settings databases and a fresh cache folder. If we get your bookmarks into the new profile successfully, you can create a backup and restore it in your regular profile.
    Exit Firefox and start up in the Profile Manager using Start > search box (or Run):
    firefox.exe -P
    Any time you want to switch profiles, exit Firefox and return to this dialog.
    Please do not delete anything in this dialog.
    Click the Create Profile button, choose a name like TESTING, and skip the option to choose a folder. Then start Firefox in the new profile you created.
    If you have backups in the JSON format (e.g., bookmarks-2014...json) try to restore one to this TESTING profile. This article has the steps (you will need to use Choose File... to get to the backup):
    [[Restore bookmarks from backup or move them to another computer]]
    Does that work and give you complete results?
    If not, the next thing I would try is to drop in the places.sqlite file you have and see whether Firefox can read it properly.
    First, open up a Windows Explorer window to this new profile folder. You can do that using either
    * "3-bar" menu button > "?" button > Troubleshooting Information
    * Help menu > Troubleshooting Information
    In the first table on the page, click the "Show Folder" button
    Got the list of files? Okay, leaving that window open, switch back over to Firefox and Exit the browser, using either:
    * "3-bar" menu button > "power" button
    * File menu > Exit
    Pause while Firefox finishes its cleanup -- you will see the timestamps update in the profile folder, then rename '''places.sqlite''' to something like places.old and drop in the places.sqlite file you want to test.
    Start Firefox back up again. Bookmarks?

  • Firefox 3.6.12 is slow when loading pages and gets stuck in short busts after the last update to 3.6.12. Help.

    even when typing this, my cursor got stuck for a few seconds and then characters appeared

    It's been one thing after another with FF lately. Even when typing this post, the cursor gets stuck/characters do not appear. WTF?

  • My imac won't load properly and gets the spinning wheel for everything!? Help!

    HI everyone,
    hope hope someone will be able to help.
    My imac freezed up the other day for no apparent reason. I couldn't do anything apart from move the mouse. So had to shut dow with the power button.
    When it restarted I was able to log in as usual to the user that I normally use. Yet when I went to click on anything I get the spinning wheel of death! I've rebooted in safe mode but this didn't make a difference. I can't even run disk utility to check if there is an issue with the drive!
    Any help would be greatly appreciated!
    thanks charlotte

    Sounds like maybe the Hard Drive is failing or has failed.
    1. Start from your Mac OS X Install disc: Insert the installation disc, then restart the computer while holding the C key.
    2. When your computer finishes starting up from the disc, choose Disk Utility from the Installer menu. (In Mac OS X 10.4 or later, you must select your language first.) 
Important: Do not click Continue in the first screen of the Installer. If you do, you must restart from the disc again to access Disk Utility.
    3. Click the First Aid tab.
    4. Click the disclosure triangle to the left of the hard drive icon to display the names of your hard disk volumes and partitions.
    5. Select your Mac OS X volume.
    6. Click Repair. Disk Utility checks and repairs the disk.
    If you can not see the Mac OS X volume (Macintosh HD) in Disk Utility while started up form the Install Disc, then you will need to make an appointment at your local Apple Store or AASP and have them help.
    If you have a good backup in place, then you can easily restore the new Hard Drive from backup. If not, then depending on what is wrong, you may or may not be able to recover your user data from a bad Hard Drive.

  • Can't Access MovieClips and Functions in Loaded SWF

    Hi everybody,
    I'm trying to simply access anything inside this loaded SWF and all I get is 'null'.
    I have code in the parent SWF that needs to tell the child SWF movieclip what to do but nothing works. This was a piee of cake in AS2 and I can't seem to get anything to crossover in AS3.
    Here's 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 the clips loaded within pull up undefined property errors.
    Can somebody please tell me what I'm doing wrong? I'd be stoked to know what I'm missing and feel like this should be a piece of cake.
    Thanks for any help!

    You are not adding the content to the stage at 0,0, you are adding it to panel2 at 0,0.  THen you take panel2 and assign it to be something that likely doesn't exist by the time you assign it.  You need to wait until the loader completes loading before you attempt to do anything with its content, otherwise it has no content (null).  Similarly, you cannot control anything in the loaded swf until it has finished loading.  So assign an event listener to the contentLoaderInfo property of the Loader to determine when loading is complete, and have the event handler function deal with starting the interaction 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 loaded swf here
        // but you don't want to be assigning it to the panel2 object that contains the loader
    As far as controlling anything inside the swf you load, is it an AS1/2 or an AS3 swf?

  • Loading External SWF and setting variables

    Hello Everyone.
    I'm sure you are all a where of the FlashVars attribute for
    Flash embeds which holds variables for SWF's when they are
    rendered. I'm attempting to load an External SWF dynamically
    from within my own SWF and need to provide it with the values
    normally stored in the FlashVars. For the example below I
    wait until the External SWF is completely loaded using the
    onLoadInit event from moviecliploader and then i attempt to
    set the required variables that the loaded SWF needs. This works
    great in test and debug mode (ie. Test Movie and Debug Movie
    from the Control menu), but when i publish my FLA to SWF and run
    the SWF the variables will NOT get set in the loaded External SWF.
    From my readings ive people have mentioned that the player is only
    able to access Methods of an External SWF. If this is the case then
    how do they expect people to set the FlashVars of dynamically
    loaded SWFs? I investigated the loadVariables procedure as well and
    had the same results in test mode and was wasn't reliable because
    of timing issues.
    The sample source is below... if anyone has any ideas or has
    come across this issue before, I would really appreciate some
    insight.
    Thank you in advance for your time.
    var loader_mc:MovieClipLoader = new MovieClipLoader();
    var mclListener:Object = new Object();
    loader_mc.addListener(mclListener);
    mclListener.onLoadProgress = function(target_mc:MovieClip,
    numBytesLoaded:Number, numBytesTotal:Number) {
    // DO NOTHING
    mclListener.onLoadComplete = function(target_mc:MovieClip) {
    // DO NOTHING
    mclListener.onLoadInit = function(target_mc:MovieClip) {
    // WORKS IN TEST MODE NOT IN PUBLISH/SWF MODE
    target_mc._root.param1 = "value1";
    // WORKS IN TEST MODE NOT IN PUBLISH/SWF MODE
    _level0.container_mc.param1 = "value1";
    this.createEmptyMovieClip("container_mc",
    this.getNextHighestDepth());
    container_mc._lockroot = true;
    loader_mc.loadClip("somecoolflash.swf", container_mc);

    I've tried that as well and it behaves the same as onLoadInit
    ... Works when i test but doesnt when i publish to a swf. I think
    this is security related and the flash player just cant write to a
    loaded swf and set variables.

  • TS1424 has anyone not been able to get the installer to properly load and get a message like: This installer is intended for 32 bit versions of windows. Please download and install 64 bit iTuines installer instead? and even if you uninstall and reinstall

    Has anyone not been able to get the iTunes installer to load properly and get a message like this: This iTunes installer is intended for 32 bit versions of windows. Please download and install 64 bit iTunes installer instead. I have tried repeatedly to get this to load, I have uninstalled iTunes completely and reinstalled and still get the same message. I have windows XP and a brand new ipod touch which I am trying to load.

    Yes, it's come up a number of times. If you look to the right under "more like this", you'll find threads that may offer useful suggestions.
    Regards.

  • Using embeded fonts in loaded swf.

    I have a .Swf, which has 3 fonts embedded in it, they are all exported in frame 1 for AS.  This swf loads any number of external .swfs which have dynamically generated textfields inside of them.  This text must be embedded text because effects may be applied to them.  I do not want to embed the three fonts into every external swf, and do not think I should have to.  The font exists in the Loading swf and I have registered the fonts to the global font list.  If I print this list from the loaded swf, all three fonts are present, but when I try to use any of them, my textfiels are empty.
    My question is how do I utilize a font which is embedded in a swf, from a swf which has been loaded into that swf?
    From my external swf, this code:
    [PHP]var embeddedFonts:Array = Font.enumerateFonts(false);
    embeddedFonts.sortOn("fontName", Array.CASEINSENSITIVE);
    trace(embeddedFonts);[/PHP]
    produces the following:
    [PHP][object CenturyBook],[object MyriadProRegular],[object MyriadProItalic][/PHP]
    which are the three fonts that are embedded in the loading swf, So I assume the LOADED swf has access to these fonts.
    When I apply this code to the externally loaded swf:
    [PHP]var FontClass:Class = getDefinitionByName("MyriadProRegular") as Class;
    trace("FontClassInstance -> " + FontClass.toString());
    var linkedFont: Font = new FontClass();
    trace("Font name: " + linkedFont.fontName);
    var textFormat: TextFormat = new TextFormat(linkedFont.fontName, 14);
    //... The next lines set up the text box and apply the format.  I am sure this is done correctly.
    [/PHP]
    I get the following output:
    [PHP]FontClassInstance -> [class MyriadProRegular]
    Font name: Myriad Pro[/PHP]
    which is exactly what I would expect.  Yet, my text box is still blank.  I have embedText = true on the text box, and have applied a string to the "text" property, so it's nothing silly liek that.
    Any help would be appreciated...

    You may also want to look at the various embedded font format issues. Many of the Flex 4 components use a newer embedded font fortmat, which is not the same as the one generally used in Flash. So even if ther Flash font gets registered properly, it still may not work with some of the spark components.
    You should be able to create a swf using Flex that contains fonts embedded in either format, which can then be used in the way you describe, though, since Flex 4 suports both font formats.
    Hopefully, someone else will jump in here if I got some of this wrong.
    -JM

  • Loaded swf does not recognize stage of parent correctly

    I have an issue that is probably easily solved, but my attempts to solve it have been frivolous. 
    I am creating a “lightbox” to display artwork, but I have come across a slight hiccup.
    I am executing the lightbox functionality from a swf file that is loaded by a parent swf.  For testing purposes, when the lightbox button is clicked, the image should fill the entire stage.  Even though both the loaded swf and the parent swf recognize the same stage dimensions at all times(validated through tracing statements) and the lightbox image is positioned to the top/left corner of the stage, the image instead aligns to the top/left corner of the loaded swf.  And if the stage is resized after the lightbox image is displayed, the container MC (which is located in the parent swf and centers all the site’s content) re-aligns to the top/left corner of the stage . 
    To better illustrate these points, click the link below to see some screenshots with captions:
    http://newsite.katech.com/assets/images/lightbox_screenshots.jpg
    Also, here is the code applicable code from the loaded swf:
    stop();
    picture.visible = false;
    picture.x = 0;
    picture.y = 0;
    picture.width = stage.stageWidth;
    picture.height = stage.stageHeight;
    lightboxBtn.buttonMode = true;
    trace("embedded swf says the stage is " + stage.stageWidth + " X " + stage.stageHeight);
    function onStageResize(event:Event):void
                    trace("embedded swf says the stage is " + stage.stageWidth + " X " + stage.stageHeight);
                    picture.x = 0;
                    picture.y = 0;
                    picture.width = stage.stageWidth;
                    picture.height = stage.stageHeight;
    stage.addEventListener(Event.RESIZE, onStageResize);
    function showImage(event:MouseEvent):void
                    picture.visible = true;
    lightboxBtn.addEventListener(MouseEvent.CLICK, showImage);
    And for the applicable code from the parent swf:
    stop();
    trace("MAIN swf says the stage is " + stage.stageWidth + " X " + stage.stageHeight);
    //aligns site content to center of stage
    function onStageResize(event:Event):void
                    trace("MAIN swf says the stage is " + stage.stageWidth + " X " + stage.stageHeight);
                    container.x = (stage.stageWidth/2) - (container.width/2);
                    container.y = (stage.stageHeight/2) - (container.height/2);
                    if (container.x < 0)
                                    container.x = 0;
                    if (container.y < 0)
                                    container.y = 0;
    stage.addEventListener(Event.RESIZE, onStageResize);
    How can I get the loaded swf to display the lightbox image correctly in respect to the parent swf?  What am I doing wrong?

    I have still yet to resolve this issue on my own, if anyone could point me in the right direction, it would be greatly appreciated.
    Also, when I updated my previous post something "screwy" happened with the edit, so I went back and corrected the mistakes in case it made things unclear.
    Thanks.

  • How to clear grey loading screen and animated gif (Dynamic Action with "Show Processing" on submit)

    APEX V4.2.3
    DB 11.2
    I have a classic report on page 1.  I have a region button called "Export" (defined by a submit dynamic action with "show processing=Yes") that submits the page and then via a branch directs me to page 2 which has a slightly different version of the report on page 1 (i.e. no breaks) which I want to capture as a CSV export.  Therefore I've set the report template on page 2 to " Export:CSV".
    Now when I click on the page 1 export button the grey screen and loading gif appears indicating that the report is executing and then as expected, page 2 doesn't appear but instead the standard open/save window's dialog box appears asking to open or save the generated CSV file.  All good..but the grey loading screen remains.  How do I clear this loading screen and get back to the context of page 1 ?
    thanks in advance
    PaulP

    Hi PPlatt,
    We would love to help but you left out one crucial part of the puzzle: namely how does your CSV report get exported. With the way it is setup (a redirect to another page), I'm going to assume you do that because you have some PL/SQL on that page that prints the CSV.
    Now there are two questions that are crucial here:
    - How do we stop the icon from bugging us on the screen
    - How do we communicate with the browser that it should no longer display the loading icon
    The first question is rather easy, two simply lines of codes can do that:
    $('#apex_wait_popup').hide();
    $('#apex_wait_overlay').hide();
    But when do we use this code? Quite simple when the document is downloaded. When is it downloaded? At the end of the PL/SQL code that prints the document to the browser.
    What you could do is at the end of that code give an application item a certain value. For example :AI_PRINTED := 'Y';
    Then all you need to do is let the browser ask for the value. You could do this by using JavaScript to continuously fire AJAX to the server using a JS timing event:
    http://www.w3schools.com/js/js_timing.asp
    Better would be a Server send event, but since you left out another crucial piece of information: your browser, I will not go deeper into this.
    Start this timing event when someone asks for the document, and end it as soon as the process returns that :AI_PRINTED equals 'Y'.
    Despite the lack of information, I hope I have given, or at least inspired you to get to the solution.
    Regards,
    Joni

  • Controlling a Movie Clip on the Main Timeline from a loaded SWF?

    Is it possible to control a MovieClip on the main timelne from another loaded clip?
    I see posts that control loaded clips, but most are all from the loader in the main timeline.  I have a moviclip on the main timeline that I want to make visible or invisible depending on what keyframe is playing in another loaded swf.
    If I try to call the movieClip from the loaded SWF I get "error #1119.  Access of possibly undefined property...." because it doesn't exist in the loaded SWF, just the main timeline. 
    The old AS2 way just used "_root".  Since "_root" doesn't exist any more, how do you control items on the main TimeLine from a loaded SWF?

    I am not clear what you mean because you are saying you are trying to target a movieclip that does not exist where you are trying to target it.
    Try using a trace to see what you are targeting when you you target the MovieClip(parent.parent)....
    trace(MovieClip(parent.parent));
    The other approach I mentioned earlier is the more OOP-correct approach if you would rather try that way.  Here's a rough outline of it...
    AS3 - Dispatch Event
    http://forums.adobe.com/thread/470135?tstart=120
    Example:
    Add something to trigger the event in the child (your loaded swf):
    dispatchEvent(new Event("eventTriggered")); (
    if dispatchEvent problem, see: http://www.kirupa.com/forum/showthread.php?p=1899603#post1899603)
    In your loading/parent swf, listen for the complete event on the Loader.contentLoaderInfo.  In the complete event handler, add a listener for the event on the loaded swf.
    // event handler triggered when external swf is loaded
    function loaderCompleteHandler(event:Event) {
        MovieClip(event.currentTarget.content).addEventListener("eventTriggered", eventHandler);
    function eventHandler(event:Event):void {
        trace("event dispatched in loaded swf");
       // this is where your main file can set the visible property of your movieclip

  • Dynamic Text in Externally Loaded swf

    hi. i have a dynamic text field in an externally loaded swf. Its a digital clock so i want the numbers to update in the dynamic text field.
    this is not my exact code but it is very similar. i show below that i add the loader.swf, and once its loading is complete, i can work on its movieclips and add event listeners to its buttons, etc. but i cannot change the dynamic text field (its "classic text" set to "dynamic text"). after running this, the text just stays empty as it is in the external swf).
    here is the sample code:
    var loader:Loader = new Loader();
    loader.load(new URLRequest("loader.swf"));
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaded);
    function loaded(event:Event):void{
         addChild(loader);
         var loader_mc:MovieClip = (loader.content as MovieClip)
         loader_mc.myMovieClip.gotoAndStop(2);//***this works
         loader_mc.myButton_btn.addEventListener(MouseEvent.CLICK, clickMe);//***this works
         loader_mc.myText_txt.text = "12";//***this doesn't work******
    please help. thanks!

    Did you embed the font in the textfield--it needs to be done in the loaded swf when you create it? One other thing to check is that the color for the textfield is not the same as the background it sits on.

Maybe you are looking for

  • [OSB10.3.1] err creating JMS stuff in OSB cluster from recorded WLS session

    Hi all, I've setup an OSB cluster with 2 managed servers. From WLS console I created successfully the below JMS resources: 1. new file store, name and directory: MyFileStore_m01, target: bnk01osbm01 migratable 2. new file store, name and directory: M

  • Lotus notes as a front end and oracle as backend

    Dear All, Can i use lotus notes as a front end and oracle as backend atleast for few forms in my application. If Yes how to go about it. I have not tried it even once Kindly also advice if this is appropriate forum to ask this question Best Regards,

  • Can't Install Photoshop CS2 Correctly

    I recently installed Photoshop CS2 on my Windows XP (SP2) computer. It installed fine about a year ago, but I got a virus and had to format my drive to get rid of it a few months ago. I tried to reinstall my software today, opened it, clicked the reg

  • Parent Child heirarchies in OBIEE11g

    Hello Experts I have got a requirement from the client that they need to have multiple version of Parent child heirarchies coming out from a particulat dimension. To elaborate furthet say suppose there is a dinemsion called Profit Center where we nee

  • Php / mysql  replace non-ascii character in a string

    I have a script that converts a ms word document to text then uploads that to a blob field on a mysql db. During the conversion some characters my not be recognised. When i then call up the blob for display on the browser...those characters show up a