External swf loading help please!

Hi, Im trying to load an external swf on even an object in the main swf file, I'm using this code, but I get an error, please help if you can:

bg.farm.addEventListener (MouseEvent.MOUSE_DOWN, farm_Press);

var fl_Loader:Loader;

function farm_Press(evt:MouseEvent):void

{

bg.farm.removeEventListener (MouseEvent.MOUSE_OVER, farm_Over);

bg.farm.removeEventListener (MouseEvent.MOUSE_OUT, farm_OUT);

bg.farm.removeEventListener (MouseEvent.MOUSE_DOWN, farm_Press);

removeChild (bg);

fl_Loader = new Loader();

fl_Loader.load (new URLRequest ("farmSWF.swf"));

bg.addChild (fl_Loader);

fl_Loader.width = Capabilities.screenResolutionX;

fl_Loader.height = Capabilities.screenResolutionY;

}

error-

TypeError: Error #1009: cannot access a property or method of a null object reference.

to Project2_fla::MainTimeline/frame1()

THX pavel

ferrisID.content, that's how you référenceriez the root of your loaded swf file

also: you cannot close a swf file loaded, you simply to delete the instance of the stage charger

Tags: Adobe Animate

Similar Questions

  • External SWF load on buttons

    Hi all..

    I am loading a SWF file outside on click of a button, however, when the external SWF file loads, it covers the buttons... Can someone help me please on how I can keep the buttons on the top? I even tried the external SWF to load in a clip and place the buttons on a layer above - and it does not work... Any help would be great appreciated. Thank you advance!

    Here is my code:

    Table external to use staples. Variable index refers to the next clip is displayed.
    var clip: Array = ["page1.swf", "page2.swf", "page3.swf"];
    var int index = 0;

    Stuff to load swf files
    var thisLoader:Loader = new Loader();
    thisLoader.contentLoaderInfo.addEventListener (Event.INIT, doneLoading);

    var thisMC:MovieClip = new MovieClip();
    stage.addChild (thisMC);            Add MC initially empty so that the nextClip function can be generic

    Removes the old MC and gets the following, waiting until what, when it booted transfer, adding to the scene
    function nextClip (): void {}
    thisLoader.load (new URLRequest (clips [index]));
    }

    AS of Tell the loaded file is a video clip and add it to the stage.
    function doneLoading(e:Event):void {}
    stage.removeChild (thisMC);
    thisMC = MovieClip (thisLoader.content);
    thisLoader.unload ();
    stage.addChild (thisMC);
    thisMC.play ();
    }


    'Next button' just calls a function that indicates the file name following (mod the number of files in the list)

    bttn1_mc.addEventListener (MouseEvent.CLICK, playNext);

    function playNext(e:MouseEvent):void {}
    nextClip();
    index = (index + 1)%(clips.length);
    }

    stage.addChild (bttn1_mc);
    bttn1_mc. Visible = true;

    You are welcome.

    Please mark this thread as answered.

  • His control of an external SWF PLS HELP!

    Hi all

    I'm trynig to control an external SWF sound but I can't seem to do things, I am kind again have you and would really apreciate any HELP given!

    Here is the code I use to import the sound

    mport flash.media.Sound;
    import flash.net.URLRequest;
    import flash.display.Sprite;
    import flash.media.SoundChannel;
    import flash.events.Event;
    import flash.events.MouseEvent;

    var _som1:Sound;
    var _channel1:SoundChannel;
    var _playing1:Boolean = false;
    var _position1:int;

    _som1 = new Sound( new URLRequest ( "som1.mp3"));
    _channel1 = _som1.play();


    /*
    //this controls the sound inside the SWF
    //this code has to be on the main SWF
    _play.addEventListener(MouseEvent.CLICK, playSound);
    _pause.addEventListener(MouseEvent.CLICK, pauseSound);

    function playSound(event:MouseEvent):void {
        _channel1 = _som1.play(_position1);
    }

    function pauseSound(event:MouseEvent):void {
        _position1 = _channel1.position;
        _channel1.stop();
    }
    */

    My main SWF call an internally within a clip, here is the code, if this can help somehow...

    var loadAnimBox:Loader = new Loader();
    var vid_mc:MovieClip;

    function startLoading():void {
        loadAnimBox.contentLoaderInfo.addEventListener(Event.COMPLETE, onBoxLoaded);
        // load the box animation SWF
        loadAnimBox.load(new URLRequest((meuCaminho.parameters.var3) + ".swf"));
    }

    function onBoxLoaded(e:Event):void {
        loadAnimBox.contentLoaderInfo.removeEventListener(Event.COMPLETE, onBoxLoaded);

        vid_mc = loadAnimBox.content as MovieClip;
        // We listen for that event:
        vid_mc.addEventListener("firstAnimationComplete", onFirstComplete, false, 0, true);   
        addChild(vid_mc);
       
        // set up the play button
        play_btn.addEventListener(MouseEvent.CLICK, playClick);   
        stop_btn.addEventListener(MouseEvent.CLICK, stopClick);

    }

    function onFirstComplete(e:Event):void {
        // we should remove the listener if we're not going to play this again
        trace("First animationn complete, start second animation.");
    }

    function playClick(e:MouseEvent):void {
        vid_mc.play();
    }
    function stopClick(e:MouseEvent):void {
        vid_mc.stop();
    }

    Thanks for the attention... best regards!

    When your external swf:

    var alreadyStarted:Boolean

    if(!alreadyStarted){alreadyStarted=true;_som1 = new Sound( new URLRequest ( "som1.mp3"));_channel1 = _som1.play();}
    
    and in your main swf use the two functions in suggested to play and pause your sound.
    
  • Incompatible extern SWF loaded class with tree

    Hello

    I created a method to load certain classes of extern SWF (as descripted it).

    I can use the classes in theses for the source of the image.

    I have this bug when I used them for a tree of the icon.

    The problem is in the TreeItemRenderer 389 line.

    var iconClass:Class = _listData.icon;

    I don't understand the problem because my class CNodeRelais class type and iconClass is a type too...

    I really need help . Thanks in advance.

    TypeError: Error #1034: the type constraint failure *: conversion of CNodeRelais@10c95421 into mx.core.IFlexDisplayObject impossible.
    to mx.controls.treeClasses::TreeItemRenderer/commitProperties() [E:\dev\4.0.0\frameworks\proj ects\framework\src\mx\controls\treeClasses\TreeItemRenderer.as:389]
    at mx.core::UIComponent/validateProperties() [E:\dev\4.0.0\frameworks\projects\framework\src\ mx\core\UIComponent.as:7772]
    at mx.managers::LayoutManager/validateClient() [E:\dev\4.0.0\frameworks\projects\framework\sr c\mx\managers\LayoutManager.as:863]
    to mx.controls::List / http://www.Adobe.com/2006/Flex/MX/internal:setupRendererFromData ([E:\dev\4.0.0\framework s\projects\framework\src\mx\controls\List.as:1706])
    at mx.controls::List/commitProperties() [E:\dev\4.0.0\frameworks\projects\framework\src\mx\co ntrols\List.as:895]
    at mx.controls::Tree/commitProperties() [E:\dev\4.0.0\frameworks\projects\framework\src\mx\co ntrols\Tree.as:1189]
    at mx.core::UIComponent/validateProperties() [E:\dev\4.0.0\frameworks\projects\framework\src\ mx\core\UIComponent.as:7772]
    at mx.managers::LayoutManager/validateProperties() [E:\dev\4.0.0\frameworks\projects\framewor k\src\mx\managers\LayoutManager.as:572]
    at mx.managers::LayoutManager/doPhasedInstantiation() [E:\dev\4.0.0\frameworks\projects\frame work\src\mx\managers\LayoutManager.as:730]
    at mx.managers::LayoutManager/doPhasedInstantiationCallback() [E:\dev\4.0.0\frameworks\projec ts\framework\src\mx\managers\LayoutManager.as:1072]

    You can't make a class implements an interface when running, so there is no

    way to change the interfaces of a dynamically loaded class.

  • Swf loader help

    Hello all, I use Flash CS4 with AS3.


    I have a problem with the preloader site. When I simulate the load it is 'invisible' for awhile and then appear from loading of ~ 24-27% or perhaps ~ 55%
    To resolve this problem some people suggested to create a loader.swf (where you want to preload) and the site.swf: when the loader.swf have loaded the site.swf then it appear.


    Well, I tried this with the following code:

    var file:Loader=new Loader();
    var: path string.
    load.bar.scaleX = 0;

    run the preLoader (event: Event): void {}
    If (file.contentLoaderInfo.bytesTotal! = 0)
    {
    load.bar.scaleX = (file.contentLoaderInfo.bytesLoaded / file.contentLoaderInfo.bytesTotal);
    Load.txt_perc. Text = String (Math.round ((file.contentLoaderInfo.bytesLoaded/file.contentLoad erInfo.bytesTotal)*100))+"%";))
    }
    trace (file.contentLoaderInfo.bytesLoaded);
    }

    function stopLoader (event: Event): void {}
    trace ("Downloaded");
    file.removeEventListener (Event.ENTER_FRAME, preLoader);
    load.bar.scaleX = 0;
    Load.txt_perc. Text ="";
    }

    file.contentLoaderInfo.addEventListener (Event.COMPLETE, stopLoader);

    function loadMovie (): void {}
    load.bar.scaleX = 0;
    var swf:URLRequest = new URLRequest (path);
    leader. Load (SWF);
    file.addEventListener (Event.ENTER_FRAME, preLoader);
    stage.addChild (file);
    }

    function path1(e:Event):void {}
    path = "example.swf";
    loadMovie();
    }

    stage.addEventListener (Event.ENTER_FRAME, path1);


    But he returns this error:

    #2044 error: Unhandled IOErrorEvent:. Text = #2036 Error: incomplete loading.


    Someone told me that this error is due to the impossibility to find the URL of the swf file, but this is false since the swf file is finished.

    If I look at the load simulation I see multiple copies of the swf file are "loaded", but nobody is 100%.

    However, I said "responsible" because if I put a trace (file.contentLoaderInfo.bytesLoaded); I see a 0 permanent.


    Please help me I'm going crazy!

    where did,

    removeChild (file);

    come from?   which removes your swf loaded from the display list.  remove this line of code.

  • How to control an external SWF loaded with actionscript

    It is a question of both parties, and I'm pretty new to Flash. I'm working on a flash animation and the interface is a small town (simiar to "doritos.com" and "comcasttown.com"), if you are referencing the doritos comcast sites and their little movie gently. I have several items in the city. For example, one of the elements is an airplane hanger. When you reverse the hanger, I created a movie, the doors open and a plane flies out of the hangar. I have several small films throughout the interactive like this. I created the hangar as a separate swf file animation. In my main movie, I created a button bearing, it loads the SWF hangar in an empty movieclip. When I publish and display the swf file, it plays slow and jerky. First of all, is it possible to write an actionscript to load external swf file, but it will stop on the first frame of the animation, and when you the reversal, he continues to play.  To put all this in a Word, I want to create several buttons throughout the movie with loadmovie functions, once loaded swf movies I want to that they stop on the first frame of the animation and when you charge rolling video swf I want to continue to play the animation. ActionScript should be applied for swf movies first and preloaded in the main movie. And what will make the movies smoothly once he published and displayed in a browser.  Also, if that makes a difference, I created animations in sequels, exported as imported into flash FLVs and exported to the swf. Again, it works really slow and jerky. I'm taking the right approach?  I know it's a lot of information, but any help would be greatly appreciated. Here is the script I used for the button.


    on (rollover) {loadMovie ("movies/solarpanel.swf", "solarload");


    Thank you

    1. export a SWF of sequels.

    2. Add a stop() on the first frame of your SWF so they don't start playing while they are loading.

    3. apply mouse on your target movieclips managers and using the play() method to start your SWF play when postponed:

    {target1mc.onRollOver = Function ()}

    This.Play ();

    }

    and if you want them to stop when roll-out:

    {target1mc.onRollOut = Function ()}

    This.Stop ();

    }

  • Using the DateField in an external SWF loaded

    Hello

    I had major trouble trying to get a PHP contact form basis to work within an external SWF file loaded within a parent SWF. When I test the movie on its own it seems to work fine (example: I am able to select a date in the DateField component). However, when I open the SWF file parent and call the external SWF file with the DateField shape is essentially unusable (example: when you click on it nothing happens, no calendar is displayed to select a date).

    I have no ActionScript on it yet, simply because I tell myself that I need to work before I tell him what to do with the PHP file. The name of the instance on the DateField is 'survive. ' Any help is appreciated. Thank you.

    Also, I used successfully the contact form on the web. But, UI components only that I am able to edit the input text boxes, not the DateField or ComboBox I have in there as well. It is very strange, I was not aware that he had to do something special with the help of these user interface components in an external file.

    Elijah

    Hey 2 m.

    In fact, I found a post on this forum who answered the way back in February in kglad. The answer to my problem was simply place the following code on the layer actions where my components have been posted:

    This ._lockroot = 1;

    That's all. Thank you at least 2 m.

    Elijah

  • Control external SWF loaded in MovieClips

    Draw the hair a little bit today, with something that seems so easy. I have a main scenario with two empty clips (originalMC, newMC). I'm loading external swf (original.swf, new.swf) in them. Sovereign wealth funds are in the same folder as the main file. They load very well and my EventListeners trigger functions as expected.

    I need the ability to stop reading the swf external when they load, but everything I've tried to create errors or simply fails. What I have to add to the functions (stopNew and stopOriginal) to prevent them from playing? Code below. Thank you.

    Chargers for newMC and originalMC

    var loader: Loader = new Loader();

    loader.contentLoaderInfo.addEventListener (Event.COMPLETE, stopOriginal);

    Loader.Load (new URLRequest ("original.swf"));

    originalMC.addChild (loader);

    var loader2:Loader = new Loader();

    loader2.contentLoaderInfo.addEventListener (Event.Complete, stopNew);

    loader2. Load (new URLRequest ("new.swf"));

    newMC.addChild (loader2);

    function stopNew(e:Event):void {}

    trace ("new load");

    Track works on export, so the function is called correctly

    I would like this feature to stop the chronology of 'newMC '.

    }

    function stopOriginal(e:Event):void {}

    trace ("loaded original");

    Track works on export, so the function is called correctly

    I would like this feature to stop «originalMC» chronology

    }

    Your intentions seem to be off target if you want to stop the maturities of the two elements call you newMC and originalMC.   These two objects will not be the objects that are loaded.  To stop the timelines of the new.swf and the original.swf files you load, you would use something like...

    function stopNew(e:Event):void {}

    var newSWF:MovieClip = e.target.content;

    newSWF.stop ();

    }

    function stopOriginal(e:Event):void {}

    var originalSWF:MovieClip = e.target.content;

    originalSWF.stop ();

    }

    Assuming that you want to target these movies outside of these functions, you would report the variables outside the function instead of as shown inside.

  • CS6 - fonts embedded in external swf loaded--lack of characters

    I created a SWF with some embedded fonts, and nothing else. I put all the fonts to export for Actionscript. When I load the external police, I call Font.registerFont () on each of the classes of this SWF fonts. The fonts work, but several characters are missing from the police.

    However, if I incorporate the same fonts in the main swf file that has the textfields instead of their loading from an external swf, all characters appear as expected.

    The alternative is for me to integrate several fonts in several other SWFs to be redundant.

    This seems to be a serious bug in Flash. I like it if it's not, and I'm doing something wrong. Adobe, are you listening?

    That's why I approach to code for 98% of all projects. My TextFields are that all formatted using the TextFormat class. I embed or load a SWC with the fonts in the main project and whatever other charges have use fonts that I loaded only once in the main application.

    Consider that there are also Runtime shared as an option for you. This is where you mark all your fonts in a Font.FLA export as shared runtime. Then just create the same fonts in your other parts of the user interface, but to import from the file shared time. Then you can work on the separate user interface components while still seeing the correct font.

    System code page simply means that if I'm on an English Windows copy then which will be the language that Flash considers most important. If I try to embed Arial and then programmatically create and populate a TextField with Chinese, it won't work, nothing will be displayed. Even though I explicitly tell Flash to include Chinese glyphs (which certainly exist in Arial). Because I can not specify the unicode range I need and force it as Flash Builder, Flash "magically internally" decide everything I need is English (latin) glyphs and wouldn't integrate the Chinese glyphs. This magical behavior was always a pain.

  • 'Detect' a variable from an external SWF loaded via SWFLoader

    I load an external SWF file to a click event.  Then, when interactions has reached the end of the presentation, we would like what he offload and go into another State.

    Is this possible?  (actually turned the SWF into a component using Flash Builder 4 in the hope that it would be easier to detect variables and events)

    Thank you

    Doug

    It is possible, but you will have to wire upward communications between the

    Sovereign wealth funds

  • external SWF loading is not synchronized?

    Hello

    When I load an external SWF into my flash animation, the video is late. No idea why?
    Everything's fine when that SWF movie plays on his own.
    Thank you
    Dave

    I would just use flv. Just read on loadMovie and flvs here. In the swf file that loads the flv file, you must use the path of the html page to the flv file.

  • Color external swf loaded in AS3 urgent help!

    Hi I loaded swf to the external path by using the following command.

    var cviewer:Loader = new Loader();

    var curlRequest:URLRequest = new URLRequest("clipArts/"+evt.target.name);

    Therefore, the scenario.

    Let's say I have load Movie1.swf

    I have three video clips inside Movie1.swf called step0, step 1, step 2

    I need to change the color of step0, step 1 and step 2 of the parent flash file that loads Film1. The color of internal movie clips may be different from each other.

    I am able to change the color of the entire music video using

    var colorInfo:ColorTransform = cviewer.transform.colorTransform;

    colorInfo.color = evt.target.selectedColor;

    cviewer.transform.colorTransform = colorInfo;

    But not the individual. I even tried cviewer.step0.transform.colortransform and other things to see if it would work. But nothing has worked. Fast help would be much appreciated.

    Regards and thanks in advance.

    Try:

    var colorInfo:ColorTransform is MovieClip (cviewer.content).step0.transform.colorTransform;.

    colorInfo.color = evt.target.selectedColor;

    MovieClip (cviewer.content).step0.transform.colorTransform = colorInfo;

  • AS3 pass variable values of external swf loaded in the parent swf format

    Hello

    I'm working on an e-Learning project that uses a main SWF (SWF1) and a second SWF (SWF2) with 2 quizzes in it. Published in the ATMOSPHERE for Desktop and Android, SWF1 and SWF2 are packed together in the Office of AIR or AIR APK exports.

    I use a charger in SWF1 to compose and execute SWF2. What I am having difficulties with, need help, is how to get 2 2 SWF2 quiz scores and load these values (each is a number) return SWF1. Once back in SWF1, they will be written to a string and then displayed in a text box using textbox.text.

    While I searched online and found examples to send variables from parent to child of the SWF file, so far not able to find an example of script understandable/useable AS3 to get variables from child to parent SWF.

    Any help appreciated.

    Best wishes

    The best way to communicate between parent and child SWFs is through events. Send an event to the child with the data to send and intercept the event to the parent level. This flow is common and very easy to handle

  • Transfer the virtual machine from the external drive - URGENT HELP PLEASE

    I recently transferred my Virtual Machine to a hard drive external that I had to reinstall my OS Leopard, now when I try to copy the VM back to my mac from the external hard drive, to halfway through I have error message... "You cannot copy"Windows Vista.vmwarevm"because it has the same name as another article on volume of destination, and that the volume is not making the distinction between upper and lower case in file names."

    Virtual machine worked well for the external hard drive, but it's not convenient for me and I need ideally on my laptop... Please notify.

    To this folder on the Mac you copy it and what else is in this folder when copy you it.  I hope also merger is closed when you try to copy.

    Another thing you can do is inside the packaging of the Virtual Machine, there are two folders, Applications, and appListCache, I always delete before copy/move and these will be recreated and the reason why I do it, it is I saw copy fail until they have been deleted, although generally, it is one of the app in the Applications folder with the module of Virtual Machine that caused the problem.

    VMware Fusion (menu bar) > help > Search > type Package and then select work with Virtual Machine packages

  • AS3 communication with external swf loaded in mc

    Hi all

    Thanks for posting first

    My problem is this, I have a blank swf file that loads a swf into a clip called content_mc here is the code located in the blank swf file

    startLoad ("home page")

    var loadedSWF:Loader

    var content_mc:MovieClip = new MovieClip();

    function startLoad (SWFname:String) {}

    loadedSWF = new Loader ();

    loadedSWF.load (new URLRequest (nomswf + ".swf"));

    content_mc. AddChild (loadedSWF);

    function nextSWF (whichSWFName, removeSWF) {}

    content_mc.removeChild (removeSWF);

    If whichSWFName == 'start page') {}

    startLoad ("pre-loader");

    }

    }

    so this basically puts everything up now on the button of the swf file loaded on the outside I

    btn.next.addEventListener (MouseEvent.CLICK, nextpls);

    function nextpls (event: MouseEvent) {}

    MovieClip (parent.parent) .nextSWF ("home page", parent);

    }

    OK to explain if I remove the content_mc of the first part of the code that everything will work as it should

    the problem is that I need to load into this movieclip

    so I need to tell the MovieClip content_mc which its finished passing ("home page", parent) bit

    However I can't communicate with him

    I don't know if I did not have enough parents or if I need to say () and so on

    Maybe I need a reference or something ive read on those.

    currently learning AS3 and this part is a real headache

    any help is greatly appreciated

    Thank you

    fonzio1

    Should be more like this:

    Child ("home page")

    import flash.events.MouseEvent;
    import flash.display.MovieClip;
    
    btn.addEventListener(MouseEvent.CLICK, nextpls);
    
    function nextpls(e:MouseEvent):void {
        (parent.parent.parent as MovieClip).nextSWF("startPage", this);
    }
    

    Parent

    import flash.display.MovieClip;
    import flash.display.Loader;
    import flash.net.URLRequest;
    
    var content_mc:MovieClip = new MovieClip();
    addChild(content_mc);
    
    var loadedSWF:Loader;
    
    function startLoad(SWFName:String):void {
        loadedSWF = new Loader();
        loadedSWF.load(new URLRequest(SWFName+".swf"));
        content_mc.addChild(loadedSWF);
    }
    
    function nextSWF(whichSWFName, removeSWF){
        content_mc.removeChild(removeSWF.parent);
        if(whichSWFName == "startPage"){
            startLoad("pre-loader");
        }
    }
    
    startLoad("startPage");
    

    (Personally I use communication based instead of AS1 as "parent.parent" etc...)

Maybe you are looking for

  • My MacBook Air is a scanner in my printer?

    I am trying to add my printer (Canon MP230) to my MacBook, so I can print an assignnt. My MacBook Air is only picking up as a scanner. He worked as a printer before with the same MacBook however it just stopped and what is happening now... So I reset

  • Satellite P20-552: A second HDD can be added

    A second hard drive can be added to this laptop? What is the largest hard drive that will support this laptop?

  • Amplitude varying on the change of the input frequency

    Hello I using NOR-5752 scanner to measure the analog inputs of high frequency. NOR-5752 is connected to the module FLEX RIO 7966R and entry to the NOR-5752 is provided using the SMB-2145 terminal outlet box. Now, I'm the animals the 0.5Vpp @ differen

  • DAQmx trigger

    I'm relativley new to labview and I have a problem, try to configure the trigger with DAQmx Im am using NI 6210 to acquire data of probe of HAVE - what Im I'm wanting to do is aquire data whenever the proxistor is triggered since my digital input. So

  • HP Deskjet 1512: Cannot print from Microsoft word 2007

    Hello I recently bought a HP Deskjet 1512, it scans and copies without any problems, I am able to print images and files of e-mail, but it won't let me print anything from Microsoft Word (2007), I rebooted and reinstalled the software, I ran the hp d