AddChild in non-document class

Hello, I'm trying to migrate the hundreds of lines of code in
my main actions frame into classes.
Could someone be so kind as to tell me how to use the
addChild in a class that isn't the document class. I have got my
file structure setup with the package folder and the main document
class in the .fla root.
I can trace from secondary classes but not use addChild and I
am about to lose my mind!
I have included one of my the classes so you can see how I
have worked it.

I am trying to catch up to AS3 from older versions of Flash,
so I may be wrong about this.
from what I understand, the only way to reference the stage
is to use the stage property from an item already on the stage,
such as your main document class (or another sprite or movie clip
on the stage). as it stands you are adding 'aCloud' as a child of
the new CloudClass object, not as a child of the stage. so..
MyClouds.stage.addchild(aCloud);
also, the other poster was right about the typo--
aCloud:captionCloud = new captionCloud();
one other thing I don't understand, maybe I'm missing
something-- where is the "captionCloud" class? is it public, or at
least accessable by CloudClass? also wouldn't it be a better idea
to define all the properties for a captionCloud object in a method
of the captionCloud class, and then use CloudClass to control the
relationship between all the different captionCloud objects (but
not their internal properties such as alpha, x, y, etc). this seems
more OOP appropriate to me.
anyway, i'd like to know what finally works for you, please
post your solution when you figure it out. i'm just starting on my
1st AS3 project.

Similar Messages

  • Access a mc or textfeild from a non document class.

    Hey all.
    This use to be simple in as2, but seems to allude me from as3.  It used to be simple to access an object you put on the stage like a mc or dynamic text field by simply using _root.instanceName ect.  Now I see references to making references to the Stage and such like:
    private var stage:Stage;
    stage = stageRef;
    and I am still confused.
    What I have going on is, I have placed a movieclip on the stage in Flash and gave it an instance name of Cell_mc.
    I have a cusom class that extends MovieClip with the following imports
    import flash.display.MovieClip;
    import flash.events.Event;
    import flash.events.EventDispatcher;
    import flash.events.MouseEvent;
    import flash.events.TimerEvent;
    import flash.utils.Timer;
    This Class is tied to a set of MovieClips in my Library.
    I have a listener: this.addEventListener(MouseEvent.MOUSE_DOWN,pickUp);
    And a function:
    private function pickUp(event:MouseEvent):void
                      this.startDrag();
                      _interval = new Timer(100);
                      _interval.addEventListener(TimerEvent.TIMER,onInterval);
                      _interval.start();
    And
    private function onInterval(event:TimerEvent):void
                      //Set up hit test
                      this.hitArea(Cell_mc)
                            trace("hit");
    I get the following error whenever I try to access an object I placed on the stage from anywhere other than the document class:
    1120: Access of undefined property Cell_mc.
    How do I access the cell_mc that is already on the stage from this non-document class?
    Thanks guys.

    try:
    private var stage:Stage;
    stage = stageRef;
    and I am still confused.
    What I have going on is, I have placed a movieclip on the stage in Flash and gave it an instance name of Cell_mc.
    I have a cusom class that extends MovieClip with the following imports
    import flash.display.MovieClip;
    import flash.events.Event;
    import flash.events.EventDispatcher;
    import flash.events.MouseEvent;
    import flash.events.TimerEvent;
    import flash.utils.Timer;
    This Class is tied to a set of MovieClips in my Library.
    I have a listener: this.addEventListener(MouseEvent.MOUSE_DOWN,pickUp);
    And a function:
    private function pickUp(event:MouseEvent):void
                      this.startDrag();
                      _interval = new Timer(100);
                      _interval.addEventListener(TimerEvent.TIMER,onInterval);
                      _interval.start();
    And
    private function onInterval(event:TimerEvent):void
                      //Set up hit test
                      this.hitArea(MovieClip(root).Cell_mc)
                            trace("hit");
    I get the following error whenever I try to access an object I placed on the stage from anywhere other than the document class:
    1120: Access of undefined property Cell_mc.
    How do I access the cell_mc that is already on the stage from this non-document class?
    Thanks guys.

  • Refer to the document class from another class?

    There is a function in my document class that I need to call from inside another class. How can I call myFunction from inside OtherClass? Or refer to myVariable from inside OtherClass?
    package {
    import flash.display.Sprite;
    public class DocumentClass extends Sprite {
    public function DocumentClass():void {
    _init();
    private function _init():void {
    var myVariable:int = 0;
    function myFunction():void {
    //The function I need to access
    var myClass = new OtherClass();

    There's many ways to do it. On a case by case basis a strategy has to be chosen.
    In your case, is there literally just one child class that's trying to ask the root class to run the function? Are a bunch of other classes also trying to get at this same function? Flesh out a really good description of what you want to do for a few suggestions.
    For fun I'm going to assume other classes may want to call this function and at the same time be really simplistic in the approach by assuming the project is simple and bubbled events won't hurt performance. It doesn't sound like this is a particle situation.. In that case I'd send a simple bubbled event Main can read.
    e.g.:
    Main:
    package
      import flash.display.Sprite;
      import flash.events.Event;
      public class Main extends Sprite
           private var _a:Sprite;
           public function Main():void
                addEventListener(Event.ENTER_FRAME, onEF);
           // Called from BClass after added to stage (for event to propagate)
           public function SomeFunction():void
                // now that this is called, do what you want..
                // I'm just going to remove _a (for no special reason)
                trace("Main.SomeFunction() - called, removing _a (_b will GC eventually as well)");
                removeChild(_a);
                _a.removeEventListener("OMGEvent", _handleOMGF);
                _a = null;
           private function onEF(e:Event):void
                removeEventListener(Event.ENTER_FRAME, onEF);
                trace("Main.onEF() - Instantiating AClass");
                // instantiate a new child, which also will load a child
                _a = new AClass();
                // listen for events bubbling
                _a.addEventListener("OMGEvent", _handleOMGF);
                // add to stage
                addChild(_a);
           // listen to _a to invoke function
           private function _handleOMGF(e:Event):void
                trace("Main._handleOMGF() - child sent OMG to Main, running Main.SomeFunction()");
                SomeFunction();
    AClass:
    package
           import flash.display.Sprite;
           import flash.events.Event;
           public class AClass extends Sprite
                private var _b:BClass;
                public function AClass():void
                     addEventListener(Event.ADDED_TO_STAGE, _onAddedF);
                     addEventListener(Event.REMOVED_FROM_STAGE, _onRemovedF);
                private function _onAddedF(e:Event):void
                     removeEventListener(Event.ADDED_TO_STAGE, _onAddedF);
                     trace("AClass._onAddedF() - Instantiating BClass");
                     // first child on stage, load second child, which
                     // after it hits the stage will dispatch an event
                     _b = new BClass();
                     // we'll listen here for the event just for fun
                     _b.addEventListener("OMGEvent", _handleOMGF);
                     // trigger the ADDED_TO_STAGE
                     addChild(_b);
                // listen to _b just for fun
                private function _handleOMGF(e:Event):void
                     trace("AClass._handleOMGF() - Just heard OMG!");
                // clean up
                private function _onRemovedF(e:Event):void
                     removeEventListener(Event.REMOVED_FROM_STAGE, _onRemovedF);
                     removeChild(_b);
                     _b.removeEventListener("OMGEvent", _handleOMGF);
                     _b = null;
                     trace("AClass._onRemovedF() - I cleaned up");
    BClass:
    package
          import flash.display.Sprite;
           import flash.events.Event;
           public class BClass extends Sprite
                public function BClass():void
                     addEventListener(Event.ADDED_TO_STAGE, _onAddedF);
                private function _onAddedF(e:Event):void
                     removeEventListener(Event.ADDED_TO_STAGE, _onAddedF);
                     trace("BClass._onAddedF() - Created, dispatching 'OMGEvent' with bubbles");
                     // dispatch (I extend Sprite, it supports events)
                     // Note: I set bubbles to true to bubble back to Main (default is false)
                     dispatchEvent(new Event("OMGEvent", true));
    For ease, Example Source (saved down to CS5).
    All parents of that child will receive the dispatched event. To use that tactic you'd need to be sure your event is unique (hence using 'OMGEvent') and not have a fiercly complex display list because all those parents of this child will receive this event as well. I find in 99% of the non-particle usage of this, it really just doesn't matter. It's quick and simple.
    If you wanted to really direct it rather than bubble, you'd just remove the 'true' parameter from the dispatchEvent() and then each parent of that child would need to be told to listen for the event so it can keep relaying it up the display chain.
    I do the latter quite often when a child affects the display of each parent in some way all the way up the display list, capturing custom events at each level, doing what's necessary.
    Trace:
    Main.onEF() - Instantiating AClass
    AClass._onAddedF() - Instantiating BClass
    BClass._onAddedF() - Created, dispatching 'OMGEvent' with bubbles
    AClass._handleOMGF() - Just heard OMG!
    Main._handleOMGF() - child sent OMG to Main, running Main.SomeFunction()
    Main.SomeFunction() - called, removing _a (which marks _b for cleanup as well)
    AClass._onRemovedF() - I cleaned up
    Man, Adobe really needs to get a <pre lang="as3"> with some color coding/formatting.

  • NEED TO KNOW HOW CONVERT GIF FILE TO SYMBOL FROM DOCUMENT CLASS

                                                ROBERT LEAHONG
                                      COMPUTER PROGRAMMER / ASP Web Devloper
    Hello,
            I need to convert a GIF file (PICTURE) to a symbol (Button) From within The Document Class using ActionScript 3.0 .
    Thanks in advance for your help.

    So you imported a .gif into the library and need to get to it from the document class? If that's the case you need to  right-click the image in the library, select properties, select the ActionScript tab and then set it to export for ActionScript. Give it a class name - I'll use myGif for example. You'll see it will have a base class of BitmapData...
    Then in your document class you can just instantiate it like:
    var myImageData:BitmapData = new myGif();
    You can turn it into a useable image that you can place on stage by putting it into a Bitmap object:
    var myImage:Bitmap = new Bitmap(myImageData);
    If you want to make a button out of it, ie make it clickable - stick it into a Sprite:
    var mySprite:Sprite = new Sprite():
    mySprite.addChild(myImage);
    addChild(mySprite);
    mySprite.addEventListener(MouseEvent.CLICK, clicked);
    function clicked(e:MouseEvent):void
         trace("clicked");
    HTH

  • Document Classes and other Questions

    Basically, i am working on an application that will eventually be deployed to the desktop as an AIR application.
    I am wanting to create an Analogue clock and Digital clock with a button that toggles the display between either one when pressed. As well as this, i will be wanting to display the Date below, i am having a number of issues however.
    I have the code sorted for three of the four components, i have not attempted to figure out the button thus far as i would be more than happy to have the digital clock, analogue clock and date all being displayed on a drag and drop desktop application first. When i say i have it sorted, i have a fully working analogue clock which i have managed to display on the desktop through air on its lonesome, however, i did not include the drag and drop function. For the digital clock and date components i am not sure how to configure them into document classes. The main issue i am having is i do not know if you can reference a dynamic text box within a movie clip to a document class.
    This is the code to show the date
    [code]{
    var currentTime:Date = new Date();
    var month:Array = new Array("January","February","March","April","May","June","July","August","September","Octo ber","November","December");
    var dayOfWeek:Array = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
    date_text.text = dayOfWeek[currentTime.getDay()] + " " + currentTime.getDate() + " " + month[currentTime.getMonth()] + " " + currentTime.getFullYear();
    [/code]
    I have put the actionscript frame inside the movie clip file, and i have given both the movie clip, and the dynamic text box within the movie clip the instance name "date_text".
    Basically, i am just struggling in how to put this code into a working document class, since the digital clock and date functions are both, some what similar, i feel the solution to one will more than likely lead to me discovering the solution for the other.
    The other problem i am having, i do not know how i will display all of the components on one air application. I am assuming, that you create one other document class file which links the other four together? i have tried to do this by just linking a new FLA file with the analogue clock, but it does not work. The code for that is below.
    [code]package
              import flash.events.Event;
              import flash.display.MovieClip;
              public class time1 extends MovieClip
                        public var now:Date;
                        public function time1()
                                  // Update screen every frame
                                  addEventListener(Event.ENTER_FRAME,enterFrameHandler);
                        // Event Handling:
                        function enterFrameHandler(event:Event):void
                                  now = new Date();
                                  // Rotate clock hands
                                  hourHand_mc.rotation = now.getHours()*30+(now.getMinutes()/2);
                                  minuteHand_mc.rotation = now.getMinutes()*6+(now.getSeconds()/10);
                                  secondHand_mc.rotation = now.getSeconds()*6;
    [/code]
    That is the original clock document class (3 Movie clips for the moving hands, and the clock face is a graphic, which i may have to reference somehow below)?
    [code]package
              import flash.display.MovieClip;
              public class main extends MovieClip
                        public var hourHand_mc:time1;
                        public var minuteHand_mc:time1;
                        public var secondHand_mc:time1;
                        public function main()
                                  hourHand_mc = new SecondHand();
                                  addChild(mySecondHand);
                                  hourHand_mc.x = 75;
                                  hourHand_mc.y = 75;
                                  minuteHand_mc = new SecondHand();
                                  addChild(mySecondHand);
                                  minuteHand_mc.x = 75;
                                  minuteHand_mc.y = 75;
                                  secondHand_mc = new SecondHand();
                                  addChild(mySecondHand);
                                  secondHand.x = 75;
                                  secondHand.y = 75;
    }[/code]
    This is my attempt at creating the main document class in a seperate FLA file to attempt to load the analogue clock, and later on the Digital Clock, Date Function and Toggle Display button in the same AIR application.
    Any help on this is much appreciated, i have been reading up a lot on it through tutorials and the like, but i can't seem to fully grasp it.

    why do you have code in a movieclip?
    if you want to follow best practice and use a document class you should remove almost all code from timelines.  the only timeline code that might be reasonably used would be a stop() on the first frame of multiframe movieclips.
    so, you should have a document class.  that could contain all your code but it would be better to just have your document class create your 2 clocks and date objects and possibly manage toggling between the two clocks.  you could have a separate class the tracks the time and date and that class is used by your two clock classes and your date class.

  • Document Class not work when I shift my MovieClip to 2nd Frame.

    Hello,
    All my content is at 1st frame of my FLA file...and I'm using Document Class... When I try to shift my content to 2nd frame, so I can use 1st frame for preloader.. but its not working...
    This is my document class... Basically at 1st frame I'm loading external jpg image to a MovieClip..
    Is it possible, I can **** my MovieClip and other content to 2nd frame of the timeline... ??? and Document Class work???
    Thanks...
    package com.ahmad.bg
         //import all classes
         import caurina.transitions.Tweener;
         import flash.display.Loader;
         import flash.display.MovieClip;
         import flash.display.Sprite;
         import flash.display.StageAlign;
         import flash.display.StageDisplayState;
         import flash.display.StageScaleMode;
         import flash.events.Event;
         import flash.events.MouseEvent;
         import flash.net.URLRequest;
         public class MainClass extends MovieClip
              //create variables
              private var loader:Loader;
              private static const IMAGE_PATH:String = "bgs/bg.jpg";         
              public function MainClass() {
                   stage.align = StageAlign.TOP_LEFT;
                   stage.scaleMode = StageScaleMode.NO_SCALE;              
                   stage.addEventListener(Event.RESIZE, stageResize);         
                   //load external image
                   loader = new Loader();
                   loader.load(new URLRequest(IMAGE_PATH));
                   loader.contentLoaderInfo.addEventListener(Event.COMPLETE, showImage);
                   pic.addChild(loader);    
              private function showImage(e:Event):void
                   try {                             
                        e.target.content.alpha = 1;
                        Tweener.addTween(e.target.content, { alpha:1, time:1, transition:"easeOutSine" } );                   
                        e.target.content.smoothing = true;                             
                   } catch (e:Error) { };
                   stageResize();
              private function stageResize(e:Event=null):void
                   pic.x = 0;
                   pic.y = 0;
                   pic.scaleX = pic.scaleY = 1;              
                   if ((stage.stageHeight / stage.stageWidth) < pic.height / pic.width) {
                        pic.width = stage.stageWidth;
                        pic.scaleY = pic.scaleX;
                   } else {
                        pic.height = stage.stageHeight;                   
                        pic.scaleX = pic.scaleY;
                   pic.x = stage.stageWidth / 2 - pic.width / 2;
                   pic.y = stage.stageHeight / 2 - pic.height / 2;         
                   bottomNav.x = Math.floor(stage.stageWidth / 2 - bottomNav.width / 2);
                   bottomNav.y = Math.floor(stage.stageHeight - bottomNav.height - 0);

    If you have code in your main class that references specific movieclips on the stage, they have to be on every frame you plan on using.
    If you have a movieclip named "pic" on frame 2, but you are referencing it right away in the main class, which starts on frame 1, then it is looking for a movieclip that does not exist until you move it to frame 2

  • Preloader in Document Class Help.

    Hello,
    I want to know that how can I add a Preloader to my existing document class. In my FLA all content is on 1st Frame. I'm loading an external image to a MovieClip which is on 1st frame and on stage. My document class is working fine but when i try to add any preloading script, its not working...
    Can any one please help me in this regard..
    A Garden of Thanks.
    My Document Class is here...  (This was also a tutorial which I'm using..)
    package com.ahmad.bg
         //import all classes
         import caurina.transitions.Tweener;
         import flash.display.Loader;
         import flash.display.MovieClip;
         import flash.display.Sprite;
         import flash.display.StageAlign;
         import flash.display.StageDisplayState;
         import flash.display.StageScaleMode;
         import flash.events.Event;
         import flash.events.MouseEvent;
         import flash.net.URLRequest;
         public class MainClass extends MovieClip
              //create variables
              private var loader:Loader;
              private static const IMAGE_PATH:String = "bgs/bg.jpg";          
              public function MainClass() {
                   stage.align = StageAlign.TOP_LEFT;
                   stage.scaleMode = StageScaleMode.NO_SCALE;               
                   stage.addEventListener(Event.RESIZE, stageResize);          
                   //load external image
                   loader = new Loader();
                   loader.load(new URLRequest(IMAGE_PATH));
                   loader.contentLoaderInfo.addEventListener(Event.COMPLETE, showImage);
                   pic.addChild(loader);     
              private function showImage(e:Event):void
                   try {                              
                        e.target.content.alpha = 0;
                        Tweener.addTween(e.target.content, { alpha:1, time:1, transition:"easeOutSine" } );                    
                        e.target.content.smoothing = true;                              
                   } catch (e:Error) { };
                   stageResize();
              private function stageResize(e:Event=null):void
                   pic.x = 0;
                   pic.y = 0;
                   pic.scaleX = pic.scaleY = 1;               
                   if ((stage.stageHeight / stage.stageWidth) < pic.height / pic.width) {
                        pic.width = stage.stageWidth;
                        pic.scaleY = pic.scaleX;
                   } else {
                        pic.height = stage.stageHeight;                    
                        pic.scaleX = pic.scaleY;
                   pic.x = stage.stageWidth / 2 - pic.width / 2;
                   pic.y = stage.stageHeight / 2 - pic.height / 2;          
                   //my bottom navigation
                            bottomNav.x = Math.floor(stage.stageWidth / 2 - bottomNav.width / 2);
                   bottomNav.y = Math.floor(stage.stageHeight - bottomNav.height - 0);

    package com.ahmad.bg
         //import all classes
         import caurina.transitions.Tweener;
         import flash.display.Loader;
         import flash.display.MovieClip;
         import flash.display.Sprite;
         import flash.display.StageAlign;
         import flash.display.StageDisplayState;
         import flash.display.StageScaleMode;
         import flash.events.Event;
         import flash.events.MouseEvent;
         import flash.net.URLRequest;
         import flash.events.ProgressEvent;
         public class MainClass extends MovieClip
              //create variables
              private var loader:Loader;
              private static const IMAGE_PATH:String = "bgs/bg.jpg";          
              public function MainClass() {
                   stage.align = StageAlign.TOP_LEFT;
                   stage.scaleMode = StageScaleMode.NO_SCALE;               
                   stage.addEventListener(Event.RESIZE, stageResize);          
                   //load external image
                   loader = new Loader();
                   loader.load(new URLRequest(IMAGE_PATH));
                   loader.contentLoaderInfo.addEventListener(Event.COMPLETE, showImage);
                   loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, preload_image, false, 0, true);
                   private function preload_image(event:ProgressEvent):void
                          var per = int((event.bytesLoaded / event.bytesTotal) * 100);
                          pic.addChild(loader);
                          //make a textfield or preloader animation and assign this per to it.
              private function showImage(e:Event):void
                   try {                              
                        e.target.content.alpha = 0;
                        Tweener.addTween(e.target.content, { alpha:1, time:1, transition:"easeOutSine" } );                    
                        e.target.content.smoothing = true;                              
                   } catch (e:Error) { };
                   stageResize();
              private function stageResize(e:Event=null):void
                   pic.x = 0;
                   pic.y = 0;
                   pic.scaleX = pic.scaleY = 1;               
                   if ((stage.stageHeight / stage.stageWidth) < pic.height / pic.width) {
                        pic.width = stage.stageWidth;
                        pic.scaleY = pic.scaleX;
                   } else {
                        pic.height = stage.stageHeight;                    
                        pic.scaleX = pic.scaleY;
                   pic.x = stage.stageWidth / 2 - pic.width / 2;
                   pic.y = stage.stageHeight / 2 - pic.height / 2;          
                   //my bottom navigation
                   bottomNav.x = Math.floor(stage.stageWidth / 2 - bottomNav.width / 2);
                   bottomNav.y = Math.floor(stage.stageHeight - bottomNav.height - 0);
    Oh.. Thanks.. its working now... Thanks aloooooooooooooot.....
    Any other tip if you have a time to give me will be a greatful to you...
    Thanks again for your precious time.. I've seen your Awesome Portfolio at your website....

  • Changing a document class to an imported class

    Hello everybody!
    My following document class is working fine. But, when I want to import it instead of using as a document class, it reports an error "1067: Implicit coercion of a value of type Class to an unrelated type flash.display:DisplayObject.". My class code is here:
    package
    import flash.display.Sprite;
    import flash.display.Shape;
    import flash.text.TextField;
    import flash.events.MouseEvent;
    public class Shapes extends Sprite
      var square: Sprite = new Sprite();
      var txt: TextField = new TextField();
      public function Shapes()
       square.graphics.lineStyle(4, 0xFF66CC);
       square.graphics.beginFill(0x990066);
       square.graphics.drawRect(250, 35, 175, 175);
       square.graphics.endFill();
       square.buttonMode = true;
       addChild(square);
       square.addEventListener(MouseEvent.CLICK, clickHandler);
       txt.text = "A Child of the Square";
       square.addChild(txt);
      function clickHandler(ev: MouseEvent): void
       if (square.numChildren > 0)
        square.removeChild(txt);
    My FLA file script is as below:
    import Shapes;
    addChild(Shapes);
    Seeking help, please!

    You need to create an instance of the class Shapes and tha add this isntance
    i.e. something like this
    var shapes: Shapes = new Shapes();
    addChild( shapes );

  • Non-servlet class in servlet program

    hi,
    I declare a non-servlet class which is defined by myself in a servlet class. I passed the complie but got an runtime error said NoClassDefFoundError. Does anyone can help me? Thanks.
    The following is my code.
    //get the search string from web form
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.net.*;
    import java.util.*;
    public class SearchEngines extends HttpServlet {
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {   
    String searchString = (String) request.getParameter("searchString");
         String searchType = (String) request.getParameter("searchType");
         Date date = new java.util.Date();
         response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    Vector doc_retrieved = new Vector();
    BooleanSearch bs = new BooleanSearch();
    doc_retrieved=bs.beginSearch(searchString, searchType);
    out.println("<HTML><HEAD><TITLE>Hello Client!</TITLE>" +
                   "</HEAD><BODY>Hello Client! " + doc_retrieved.size() + " documents have been found.</BODY></HTML>");
    out.close();
    response.sendError(response.SC_NOT_FOUND,
    "No recognized search engine specified.");
    public void doPost(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    doGet(request, response);
    // a search engine implements the boolean search
    import java.io.*;
    import java.util.*;
    import au.com.pharos.gdbm.GdbmFile;
    import au.com.pharos.gdbm.GdbmException;
    import au.com.pharos.packing.StringPacking;
    import IRUtilities.Porter;
    public class BooleanSearch{
         BooleanSearch(){;}
         public Vector beginSearch(String searchString, String searchType){
              Vector query_vector = queryVector(searchString);
              Vector doc_retrieved = new Vector();
              if (searchType.equals("AND"))
                   doc_retrieved = andSearch(query_vector);
              else
                   doc_retrieved = orSearch(query_vector);
              return doc_retrieved;
         private Vector queryVector(String query){
         Vector query_vector = new Vector();
              try{
                   GdbmFile dbTerm = new GdbmFile("Term.gdbm", GdbmFile.READER);
              dbTerm.setKeyPacking(new StringPacking());
              dbTerm.setValuePacking(new StringPacking());
              query = query.toLowerCase();
              StringTokenizer st = new StringTokenizer(query);
              String word = "";
              String term_id = "";
              while (st.hasMoreTokens()){
                   word = st.nextToken();
                   if (!search(word)){
                        word = Stemming(word);
                        if (dbTerm.exists(word)){
                   //          System.out.println(word);
                             term_id = (String) dbTerm.fetch(word);
                             query_vector.add(term_id);
              catch(GdbmException e){
                   System.out.println(e.getMessage());
              return query_vector;
         private Vector orSearch(Vector query_vector){
              Vector doc_retrieved = new Vector();
              try{
                   GdbmFile dbVector = new GdbmFile("Vector.gdbm", GdbmFile.READER);
                   dbVector.setKeyPacking(new StringPacking());
                   dbVector.setValuePacking(new StringPacking());
                   int doc_num = dbVector.size();
                   String doc_id = "";
                   String temp = "";
                   for (int i = 1; i <= doc_num; i++){
                        boolean found = false;
                        doc_id = String.valueOf(i);
                        temp = (String) dbVector.fetch(doc_id);
                        StringTokenizer st = new StringTokenizer(temp);
                        while (st.hasMoreTokens() && !found){
                             temp = st.nextToken();
                             StringTokenizer st1 = new StringTokenizer(temp, ",");
                             String term = st1.nextToken();
                             if (query_vector.contains(term)){
                                  doc_retrieved.add(doc_id);
                                  found = true;
              catch(GdbmException e){
                   System.out.println(e.getMessage());
              return doc_retrieved;
         private Vector andSearch(Vector query_vector){
              Vector doc_retrieved = new Vector();
              try{
                   GdbmFile dbVector = new GdbmFile("Vector.gdbm", GdbmFile.READER);
                   dbVector.setKeyPacking(new StringPacking());
                   dbVector.setValuePacking(new StringPacking());
                   int doc_num = dbVector.size();
                   String doc_id = "";
                   String temp = "";
                   for (int i = 1; i <= doc_num; i++){
                        Vector doc_vector = new Vector();
                        boolean found = true;
                        doc_id = String.valueOf(i);
                        temp = (String) dbVector.fetch(doc_id);
                        StringTokenizer st = new StringTokenizer(temp);
                        while (st.hasMoreTokens()){
                             temp = st.nextToken();
                             StringTokenizer st1 = new StringTokenizer(temp, ",");
                             String term = st1.nextToken();
                             doc_vector.add(term);
                        for (int j = 0; j < query_vector.size(); j++){
                             temp = (String) query_vector.get(j);
                             if (doc_vector.contains(temp))
                                  found = found & true;
                             else
                                  found = false;
                        if (found)
                             doc_retrieved.add(doc_id);
              catch(GdbmException e){
                   System.out.println(e.getMessage());
              return doc_retrieved;
         private String Stemming(String str){
              Porter st = new Porter ();
              str = st.stripAffixes(str);
              return str;          
         private boolean search(String str){
              //stop word list
              String [] stoplist ={"a","about","above","according","across","actually","adj","after","afterwards","again",
                                       "against","all","almost","alone","along","already","also","although","always","am","among",
                                       "amongst","an","and","another","any","anyhow","anyone","anything","anywhere","are",
                                       "aren't","around","as","at","away","be","became","because","become","becomes","becoming",
                                       "been","before","beforehand","begin","beginning","behind","being","below","beside",
                                       "besides","between","beyond","billion","both","but","by","can","cannot","can't",
                                       "caption","co","co.","could","couldn't","did","didn't","do","does","doesn't","don't",
                                       "down","during","each","eg","eight","eighty","either","else","elsewhere","end","ending",
                                       "enough","etc","even","ever","every","everyone","everything","everywhere","except",
                                       "few","fifty","first","five","for","former","formerly","forty","found","four","from",
                                       "further","had","has","hasn't","have","haven't","he","he'd","he'll","hence","her","here",
                                       "hereafter","hereby","herein","here's","hereupon","hers","he's","him","himself","his",
                                       "how","however","hundred","i'd","ie","if","i'll","i'm","in","inc.","indeed","instead",
                                       "into","is","isn't","it","its","it's","itself","i've","last","later","latter","latterly",
                                       "least","less","let","let's","like","likely","ltd","made","make","makes","many","maybe",
                                       "me","meantime","meanwhile","might","million","miss","more","moreover","most","mostly",
                                       "mr","mrs","much","must","my","myself","namely","neither","never","nevertheless","next",
                                       "nine","ninety","no","nobody","none","nonetheless","noone","nor","not","nothing","now",
                                       "nowhere","of","off","often","on","once","one","one's","only","onto","or","other","others",
                                       "otherwise","our","ours","ourselves","out","over","overall","own","per","perhaps","pm",
                                       "rather","recent","recently","same","seem","seemed","seeming","seems","seven","seventy",
                                       "several","she","she'd","she'll","she's","should","shouldn't","since","six","sixty",
                                       "so","some","somehow","someone","sometime","sometimes","somewhere","still","stop",
                                       "such","taking","ten","than","that","that'll","that's","that've","the","their","them",
                                       "themselves","then","thence","there","thereafter","thereby","there'd","therefore",
                                       "therein","there'll","there're","there's","thereupon","there've","these","they","they'd",
                                       "they'll","they're","they've","thirty","this","those","though","thousand","three","through",
                                       "throughout","thru","thus","to","together","too","toward","towards","trillion","twenty",
                                       "two","under","unless","unlike","unlikely","until","up","upon","us","used","using",
                                       "very","via","was","wasn't","we","we'd","well","we'll","were","we're","weren't","we've",
                                       "what","whatever","what'll","what's","what've","when","whence","whenever","where",
                                       "whereafter","whereas","whereby","wherein","where's","whereupon","wherever","whether",
                                       "which","while","whither","who","who'd","whoever","whole","who'll","whom","whomever",
                                       "who's","whose","why","will","with","within","without","won't","would","wouldn't",
                                       "yes","yet","you","you'd","you'll","your","you're","yours","yourself","you've"};
              int i = 0;
              int j = stoplist.length;
              int mid = 0;
              boolean found = false;
              while (i < j && !found){
                   mid = (i + j)/2;
                   if (str.compareTo(stoplist[mid]) == 0)
                        found = true;
                   else
                        if (str.compareTo(stoplist[mid]) < 0)
                             j = mid;
                        else
                             i = mid + 1;
              return found;
         }

    please show us the full error message.
    it sounds like a classpath problem...

  • Accessing value in document class

    hello i am trying to acces a value in the document class. but i can't get it to work.
    what i have is:
    can someone tell me how i should access the myArray value?
    bomberman.as:
    package  {
              import flash.display.MovieClip;
              public class bomberman extends MovieClip {
            public var myArray:Array=[]; //trying to access this value
                        public function bomberman() {
                                  init();
                                  //trace(document.docClass);
                        private function init() {
                        var square:Array=[];
                                  for (var i:Number=0;i<11;i++) {
                                            for (var j:Number=0;j<11;j++) {
                                                      var temp:grassSquare;
                                                      if (i==0||i==10) {
                                                                temp=new grassSquare(i*50,j*40);
                                                                addChild(temp);
                                                                square.push(temp);
                                                      } else if (i%2!=0) {
                                                                if (j==0||j==10) {
                                                                          temp=new grassSquare(i*50,j*40);
                                                                          addChild(temp);
                                                                          square.push(temp);
                                                                          myArray.push(false);
                                                                } else {
                                                                          myArray.push(true);
                                                      } else {
                                                                if (j%2==0) {
                                                                          temp=new grassSquare(i*50,j*40);
                                                                          addChild(temp);
                                                                          square.push(temp);
                                                                          myArray.push(false);
                                                                } else {
                                                                          myArray.push(true);
    bomberman.fla:
    import flash.events.KeyboardEvent
              var User1:Player1=new Player1;
              stage.addEventListener(KeyboardEvent.KEY_DOWN, User1.fl_SetKeyPressed);
              User1.x=75;
              User1.y=60;
              addChild(User1);
    Player1.as:
    package  {
              import flash.display.MovieClip;
              import flash.events.Event;
              import flash.events.KeyboardEvent
              import flash.ui.Keyboard
              public class Player1 extends MovieClip {
              private var upPressed:Boolean = false;
              private var downPressed:Boolean = false;
              private var leftPressed:Boolean = false;
              private var rightPressed:Boolean = false;
              private var currentSquare:uint=12;
                        public function Player1() {
                                  this.addEventListener(Event.ENTER_FRAME, fl_MoveInDirectionOfKey);
                                  //stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_SetKeyPressed);
                        public function fl_MoveInDirectionOfKey(event:Event)
                                            if (upPressed && this.y>=100 /*&&document.myArray[currentSquare-1]*/)
                                                      this.y -= 40;
                                                      upPressed = false;
                                                      currentSquare-=1;
                                            if (downPressed && this.y<=340 /*&& this.myArray[currentSquare+1]*/)
                                                      this.y += 40;
                                                      downPressed = false;
                                                      currentSquare+=1;
                                            if (leftPressed && this.x>=125 /*&& /*this.myArray[currentSquare-11]*/)
                                                      this.x -= 50;
                                                      leftPressed = false;
                                                      currentSquare-=11;
                                            if (rightPressed && this.x<=425 /* && /*this.myArray[currentSquare+11]*/)
                                                      this.x += 50;
                                                      rightPressed = false;
                                                      currentSquare+=11;
                                            trace(currentSquare);
                                  public function fl_SetKeyPressed(event:KeyboardEvent):void
                                            switch (event.keyCode)
                                                      case Keyboard.UP:
                                                                upPressed = true;
                                                                break;
                                                      case Keyboard.DOWN:
                                                                downPressed = true;
                                                                break;
                                                      case Keyboard.LEFT:
                                                                leftPressed = true;
                                                                break;
                                                      case Keyboard.RIGHT:
                                                                rightPressed = true;
                                                                break;

    i have this code now and it gives me a bunch of errors. could someone tell me what's going wrong ?
    errors are in the red code.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 25
    1093: Syntax error.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 27
    1084: Syntax error: expecting identifier before this.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 27
    1084: Syntax error: expecting colon before minusassign.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 28
    1084: Syntax error: expecting rightbrace before semicolon.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 31
    1084: Syntax error: expecting rightparen before if.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 31
    1084: Syntax error: expecting identifier before dot.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 31
    1093: Syntax error.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 33
    1084: Syntax error: expecting identifier before this.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 33
    1084: Syntax error: expecting colon before plusassign.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 34
    1084: Syntax error: expecting rightbrace before semicolon.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 37
    1093: Syntax error.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 39
    1084: Syntax error: expecting identifier before this.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 39
    1084: Syntax error: expecting colon before minusassign.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 40
    1084: Syntax error: expecting rightbrace before semicolon.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 43
    1084: Syntax error: expecting rightparen before if.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 43
    1084: Syntax error: expecting identifier before dot.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 43
    1093: Syntax error.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 45
    1084: Syntax error: expecting identifier before this.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 45
    1084: Syntax error: expecting colon before plusassign.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 46
    1084: Syntax error: expecting rightbrace before semicolon.
    package  {
              import flash.display.MovieClip;
              import flash.events.Event;
              import flash.events.KeyboardEvent
              import flash.ui.Keyboard
              public class Player1 extends MovieClip {
              private var upPressed:Boolean = false;
              private var downPressed:Boolean = false;
              private var leftPressed:Boolean = false;
              private var rightPressed:Boolean = false;
              private var currentSquare:uint=12;
                        public function Player1() {
                                  this.addEventListener(Event.ENTER_FRAME, fl_MoveInDirectionOfKey);
                                  //stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_SetKeyPressed);
                        public function fl_MoveInDirectionOfKey(event:Event)
                                            if (upPressed && this.y>=100 && MovieClip(root).myArray[currentSquare-1]*/)
                                                      this.y -= 40;
                                                      upPressed = false;
                                                      currentSquare-=1;
                                            if (downPressed && this.y<=340 && MovieClip(root).myArray[currentSquare+1]*/)
                                                      this.y += 40;
                                                      downPressed = false;
                                                      currentSquare+=1;
                                            if (leftPressed && this.x>=125 && MovieClip(root).myArray[currentSquare-11]*/)
                                                      this.x -= 50;
                                                      leftPressed = false;
                                                      currentSquare-=11;
                                            if (rightPressed && this.x<=425 && MovieClip(root).myArray[currentSquare+11]*/)
                                                      this.x += 50;
                                                      rightPressed = false;
                                                      currentSquare+=11;
                                            trace(currentSquare);
                                  public function fl_SetKeyPressed(event:KeyboardEvent):void
                                            switch (event.keyCode)
                                                      case Keyboard.UP:
                                                                upPressed = true;
                                                                break;
                                                      case Keyboard.DOWN:
                                                                downPressed = true;
                                                                break;
                                                      case Keyboard.LEFT:
                                                                leftPressed = true;
                                                                break;
                                                      case Keyboard.RIGHT:
                                                                rightPressed = true;
                                                                break;

  • Document Class initialising Application

    Hi
    I have started learning AS3. One thing I seem to be missing
    the point over is the following:
    I have a Document Class as follows:
    package {
    import flash.display.*;
    import com.Application;
    public class EntryPoint extends Sprite {
    public function EntryPoint() {
    var app:Application = new Application();
    The document class creates an instance of the Application
    class
    package com {
    import flash.display.*;
    public class Application extends Sprite{
    public function Application() {
    var mc_root:Sprite = new Sprite();
    addChild(mc_root);
    var circleTest:CircleTest = new CircleTest();
    mc_root.addChild(circleTest);
    CircleTest is a library item that has a class reference of
    'CircleTest' and a Base Class of 'flash.display.Sprite'.
    I can only get the above working if the code is in the
    Document Class.
    Help would be greatly appreciated
    Thanks

    Hi. Without looking closely, I'd think the problem is that
    you're adding the circle to the app, but not onto the document
    class instance (and neither is app added as a child to your main
    class)
    so the circle is just in limbo.
    You can look at the diagram in Flash Help- under: Basics of
    display programming

  • Constructor in document class runs twice?

    Hi Folks,
    I'm working on my document class and the contructor is running twice, hence it is running almost all of my code twice.  I'm not quite sure why this is the case.  Any help is appreciated.
    I've attached my code below.
    package {
    import flash.display.MovieClip;
    import flash.display.DisplayObject;
    import flash.events.*;
    import flash.geom.*;
    import flash.net.*;
    import flash.utils.getDefinitionByName;
    public class ASIFL048_DND extends MovieClip {
      private var startDragX:Number = new Number();
      private var startDragY:Number = new Number();
      private var xmlPath:String = "../ObjectFiles/xmlIFL0480016.xml";
      private var itemList:Array = new Array();
      private var targetList:Array = new Array();
      private var gameArray:Array = new Array();
      private var myXML:XML = new XML();
      private var myTargetName:String = new String();
      private var XMLLoader:URLLoader = new URLLoader();
      private var XMLRequest:URLRequest = new URLRequest(xmlPath);
      trace("RUNNING ONCE!");
      public function ASIFL048_DND() {
       stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
       stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
       XMLLoader.addEventListener(Event.COMPLETE, completeHandler);
       trace("RUNNING TWICE?");
       loadXML();
      private function loadXML():void {
       //var XMLLoader:URLLoader = new URLLoader();
       //var XMLRequest:URLRequest = new URLRequest(xmlPath);
       XMLLoader.load(XMLRequest);
       //XMLLoader.addEventListener(Event.COMPLETE, completeHandler);
      private function completeHandler(e:Event):void {
       myXML = XML(e.target.data);
       var i:int = 0;
       var j:int = 0;
       for each (var item:XML in myXML..equip) {
        itemList[i] = item.@name;
        for each (var target:XML in item..myTarget) {
         targetList[j] = [i,target];
         j++;
        i++;
       //trace(targetList);
       selectDragItems(10);
      private function selectDragItems(gameLength:int):void {
       var randomSeed:Number = new Number();
       var randomItem:Number = new Number();
       for (var k:int = 0; k<gameLength; k++) {
        randomSeed = targetList.length;
        randomItem = Math.floor(Math.random() * targetList.length);
        gameArray = targetList.splice(randomItem, 1);
        trace(gameArray+"\n");
        //display game array
        //trace("CLASS:\t"+itemList[gameArray[k][0][0]]);
             //var ClassReference:Class = getDefinitionByName(itemList[gameArray[k][0]]) as Class;
        //var instance:Object = new ClassReference();
        //addChild(DisplayObject(instance));
      private function mouseDownHandler(e:MouseEvent):void {
       startDragX = e.target.x;
       startDragY = e.target.y;
       trace(startDragX + " " + startDragY);
       e.target.startDrag(true,new Rectangle(e.target.width/2,e.target.height/2, stage.stageWidth-e.target.width, stage.stageHeight-e.target.height));
      private function mouseUpHandler(e:MouseEvent):void {
       stopDrag();
       myTargetName = "fwdLHWindscreen_mc";
       var myTarget:DisplayObject = getChildByName(myTargetName);
       //trace(" TARGET VAR: "+myTarget.name);
       if (e.target.dropTarget != null && e.target.dropTarget.parent == myTarget) {
        trace("correct");
        e.target.x = e.target.dropTarget.parent.x;
        e.target.y = e.target.dropTarget.parent.y;
        e.target.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
        e.target.removeEventListener(MouseEvent.MOUSE_UP,mouseUpHandler);
       } else {
        trace("incorrect");
        e.target.x = startDragX;
        e.target.y = startDragY;

    My bad. The order of output is:
    RUNNING ONCE!
    RUNNING TWICE?
    The first trace is a static initializer, while the second is in the constructor.

  • Class not communicating with document class

    I created classes that would hold the layout of my level. So level 1 has an array like:
      floor1[0] = [2,1,1,1,1,1,2];
      floor1[1] = [1,1,1,1,1,1,1];
      floor1[2] = [1,1,1,2,1,1,1];
      floor1[3] = [1,1,1,1,1,1,1];
      floor1[4] = [1,1,1,2,1,1,1];
      floor1[5] = [1,1,1,1,1,1,1];
      floor1[6] = [2,1,1,1,1,1,2];
    And level 2 would contain a different setup like:
      floor2[0] = [1,1,1,3,1,1,1];
      floor2[1] = [1,2,1,3,1,2,1];
      floor2[2] = [1,1,1,3,1,1,1];
      floor2[3] = [1,1,1,2,1,1,1];
      floor2[4] = [1,1,1,3,1,1,1];
      floor2[5] = [1,2,1,3,1,2,1];
      floor2[6] = [1,1,1,3,1,1,1];
    Here's my problem. These classes aren't communicating with my document class. My document has a blank array called createFloor that will equal floor1 first. Once that level is finished, it will equal floor2, and so on. The code is below:
    for (var Y:int=0; Y<createFloor.length; Y++)
                                            for (var X:int=0; X<createFloor[Y].length; X++)
                                                      var cell:MovieClip = new Tile(X,Y);
                                                      cell.gotoAndStop(createFloor[Y][X]);
                                                      cell.x = ((X-Y)*tileh)+365;
                                                      cell.y = ((X+Y)*tileh/2)+70;
                                                      addChild(cell);
                                                      cell.addEventListener(MouseEvent.CLICK, mouseclick);
                                                      cell.addEventListener(Event.ENTER_FRAME, onGame);
    I'm not sure how to get the document class and the level class to talk to each other. I tried making the level class extend the Main, but I fugre that had nothing to do with it. Any ideas

    change your Level1 class to:
    package  {
              import flash.display.MovieClip;
              public class Level1 extends MovieClip {
    public var floor1:Array;
                        public function Level1() {
                                 floor1 = new Array();
                                  floor1[0] = [2,1,1,1,1,1,2];
                                  floor1[1] = [1,1,1,1,1,1,1];
                                  floor1[2] = [1,1,1,2,1,1,1];
                                  floor1[3] = [1,1,1,1,1,1,1];
                                  floor1[4] = [1,1,1,2,1,1,1];
                                  floor1[5] = [1,1,1,1,1,1,1];
                                  floor1[6] = [2,1,1,1,1,1,2];
    as long as Level1 is in the same directory as your document class, in your document class you can use:
    private var level1:Level1 = new Level1();
    trace(level1.floor1);

  • ArrayController in non-document based Applications

    I just tried to use the ArrayController in an app. The app was not document based. I did everything as you are supposed to do, I made up a class called AppControll, set it Files Owner of the XIB file, connected the contend Array and so on. There were no warnings or errors, the compiler said No Issues, the Build was suchsessfull. But before the window has opened, the Application crashed. On the console was this log:
    2011-05-17 16:28:45.652 MyApp[9637:903] An uncaught exception was raised
    2011-05-17 16:28:45.656 MyApp[9637:903] [<NSApplication 0x10011b240> valueForUndefinedKey:]: this class is not key value coding-compliant for the key boxArray.
    2011-05-17 16:28:45.792 MyApp[9637:903] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<NSApplication 0x10011b240> valueForUndefinedKey:]: this class is not key value coding-compliant for the key boxArray.'
    *** Call stack at first throw:
              0   CoreFoundation                      0x00007fff8059a7b4 __exceptionPreprocess + 180
              1   libobjc.A.dylib                     0x00007fff864c30f3 objc_exception_throw + 45
              2   CoreFoundation                      0x00007fff805f2969 -[NSException raise] + 9
              3   Foundation                          0x00007fff867abb8e -[NSObject(NSKeyValueCoding) valueForUndefinedKey:] + 245
              4   Foundation                          0x00007fff866db488 -[NSObject(NSKeyValueCoding) valueForKey:] + 420
              5   AppKit                              0x00007fff8810a384 -[NSApplication(NSScripting) valueForKey:] + 492
              6   Foundation                          0x00007fff866dedcc -[NSObject(NSKeyValueCoding) valueForKeyPath:] + 226
              7   AppKit                              0x00007fff87e9fb6f -[NSBinder valueForBinding:resolveMarkersToPlaceholders:] + 171
              8   AppKit                              0x00007fff88065f80 -[NSArrayDetailBinder _refreshDetailContentInBackground:] + 368
              9   AppKit                              0x00007fff87e92a33 -[NSObject(NSKeyValueBindingCreation) bind:toObject:withKeyPath:options:] + 557
              10  AppKit                              0x00007fff87e6f546 -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:] + 1172
              11  AppKit                              0x00007fff87e6d88d loadNib + 226
              12  AppKit                              0x00007fff87e6cd9a +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] + 248
              13  AppKit                              0x00007fff87e6cbd2 +[NSBundle(NSNibLoading) loadNibNamed:owner:] + 326
              14  AppKit                              0x00007fff87e6a153 NSApplicationMain + 279
              15  MyApp                            0x0000000100001302 main + 34
              16  MyApp                            0x00000001000012d4 start + 52
    terminate called after throwing an instance of 'NSException'
    The debugger tells me "Programm recieved signal SIGBART"
    If I cut the bnding to the contend array, the Applications stats as usual, but it dosent work, because there is no contend array.
    Then I tried something else. I made up a new project, this time a document-based one, and did exactly the same as I did before. It worked well and fine the way it should work. There was no problem and the ArrayController worked fine. I don`t think a made mistake writing the name of the array, because I allways copied and pasted the name to the IB. So I would like to know if it is possible to use an ArrayController in a Non-document based Application? What do i have to do differently? The reference about the ArrayController does not mention this. It would be great if you could help me soon, thank you.

    No, but actually this was not my Problem But It helped me figure out what the problem is in detail. If you use a document based application, NSDocument can call the subclass NSPersistentDocument. This automatically reads out the model (if you use Core Data. I do`t like Core Data because it`s sometimes a bit strange and it`s hard to hunt down bugs there, but I think basically the problem is the same) and create a managedObjectContext, wich is needed to run the NSArray Controller. The big question is now, how to call something simular to NSPersistentDocument wich is not a subclass ob NSDocument but of NSObject.

  • Cannot import SWF with document class (AS3)

    When I try to import a SWF-file (published from a FLA-file with a as3 document class) via the mx:SWFLoader into Flash Builder, the imported SWF is not showing up (as3 build a cube from papervision3d). Which way do you have to import such a SWF-file?
    Regards, Sjoerd

    Shitf+Ctrl+Enter:
    Attempting to launch and connect to Player using URL preloader.swf
    [SWF] preloader.swf - 9591 bytes after decompression
    [SWF] big.swf - 1785015 bytes after decompression
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
        at DocumentlClass()
    Cannot display source code at this location.
    My document class (simplyfied):
    package {
        import flash.display.Sprite;
        import flash.display.MovieClip;
        import flash.events.Event;
        import flash.events.MouseEvent;
        import fl.transitions.Tween;
        import fl.transitions.TweenEvent;
        import fl.transitions.easing.*;
        import flash.events.ProgressEvent;
        public class CarouselClass extends MovieClip {
            private vars...
            public function CarouselClass() {
                trace("document class triggered");
                    this.addEventListener(Event.ADDED_TO_STAGE,init);
            private function init(evt:Event):void{
                 texts = new Texts();
                carouselSprite = new Sprite();
                addChild(carouselSprite);
                topContainer = new Sprite();
                carouselSprite.addChild(topContainer);
                hitBar = new HitBar();
                hitBar.x = stage.stageWidth / 2 - hitBar.width /2;
                hitBar.y = 245;
                addChild(hitBar);
                downContent = new DownContent();
                addChild(downContent);
                downContent.y = 325;
                downContent.title_txt.text = "Learning Carousel";
                downContent.description_txt.text = "Click on one of images above to view further details";
                createSections();
            } ... (more functions)

Maybe you are looking for