Problem Loading a SWF

I want to load a SWF form another SWF and a have one error:
TypeError: Error #1009: Cannot access a property or method of
a null object reference.
at MoverBall$iinit()
Any help?
here is the actionscript code:
package {
import flash.display.*;
import flash.events.*;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import flash.geom.Point;
public class MoverBall extends MovieClip{
private var gameSprite:Sprite;
private var ball:Ball2;
private var xpos:Number = 0;
private var ypos:Number = 0;
private var zpos:Number = 0;
private var vx:Number = 0;
private var vy:Number = 0;
private var vz:Number = 0;
private var friction:Number = .95;
private var fl:Number = 250;
private var vpX:Number = stage.stageWidth / 2;
private var vpY:Number = stage.stageHeight / 2;
public function MoverBall(){
// INICIALIZAR SPRITE
gameSprite = new Sprite();
ball = new Ball2();
stage.addChild(gameSprite);
gameSprite.addChild(ball);
addEventListener(Event.ENTER_FRAME, onEnterFrame);
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
function onEnterFrame(event:Event):void{
xpos += vx;
ypos += vy;
zpos += vz;
vx *= friction;
vy *= friction;
vz *= friction;
if(zpos > -fl){
var scale:Number = fl / (fl + zpos);
ball.scaleX = ball.scaleY = scale;
ball.x = vpX + xpos * scale;
ball.y = vpY + ypos * scale;
ball.setCentro(new Point(ball.x+10, ball.y+10));
ball.visible = true;
else{
ball.visible = false;
function onKeyDown(event:KeyboardEvent):void{
switch(event.keyCode){
case Keyboard.UP :
vy -= 1;
break;
case Keyboard.DOWN :
vy += 1;
break;
case Keyboard.LEFT :
vx -= 1;
break;
case Keyboard.RIGHT :
vx += 1;
break;
case Keyboard.SHIFT :
vz += 1;
break;
case Keyboard.CONTROL :
vz -= 1;
break;
default :
break;
function getBall(){
return ball;
And the code in my FLA is:
// Request the content
var url:URLRequest = new URLRequest("Ball2.swf");
// Create a loader object
var loader:Loader = new Loader();
// Load the content
loader.load(url);
// Add loader into the Display List
addChild(loader);

here is the code of Ball2
package {
import flash.display.Sprite;
import flash.geom.Point;
import flash.display.*;
public class Ball2 extends MovieClip{
private var centro:Point;
private var aux:int;
public function Ball2(){
graphics.beginFill(0xff0000);
graphics.drawCircle(0,0,10);
graphics.endFill();
this.x=100;
this.y=100;
centro = new Point(this.x+10, this.y+10);
aux=1234;
public function getCentro(){
return centro;
public function getVar():int{
return aux;
public function setCentro(c:Point){
centro=c;
}

Similar Messages

  • Problems loading Flex3 swf into AIR app

    This is a challenging problem that I have reduced down to the
    bare minimum and it is still reproduceable. I have built a minimal
    AIR application and added a SWFLoader to it which loads a SWF file
    named "Junk.swf" using an absolute path.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:WindowedApplication xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute" title="Hello World">
    <mx:Style>
    WindowedApplication {
    background-color:"0x999999";
    background-alpha:"0.5";
    </mx:Style>
    <mx:SWFLoader
    source="C:/myProjectFolder/renderers/Junk.swf" width="100%"
    height="100%" />
    </mx:WindowedApplication>
    This works fine if I run the application from within Flex3,
    however when I build an installer, install the application to my
    windows vista system and execute it from the desktop the Junk.swf
    will not display. If I replace the Junk.swf with another SWF of the
    same name created in Flash CS3 then it will display properly when
    my test app is executed from either Flex or the desktop.
    The contents of the loaded SWF don't appear to be an issue
    since even the simplest of Flex3 SWFs fail to display.
    Interestingly when I add listeners to the SWFLoader to
    determine if any errors are happening no error events are sent, but
    I do receive both the INIT and COMPLETE events which tells me that
    the Junk.swf is found and loaded, just not displayed.
    Any assistance or even ideas that I could try would be
    appreciated.

    that's why i added those comments about the swf's domain.  for locally loaded swfs, use:
    SFMltd wrote:
    Hi Kglad, Thanks for the Example.
    if i run my class with securityDomain = SecurityDomain.currentDomain; then it throws this error: SecurityError: Error #2142: Security sandbox violation: local SWF files cannot use the LoaderContext.securityDomain property.
    The swf file im trying to load is stored locally so i guess this error makes sense. However if i comment out that line i get the same "cannot access Stage owned by app" error?
    See below for class:
    package  {
      import flash.display.MovieClip;
      import flash.filesystem.File;
      import flash.events.Event;
      import flash.net.FileReference;
      import flash.events.MouseEvent;
      import flash.display.Loader;
      import flash.net.URLRequest;
      import flash.system.LoaderContext;
      import flash.system.ApplicationDomain;
      import flash.system.SecurityDomain;
      public class assetPreview extends MovieClip {
      private var loader:Loader;
      private var mainSWF:MovieClip = new MovieClip();
      public function assetPreview() {
      addEventListener(Event.ADDED_TO_STAGE, initialise);
      public function initialise(e:Event):void
      removeEventListener(Event.ADDED_TO_STAGE, initialise);
      var allowSWF:LoaderContext = new LoaderContext(false,ApplicationDomain.currentDomain);
    // allowSWF.securityDomain = SecurityDomain.currentDomain;
      loader = new Loader();
      loader.load( new URLRequest(settingsXML.pathToSWF),allowSWF);
      loader.contentLoaderInfo.addEventListener(Event.COMPLETE, viewPreview);
      public function viewPreview(e:Event):void
      addChild(mainSWF);
      mainSWF.addChild(loader);

  • Problem loading one SWF into another in Flash AS3

    I am trying to load an SWF file in another SWF file. The child SWF file works fine when run standalone like if I set visibility of an item to true or false, it works fine. But when the SWF is loaded into a parent SWF, I am not able to execute such commands, neither I get any errors...

    are both swfs as3 swfs?
    is the code in the loaded swf and is that code referencing objects in the loaded swf?

  • Problem loading external swf's

    Hi
    I'm creating an application where the user uses the ARROW KEYS to navigate around the menus and SPACEBAR to continue.
    On the first screen is the main menu that launches external swf's. (I have it as an exe)
    When I play the external swfs individually in the Flash Player.......the navigation is perfect and runs smoothly.
    But when I launch the external swf's through the first screen (menu).....the loaded swf becomes very slow/sluggish to react when I hit the ARROW KEYS.
    (eg. have to hit the arrow key 3/4 times before it moves)
    The frame rate in each fla is the exact same.
    I use the levels to launch the external swf..............I have also used the "load into an empty movieclip" and the outcome is still the same.
    I'm using CS5.
    What could be the problem???
    Thanks for your help.

    In the 3 external swfs, I have in each around 10 scenes. In each scene I have 6 frames with a stop() command in each frame.
    On the selected button in each frame I have the following code: (using actionscript2)
    on (keyPress "<Up>") {
         gotoAndStop(3);
    on (keyPress "<Down>") {
         gotoAndStop(1);
    on (keyPress "<Space>") {
         gotoAndStop("scene02", "firstframeLabel");
    This code is consistant through the 10 scenes.
    On the menu swf; I have a menu system that launches the 3 external swf.
    One scene, using 3 frames with a stop() command in each frame.
    On the selected button in each frame I have the following code: (using actionscript2)
    on (keyPress "<Up>") {
         gotoAndStop(3);
    on (keyPress "<Down>") {
         gotoAndStop(1);
    on (keyPress "<Space>") {
        loadMovie ("application01.swf", 30);

  • Problem in loading secondary swf

    Hi,
    I am trying load a font as swf for IOS application.i tried load to it from both application directory and application storage directory.but it always throws the following error.
    Fast debuging mode everything works fine.
    Air Sdk 3.8
    Flash Builder 4.7
    swf version 20
    Error 3747: Multiple application domains are not supported on the operating system.
    Code i used to load the swf.
    var context:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain,null);
    var loader:Loader = new Loader();
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, fontLoadComplete);
    loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
    var strPath:String = "assets/fonts/font.swf"
    var urlReq: URLRequest = new URLRequest();
    urlReq = strPath;
    loader.load(urlReq, context);
    please correct me if i am doing any thing wrong in loading swf with as3 code.
    Regards,
    Saravanan

    Hi Nimit,
    Sorry for late reply.
    Actually problem is in my side.I am loading two swfs one with code in side another without code.
    I used loader content for only swf containing code inside but both the swfs requires to specify the loader content to same application domain.
    Its working fine after set the loader content to both swfs.
    sorry for trouble and thanks for the response.
    Regards,
    Saravanan.G

  • Problem loading swf which reads data in a local file

    Hi,
    Using flex with a online project, I have to load a swf file, which reads data in a xml file (it works fine if I open it with flash player)
    I do a very simple test :
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                    layout="absolute"
                    minWidth="955" minHeight="600"
                    >
        <mx:SWFLoader id="swfloader" source="data/player.swf"/>
    </mx:Application>
    The result is that player.swf can't read the xml file (error : Error #2044: ioError non pris en charge : text=Error #2032: Erreur de flux. URL: enonce.xml).
    I do the same test with an AIR project, and it works fine !!!!
    It works also if I put the xml file directly at the same level as my compiled application (in bin-debug for instance).
    I think that it's a path problem, but I don't know how to set it.
    Is there any way to solve the problem ???
    Thanks a lot !
    Olivier

    Hi,
    Thanks for your answer, but I am not sure to understand it.
    What code I have to adjust :
    - the code of the swf I load ? It's a problem because I don't have access to the source code : my customer provides me only a swf file (with the xml file), and I have a lot of others swf files that work the same way, I can't ask him to modify everything.
    - the code of my application ? I don't really see how to use LoaderUtil.createAbsoluteURL, because when I debug, I see in the SWFLoader code that when this method is called, the returned url is good !
    Thanks for your help.
    Olivier

  • AS3 load external swf problem, please help...

    Hey guys, I am really in need of an answer here. I would tremendously grateful if someone has the answer. I'll keep it simple and right to the point:
    1. I have created "index.swf" in AS3. Has it's own "MainClass" class.
    2. I created "holder.swf" which is the main landing page. Has 2 buttons, for the viewer to load the site in fullscreen or standard.
    3. In the timeline of "holder.swf" I have created 2 frames, 1st frame containing the buttons, second frame containing the AS3 external swf loader script.
    It does not seem to want to load my "index.swf".
    I have tested a million different ways, it load other swf's just fine, AS2 and AS3, but for some strange reason it just will NOT load "index.swf".
    This is driving me crazy, I have a feeling it has something to do with a class conflict. I have tried (import MainClass;) in the first frame of "holder.swf" and no luck.
    PLEASE GUYS, LET ME KNOW IF YOU KNOW THE ANSWER!
    THANK YOU SO MUCHO.
    Michael

    Hey kglad,
    Thanks for the quick reply!
    Well here is the problem... With the exception of a few things I need to update, as well as implementing some better preloaders etc... the site is running alright...
    About a week ago I decided that I wanted to site to start with the above landing page. A simple "holder.swf" which would give the viewer something to look at before entering the site... (ideally I want to find a script that will begin loading "index.swf" while the viewer is still on "holder.swf", but I'll figure that out later).
    Anyhow, I created "holder.swf" as I have many times before, and for some reason it does not seem to want to load "index.swf" into the second frame when instructed to do so... does that make sense?
    So... ideally I would like the site to start on the above graphic, then once the button is clicked, "index.swf" opens up...
    It's driving me crazy, because my code works on other swf's I've tested it with, just not with index.swf, which leads me to believe there is something in the MainClass.as file which is causing it not to load...
    What are your thoughts?
    Oh, and many thanks again!!!
    M

  • Load AS2 swf into AS3 swf problem

    I have a flash with AS3 and inside this swf i load in a AS2 swf.
    to load swf works just fine, but the problem is when i load this i want to go to
    a specific part of it, for example i want to go to frame 3 in the loaded swf.
    i must control this from the AS3 swf, does someone know if this is possible?
    thanks in advance

    so can i do like this then to go to frame 3 in my loaded swf?
    MovieClip(ldr.content).gotoAndStop(3); ?
    sorry for being such an airhead
    thanks for helping me out =)
    Date: Sun, 7 Jun 2009 10:25:09 -0600
    From: [email protected]
    To: [email protected]
    Subject: load AS2 swf into AS3 swf problem
    no.
    if, in your loaded swf, you have a function f1() on the loaded swf's main timeline and you load that swf using a loader (say ldr), use:
    MovieClip(ldr.content).f1();   // to call f1() in the loaded swf
    >

  • HELP PLEASE - loading external swf scale problem

    I have a Flex 3 Actionscript Project. Basically all it does it take some flash vars, set the sound volume,  and load an external swf using a loader and add the loader as a child. The problem is I want the loaded external swf to be scaled to fill the entire stage, even if it distorts it, and that doesn't seem to be happening.
    I really need to resolve this. ANY HELP APPRECIATED.
    Marcus

    Thanks for the reply!
    Here's basically what my code looks like (note: I cut some stuff out that wasn't relevant for the sake of clarity).
    private var swfLoader:Loader = null;
    public function MySwfContainer()  
        stage.scaleMode = StageScaleMode.EXACT_FIT;
        stage.align = StageAlign.TOP_LEFT;
        var request:URLRequest = new URLRequest(swfUrl);
        swfLoader = new Loader();
        swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,SWFLoader_Complete);
        swfLoader.load(request);       
    private function SWFLoader_Complete(event:Event):void
        addChild(swfLoader);
    What I am observing is that if a swf larger than the stage area is loaded it clips it rather than scale it down and make it fit.
    Marcus

  • Problem when load more swf files work with xml files into my movie

    hi ;
    I have one flash file & more of swf files which work with xml files .
    when I load one swf file into my flash file  and remove it and load anther one on the same movieclip in my flash file it load the old swf file.
    when i load one on movieclip and remove it and load anther swf  on anther movieclip the file doesn`t work  and stoped.
    when test my flash file to load and remove swf files without xml file it work fine but when repleaced the swf files with other work with xml files the problem hapend.
    thanks;

    YOu should trace the names of the files that are being targeted for loading to see if they agree with what you expect.  If you want help with the coding you will need to show the code that is relevant to your problem (not all of it)

  • Problem loading swf file in flash player 9.0.47.0

    Hi all!
    I have a really strange problem and couldn't find any information over the internet.
    The problem only occurs in flash player 9.0.47.0. It works in all the others players, newer and older..
    I try to load a swf file to my web application and get the following error: "This content requires Adobe Flash Player 10.2. Would you like to install it now?"
    the log file shows:
    *** Security Sandbox Violation ***
    SecurityDomain 'http://10.1.1.84:8080/app/jsp/flex/bin-release/LP_FLEX_project.html' tried to access incompatible context 'http://fpdownload.macromedia.com/pub/flashplayer/update/current/swf/autoUpdater.swf?0.5087 71003223956'
    Warning: Reference to undeclared variable, 'out'
    Warning: Reference to undeclared variable, 'out'
    Warning: 'out' has no property 'text'
    Warning: Reference to undeclared variable, 'cameraSettings'
    Warning: 'System' has no property '_visible'
    Warning: Reference to undeclared variable, 'microphoneSettings'
    Warning: 'System' has no property '_visible'
    Warning: Reference to undeclared variable, 'privacy'
    Warning: checkPort is not a function
    Warning: Reference to undeclared variable, 'xOffset'
    Warning: Reference to undeclared variable, 'yOffset'
    Warning: Reference to undeclared variable, 'cameraSettings'
    Warning: 'System' has no property '_visible'
    Warning: Reference to undeclared variable, 'microphoneSettings'
    Warning: 'System' has no property '_visible'
    Warning: Reference to undeclared variable, 'privacy'
    Warning: checkPort is not a function
    Warning: Reference to undeclared variable, 'cameraSettings'
    Warning: 'System' has no property '_visible'
    Warning: Reference to undeclared variable, 'microphoneSettings'
    Warning: 'System' has no property '_visible'
    Warning: Reference to undeclared variable, 'privacy'
    Does anybody has a solution??
    Thanks alot!
    Assaf

    Maybe FP9 does not support your application / swf file?  How did you develop it?

  • Fiexed! AIR 3.7 on ios load packaged swf problem

    I have fixed this, thanks. It's because this:
    <mxmlc file="${SOURCE_DIR}/${APP_NAME}.${APP_EXTENSION}"
    output="${OUTPUT_DIR}/${APP_NAME}.swf"
    static-rsls="true" It's the problem
    accessible="true"
    configname="air"
    debug="${DEBUG_FLAG}"
    failonerror="true"
    fork="true"
    maxmemory="512m">
    Hi, nice guys
    Thanks for your time to watch my proble!
    I'm develop IOS App by AIR 3.7. I have seen this about load swf http://blogs.adobe.com/airodynamics/2012/11/09/packaging-and-loading-multiple-swfs-in-air- apps-on-ios/  . Everything works fine in debug mode, but when I release it , everything is gone.
    I'm using AIR 3.7 in GPU renderer mode, and load SWF with some code. I have add LoaderContext.
    var l:LoaderContext=new LoaderContext(false, ApplicationDomain.currentDomain);
    l.allowCodeImport=true;
    When I debug in Fast mode, everything is ok, in Standard mode package get the Errors:
    Error occurred while packaging the application:
    java.lang.NegativeArraySizeException
              at com.adobe.air.ipa.SWFUtils.read(SWFUtils.java:205)
              at com.adobe.air.ipa.SWFUtils.inspect(SWFUtils.java:250)
              at com.adobe.air.ipa.SWFUtils.<init>(SWFUtils.java:181)
              at com.adobe.air.ipa.SWFSplitter.main(SWFSplitter.java:68)
    Exception in thread "main" com.adobe.air.InvalidInputException: Invalid input. Not a valid swf file
              at com.adobe.air.ipa.SWFSplitter.main(SWFSplitter.java:105)
    Compilation failed while executing : ADT
    When I use a empty project to load a test swf, get the Error:
    Main Thread (Suspended: Error: Error #3747: Multiple application domains are not supported on this operating system.)
    Anybody know how to fix this ?
    Thanks!

    i have same problem. but i did not understand where is this code? where should i look?
    """<mxmlc file="${SOURCE_DIR}/${APP_NAME}.${APP_EXTENSION}"
    output="${OUTPUT_DIR}/${APP_NAME}.swf"
    static-rsls="true" It's the problem
    accessible="true"
    configname="air"
    debug="${DEBUG_FLAG}"
    failonerror="true"
    fork="true"
    maxmemory="512m">""""

  • AS3 - Load an SWF (problem)

    Hello,
    I have to make some kind of an portfolio where I have to load my .swf's and .f4v's I made past year.
    My code doesn't make me having errors.
    Code:
    var request:URLRequest = new URLRequest("bronbestanden/A_AndriessenB_Fotoalbum.swf");
    var laden:Loader = new Loader();
    laden.scaleX = laden.scaleY = 0.5;
    laden.x = 100;
    laden.y = 190;
    laden.load(request);
    addChild(laden);
    But when I click the button he loads my .swf's but plays it
    very very slow. The fps of both my portfolio and swf is exactly the same. I already put the code
    to load my .swf in another new file and there it works very fluently. All my other types of videos (.flv's and .f4v's) also
    run without any problem (even though my .f4v-files are bigger than my .swf's) Can anyone help me?
    Thanks

    // add some preloader entertainment display
    var request:URLRequest = new URLRequest("bronbestanden/A_AndriessenB_Fotoalbum.swf");
    var laden:Loader = new Loader();
    laden.scaleX = laden.scaleY = 0.5;
    laden.x = 100;
    laden.y = 190;
    laden.contentLoaderInfo.addEventListener(Event.COMPLETE.loadCompleteF);
    laden.load(request);
    function loadCompleteF(e:Event):void{
    // remove your preloader display
    addChild(laden);
    MovieClip(laden.content).gotoAndPlay(1);

  • Problems seeing my swf file after it's loaded on my server

    Hello! I loaded a swf file in a dreamweaver cs3 and tested it on a browser and works fine. However, after I uploaded everything on my server.. I don't see the swf anymore.. I loaded the scripts AC_RunActiveContent.js.. Can't find the solution for this! Any help is appreciated it. Thanks in advance.
    Here is the link to the page: http://www.salveasi.com.br/index_test2.html

    Then there's your problem. IE uses an activeX control and many other non-standard practices to display html content. It looks like you're going to have to change your design to get the look that you want to achieve.

  • Loading External SWF - Problem

    Hi,
    Using MovieClipLoader I want to load external SWFs - and it
    is working fine
    if external swf doesn't have anything outside it's stage,
    otherwise it shows
    everything - that's the problem.
    For example, external swf's stage dimensions are 100x150, but
    it has some
    timeline animation (some objects scrolling through the stage,
    some bouncing
    text animation that sometimes goes off-stage, etc..).
    So when I load this external movie (banner.swf), I can see
    all these objects
    that were bouncing outside this 100x150 area (the stage of
    banner). Even
    more - the size of loaded movie is larger than 100x150px
    (because of these
    off-stage objects that are now visible). This way I'm getting
    positioning
    problems, too.
    var mcl:MovieClipLoader = new MovieClipLoader();
    mcl.loadClip("banner.swf", holder);
    mcl.addListener(listener);
    holder._x = Stage.width/2 - holder._width/2;
    holder._y = Stage.height/2 - holder._height/2;
    Thanks in advance,
    B.

    Hi kglad,
    Does doing that takes only into account width and height of the stage, or also considers off stage items (as in the initial question)?
    I am also looking at this issue and we can't have all the content providers modify their pre-existing flash applications to be displayed in the appropiate scale. We are looking to any of the following:
    find a way to get adobe air/flash to not consider the off stage elements on the width/height we set to the movie.
    find a way to get the stage size from the external movie and use that to auto calculate the resize needed.
    any other alternative that allows to have the same end result, which is loading up the external content at the size we specify and displaying well. We can actually hide content outside the stage, but we still need to know the appropiate scale / size to apply to the movie so what's visible matches the are where we want to show the content.

Maybe you are looking for