Undefined method addEventlistener

ERRORS ON LINE 10 AND 11
1061: Call to a possibly undefined method
addEventlistener through a reference with static
type FunButton.
package
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class FunButton extends MovieClip
public function FunButton ()
this.addEventlistener (MouseEvent.ROLL_OVER, grow);
this.addEventlistener (MouseEvent.ROLL_OUT, shrink);
private function grow (event:MouseEvent):void
this.scaleX = 1.5;
this.scaleY = 1.5;
private function shrink (event:MouseEvent):void
this.scaleX = 1;
this.scaleY = 1;

use:
addEventListener

Similar Messages

  • Symbol 'LoseMessage', Layer 'Reset_btn', Frame 1, Line 15     1061: Call to a possibly undefined method

    Hi I have a game set up, when you deplete your lives it takes you to a lose screen (Symbol), on that screen I have a button called Reset Game.
    The button name is "Reset_btn"
    The button instance is "resetbtn"
    I have the code in the symbol and I am getting this error:
    Symbol 'LoseMessage', Layer 'Reset_btn', Frame 1, Line 15    1061: Call to a possibly undefined method addEventListener through a reference with static type Class.
    Here is my code:
    //Reset Button Code
    resetbtn.addEventListener(MouseEvent.CLICK, Reset_btn);
    function Reset_btn(event:Event):void
            gotoAndStop(1);
    I have given my button and instance name and a name for the button, why am i still getting this error, can anyone help?
    Casey

    Ok.. so
    This is on a separate timeline, its a movieclip which has a timeline inside it.
    on frame 1 of that timeline inside the movieclip I have my button inside the movieclip.
    The movieclip is activated when it meets a certain condition.
    In this case when lives have been depleted to 0 from 3 a gameover screen appears.
    A button is on that gameover screen which should take me back to the main menu or Frame 1 of the actual game in this case.
    Here is the code for the condition for when game over screen appears:
    if(cursor.hitTestObject(enemyAppear2))
                            enemyAppear2.parent.removeChild(enemyAppear2);
                            stage.removeEventListener(MouseEvent.CLICK, clickEnemy2);
                            life--
                            messageDisplay2.text = String(life);
                            if(life == 0)
                                enemyTimer2.stop();
                                var loseText:LoseMessage = new LoseMessage();
                                loseText.x = 0;
                                loseText.y = 0;
                                parent.addChild(loseText);
                                Mouse.show();
    This code is in my main gaming code timeline.
    The code im trying to show is inside the movieclip which i have set up.
    Is this a clear enough explanation?

  • Call to a possibly undefined method setPropertyIsEnumerable?

    Hi,
      I am trying to accomplish using doubleClick events on dateChoosers. Below is the code that is working:
         <mx:VBox>
                  <mx:Label text="Simple DateChooser control."/>
                  <mx:DateChooser id="dateChooser1" doubleClickEnabled="true"
                      doubleClick="displayDate2()"
                      change="displayDate(DateChooser(event.target).selectedDate)"/>
                  <mx:Label id="selection"  color="blue" text="Date selected:"/>
              </mx:VBox>
      I tried putting in doubleClickEnabled as true in Actionscript, and then call the event, and this is the syntax I used:
         //enable the double Click Enabled Property
                        dch.setPropertyIsEnumerable("doubleClickEnabled",true);
                       dch.addEventListener("doubleClick", useDate2);
      This did not work, and I got this error instead: 1061: Call to a possibly undefined method setPropertyIsEnumerable through a reference with static type mx.controls:DateChooser.   
      I tried to find a suitable import statement to insert in my code, but I am not sure what to put there. Could anyone please give me a hint what to do here to get my code to accept the method?
    Thanks in advance.
    Alice

    Hi, Ryan:
      Thanks, I got that to work, but it seems like the doubleClick does not allow me to use it on the dateChooser. Here is the code:
        The MXML:
               <mx:VBox id="box2">
                <mx:DateChooser id="dch" doubleClickEnabled="true"
                      doubleClick="displayDate2()"
                      change="displayDate(DateChooser(event.target).selectedDate)"/>
             </mx:VBox>
        The same thing in Actionscript, but not working:
         dch = new DateChooser();
         dch.addEventListener("change", displayDate);
         dch.doubleClickEnabled = true;
        dch.addEventListener("doubleClick",displayDate2);
      //Got an error saying TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::MouseEvent@20112769 to     
      //mx.events.CalendarLayoutChangeEvent.
         box2.addChild(dch);
       Could you give me some pointers on what I have wrong here?
    Thanks for your help.
    Alice

  • Call to a possibly undefined method

    I am having a real problem with using two different Tile Lists in one movieClip I keep getting:
    call to a possibly undefined method trousers1
    call to a possibly undefined method trousers2
    call to a possibly undefined method trousers3
    call to a possibly undefined method trousers4
    call to a possibly undefined method trousers5
    package
    import flash.display.MovieClip;
    import flash.events.MouseEvent;
    import fl.controls.Slider;
    import fl.events.SliderEvent;
    import fl.controls.Label;
    import fl.controls.NumericStepper;
    import flash.events.Event;
    import fl.controls.TileList;
    import flash.display.DisplayObject;
    import fl.events.ListEvent;
    import flash.utils.getDefinitionByName;
    import flash.events.EventDispatcher;
    import fl.controls.SelectableList;
    public class Main extends MovieClip
       //Variables
       var startPage:StartPage;
       var tutorialPage:TutorialPage;
       var maleSizePage:MaleSizePage;
       var femaleSizePage:FemaleSizePage;
       var maleDragDropPage:MaleDragDropPage;
       var femaleDragDropPage:FemaleDragDropPage;
       var objTShirt:Object={};
       var objTrouser:Object={};
       //clothes variables
       var tshirt1:tShirt1;
       var tshirt2:tShirt2;
       var tshirt3:tShirt3;
       var tshirt4:tShirt4;
       var trousers1:Trousers1;
       var trousers2:Trousers2;
       var trousers3:Trousers3;
       var trousers4:Trousers4;
       var trousers5:Trousers5;
       var _isDragging:Boolean;
       public function Main()
        //Pages
        startPage = new StartPage;
        tutorialPage = new TutorialPage;
        maleSizePage = new MaleSizePage;
        femaleSizePage = new FemaleSizePage;
        maleDragDropPage = new MaleDragDropPage;
        femaleDragDropPage = new FemaleDragDropPage;
        objTShirt[0+"_"+0] = new tShirt1;
        objTShirt[1+"_"+0] = new tShirt2;
        objTShirt[2+"_"+0] = new tShirt3;
        objTShirt[3+"_"+0] = new tShirt4;
        objTrouser[0+"_"+0] = new trousers1;
        objTrouser[1+"_"+0] = new trousers2;
        objTrouser[2+"_"+0] = new trousers3;
        objTrouser[3+"_"+0] = new trousers4;
        objTrouser[4+"_"+0] = new trousers5;
        _isDragging = false;
        addChild(startPage);
        //Event Listeners Buttons
        startPage.startButton.addEventListener(MouseEvent.CLICK,startButtonClick);
        tutorialPage.continueButton.addEventListener(MouseEvent.CLICK,tutorialContinueButtonClick);
        maleSizePage.continueButton.addEventListener(MouseEvent.CLICK,maleSizeContinueButtonClick);
        femaleSizePage.continueButton.addEventListener(MouseEvent.CLICK,femaleSizeContinueButtonClick);
        //Size Page Event Listeners
        maleSizePage.heightSlider.addEventListener(SliderEvent.CHANGE,heightSlChange_M);
        maleSizePage.neckSlider.addEventListener(SliderEvent.CHANGE,neckSlChange_M);
        maleSizePage.chestSlider.addEventListener(SliderEvent.CHANGE,chestSlChange_M);
        maleSizePage.waistSlider.addEventListener(SliderEvent.CHANGE,waistSlChange_M);
        maleSizePage.armSlider.addEventListener(SliderEvent.CHANGE,armSlChange_M);
        maleSizePage.legSlider.addEventListener(SliderEvent.CHANGE,legSlChange_M);
        maleSizePage.heightValue.addEventListener(Event.CHANGE,heightVChange_M);
        maleSizePage.neckValue.addEventListener(Event.CHANGE,neckVChange_M);
        maleSizePage.chestValue.addEventListener(Event.CHANGE,chestVChange_M);
        maleSizePage.waistValue.addEventListener(Event.CHANGE,waistVChange_M);
        maleSizePage.armValue.addEventListener(Event.CHANGE,armVChange_M);
        maleSizePage.legValue.addEventListener(Event.CHANGE,legVChange_M);
        femaleSizePage.heightSlider.addEventListener(SliderEvent.CHANGE,heightSlChange_F);
        femaleSizePage.bustSlider.addEventListener(SliderEvent.CHANGE,bustSlChange_F);
        femaleSizePage.hipSlider.addEventListener(SliderEvent.CHANGE,hipSlChange_F);
        femaleSizePage.armSlider.addEventListener(SliderEvent.CHANGE,armSlChange_F);
        femaleSizePage.waistSlider.addEventListener(SliderEvent.CHANGE,waistSlChange_F);
        femaleSizePage.legSlider.addEventListener(SliderEvent.CHANGE,legSlChange_F);
        //Drag and Drop page Listeners
        maleDragDropPage.menuBar.stop();
        femaleDragDropPage.menuBar.stop();
        maleDragDropPage.menuBar.topsButton.addEventListener(MouseEvent.MOUSE_DOWN,topsMenuShow_M);
        maleDragDropPage.menuBar.trousersButton.addEventListener(MouseEvent.MOUSE_DOWN,trousersMenuShow_M);
        maleDragDropPage.menuBar.shoesButton.addEventListener(MouseEvent.MOUSE_DOWN,shoesMenuShow_M);
       //Event Button handlers
       function startButtonClick(event:MouseEvent):void
        addChild(tutorialPage);
       function tutorialContinueButtonClick(event:MouseEvent):void
        if (startPage.maleSelection.selected == true)
         addChild(maleSizePage);
         removeChild(startPage);
         removeChild(tutorialPage);
        if (startPage.femaleSelection.selected == true)
         addChild(femaleSizePage);
         removeChild(startPage);
         removeChild(tutorialPage);
       function maleSizeContinueButtonClick(event:MouseEvent):void
        addChild(maleDragDropPage)
        removeChild(maleSizePage)
       function femaleSizeContinueButtonClick(event:MouseEvent):void
        addChild(femaleDragDropPage)
        removeChild(femaleSizePage)
       // slider handlers
       function heightSlChange_M(event:SliderEvent):void
        maleSizePage.heightValue.value = maleSizePage.heightSlider.value;
        maleSizePage.maleCharacter.height = maleSizePage.heightSlider.value + 280;
       function neckSlChange_M(event:SliderEvent):void
        maleSizePage.neckValue.value = maleSizePage.neckSlider.value;
        maleSizePage.maleCharacter.neck.width = maleSizePage.neckSlider.value + 40;
       function chestSlChange_M(event:SliderEvent):void
        maleSizePage.chestValue.value = maleSizePage.chestSlider.value;
        maleSizePage.maleCharacter.chest.width = maleSizePage.chestSlider.value + 141;
       function waistSlChange_M(event:SliderEvent):void
        maleSizePage.waistValue.value = maleSizePage.waistSlider.value;
        maleSizePage.maleCharacter.waist.width = maleSizePage.waistSlider.value + 140;
       function armSlChange_M(event:SliderEvent):void
        maleSizePage.armValue.value = maleSizePage.armSlider.value;
        maleSizePage.maleCharacter.leftArm.height = maleSizePage.armSlider.value + 180;
        maleSizePage.maleCharacter.rightArm.height = maleSizePage.armSlider.value + 180;
       function legSlChange_M(event:SliderEvent):void
        maleSizePage.legValue.value = maleSizePage.legSlider.value;
        maleSizePage.maleCharacter.rightLeg.height = maleSizePage.legSlider.value + 250;
        maleSizePage.maleCharacter.leftLeg.height = maleSizePage.legSlider.value +250;
       function heightVChange_M(e:Event):void
        maleSizePage.heightSlider.value = maleSizePage.heightValue.value;
        maleSizePage.maleCharacter.height = maleSizePage.heightValue.value + 280;
       function neckVChange_M(e:Event):void
        maleSizePage.neckSlider.value = maleSizePage.neckValue.value;
        maleSizePage.maleCharacter.neck.width = maleSizePage.neckValue.value + 40;
       function chestVChange_M(e:Event):void
        maleSizePage.chestSlider.value = maleSizePage.chestValue.value;
        maleSizePage.maleCharacter.chest.width = maleSizePage.chestValue.value + 141;
       function waistVChange_M(e:Event):void
        maleSizePage.waistSlider.value = maleSizePage.waistValue.value;
        maleSizePage.maleCharacter.waist.width = maleSizePage.waistValue.value + 140
       function armVChange_M(e:Event):void
        maleSizePage.armSlider.value = maleSizePage.armValue.value;
        maleSizePage.maleCharacter.leftArm.height = maleSizePage.armValue.value + 180;
        maleSizePage.maleCharacter.rightArm.height = maleSizePage.armValue.value + 180;
       function legVChange_M(e:Event):void
        maleSizePage.legSlider.value = maleSizePage.legValue.value;
        maleSizePage.maleCharacter.leftLeg.height = maleSizePage.legValue.value + 240;
        maleSizePage.maleCharacter.rightLeg.height = maleSizePage.legValue.value + 240;
       function heightSlChange_F(e:Event):void
        femaleSizePage.heightValue.value = femaleSizePage.heightSlider.value;
        femaleSizePage.femaleCharacter.height = femaleSizePage.heightSlider.value + 250;
       function bustSlChange_F(e:Event):void
        femaleSizePage.bustValue.value = femaleSizePage.bustSlider.value;
        femaleSizePage.femaleCharacter.chest.width = femaleSizePage.bustSlider.value + 150;
       function waistSlChange_F(event:SliderEvent):void
        femaleSizePage.waistValue.value = femaleSizePage.waistSlider.value;
        femaleSizePage.femaleCharacter.waist.width = femaleSizePage.waistSlider.value + 140;
       function armSlChange_F(event:SliderEvent):void
        femaleSizePage.armValue.value = femaleSizePage.armSlider.value;
        femaleSizePage.femaleCharacter.leftArm.height = femaleSizePage.armSlider.value + 180;
        femaleSizePage.femaleCharacter.rightArm.height = femaleSizePage.armSlider.value + 180;
       function legSlChange_F(event:SliderEvent):void
        femaleSizePage.legValue.value = femaleSizePage.legSlider.value;
        femaleSizePage.femaleCharacter.rightLeg.height = femaleSizePage.legSlider.value + 250;
        femaleSizePage.femaleCharacter.leftLeg.height = femaleSizePage.legSlider.value +250;
       function hipSlChange_F(event:SliderEvent):void
        femaleSizePage.hipValue.value = femaleSizePage.hipSlider.value;
        femaleSizePage.femaleCharacter.hips.width = femaleSizePage.hipSlider.value + 160;
       function heightVChange_F(e:Event):void
        femaleSizePage.heightSlider.value = femaleSizePage.heightValue.value;
        femaleSizePage.femaleCharacter.height = femaleSizePage.heightValue.value + 280;
       function bustVChange_F(e:Event):void
        femaleSizePage.bustSlider.value = femaleSizePage.bustValue.value;
        femaleSizePage.femaleCharacter.chest.width = femaleSizePage.bustValue.value + 150;
       function hipsVChange_F(e:Event):void
        femaleSizePage.hipSlider.value = femaleSizePage.hipValue.value;
       function waistVChange_F(e:Event):void
        femaleSizePage.waistSlider.value = femaleSizePage.waistValue.value;
        femaleSizePage.femaleCharacter.waist.width = femaleSizePage.waistValue.value + 140;
       function armVChange_F(e:Event):void
        femaleSizePage.armSlider.value = femaleSizePage.armValue.value;
        femaleSizePage.femaleCharacter.leftArm.height = femaleSizePage.armValue.value + 180;
        femaleSizePage.femaleCharacter.rightArm.height = femaleSizePage.armValue.value + 180
       function legVChange_F(e:Event):void
        femaleSizePage.legSlider.value = femaleSizePage.legValue.value;
        femaleSizePage.femaleCharacter.rightLeg.height = femaleSizePage.legValue.value + 250;
        femaleSizePage.femaleCharacter.leftLeg.height = femaleSizePage.legValue.value +250;
       //Drag and Drop handlers
       function topsMenuShow_M(event:MouseEvent):void
        maleDragDropPage.menuBar.gotoAndStop(2);
        maleDragDropPage.menuBar.maleTops.addEventListener(ListEvent.ITEM_CLICK,addTshirt1_M)
       function trousersMenuShow_M(event:MouseEvent):void
        maleDragDropPage.menuBar.gotoAndStop(3);
        maleDragDropPage.menuBar.maleTrousers.addEventListener(ListEvent.ITEM_CLICK,addTrousers1_M)
       function shoesMenuShow_M(event:MouseEvent):void
        maleDragDropPage.menuBar.gotoAndStop(4);
       function addTshirt1_M(event:ListEvent):void
        trace(event.rowIndex,event.columnIndex)
        if (contains(objTShirt[0+"_"+0]))
         removeChild(objTShirt[0+"_"+0]);
        if (contains(objTShirt[1+"_"+0]))
         removeChild(objTShirt[1+"_"+0]);
        if (contains(objTShirt[2+"_"+0]))
         removeChild(objTShirt[2+"_"+0]);
        if (contains(objTShirt[3+"_"+0]))
         removeChild(objTShirt[3+"_"+0]);
        addChild(objTShirt[event.rowIndex+"_"+event.columnIndex] as DisplayObject).addEventListener(MouseEvent.MOUSE_DOWN,tShirtDragPickup);
       function tShirtDragPickup(event:Event):void
        var currentDragObject:MovieClip = event.currentTarget as MovieClip;
        currentDragObject.startDrag();
        setChildIndex(currentDragObject, numChildren-1);
        _isDragging = true;
        currentDragObject.addEventListener(MouseEvent.MOUSE_UP, tShirtDragDrop);
       function tShirtDragDrop(event:Event):void
        var currentDragObject:MovieClip = event.currentTarget as MovieClip;
        currentDragObject.stopDrag();
        _isDragging = false;
        currentDragObject.removeEventListener(MouseEvent.MOUSE_UP, tShirtDragDrop);
       function tShirtTarget(event:Event):void
        if (maleDragDropPage.objTShirt[0+"_"+0].hitTestObject(maleDragDropPage.maleCharacter.chest))
         if (! _isDragging)
          maleDragDropPage.objTShirt[0+"_"+0].x = maleDragDropPage.maleCharacter.chest.x;
          maleDragDropPage.objTShirt[0+"_"+0].y = maleDragDropPage.maleCharacter.chest.y;
        if (maleDragDropPage.objTShirt[1+"_"+0].hitTestObject(maleDragDropPage.maleCharacter.chest))
         if (! _isDragging)
          maleDragDropPage.objTShirt[1+"_"+0].x = maleDragDropPage.maleCharacter.chest.x;
          maleDragDropPage.objTShirt[1+"_"+0].y = maleDragDropPage.maleCharacter.chest.y;
        if (maleDragDropPage.objTShirt[2+"_"+0].hitTestObject(maleDragDropPage.maleCharacter.chest))
         if (! _isDragging)
          maleDragDropPage.objTShirt[2+"_"+0].x = maleDragDropPage.maleCharacter.chest.x;
          maleDragDropPage.objTShirt[2+"_"+0].y = maleDragDropPage.maleCharacter.chest.y;
        if (maleDragDropPage.objTShirt[3+"_"+0].hitTestObject(maleDragDropPage.maleCharacter.chest))
         if (! _isDragging)
          maleDragDropPage.objTShirt[3+"_"+0].x = maleDragDropPage.maleCharacter.chest.x;
          maleDragDropPage.objTShirt[3+"_"+0].y = maleDragDropPage.maleCharacter.chest.y;
       function addTrousers1_M(event:ListEvent):void
        trace(event.rowIndex,event.columnIndex)
        if (contains(objTrouser[0+"t"+0]))
         removeChild(objTrouser[0+"t"+0]);
        if (contains(objTrouser[1+"t"+0]))
         removeChild(objTrouser[1+"t"+0]);
        if (contains(objTrouser[2+"t"+0]))
         removeChild(objTrouser[2+"t"+0]);
        if (contains(objTrouser[3+"t"+0]))
         removeChild(objTrouser[3+"t"+0]);
        if (contains(objTrouser[4+"t"+0]))
         removeChild(objTrouser[4+"t"+0]);
        addChild(objTrouser[event.rowIndex+"t"+event.columnIndex] as DisplayObject).addEventListener(MouseEvent.MOUSE_DOWN,trouserDragPickup);
       function trouserDragPickup(event:Event):void
        var currentDragObject:MovieClip = event.currentTarget as MovieClip;
        currentDragObject.startDrag();
        setChildIndex(currentDragObject, numChildren-1);
        _isDragging = true;
        currentDragObject.addEventListener(MouseEvent.MOUSE_UP, trouserDragDrop);
       function trouserDragDrop(event:Event):void
        var currentDragObject:MovieClip = event.currentTarget as MovieClip;
        currentDragObject.stopDrag();
        _isDragging = false;
        currentDragObject.removeEventListener(MouseEvent.MOUSE_UP, trouserDragDrop);
       function trouserTarget(event:Event):void
        if (maleDragDropPage.objTrouser[0+"_"+0].hitTestObject(maleDragDropPage.maleCharacter.waist))
         if (! _isDragging)
          maleDragDropPage.objTrouser[0+"_"+0].x = maleDragDropPage.maleCharacter.waist.x;
          maleDragDropPage.objTrouser[0+"_"+0].y = maleDragDropPage.maleCharacter.waist.y;
        if (maleDragDropPage.objTrouser[1+"_"+0].hitTestObject(maleDragDropPage.maleCharacter.waist))
         if (! _isDragging)
          maleDragDropPage.objTrouser[1+"_"+0].x = maleDragDropPage.maleCharacter.waist.x;
          maleDragDropPage.objTrouser[1+"_"+0].y = maleDragDropPage.maleCharacter.waist.y;
        if (maleDragDropPage.objTrouser[2+"_"+0].hitTestObject(maleDragDropPage.maleCharacter.chest))
         if (! _isDragging)
          maleDragDropPage.objTrouser[2+"_"+0].x = maleDragDropPage.maleCharacter.chest.x;
          maleDragDropPage.objTrouser[2+"_"+0].y = maleDragDropPage.maleCharacter.chest.y;
        if (maleDragDropPage.objTShirt[3+"_"+0].hitTestObject(maleDragDropPage.maleCharacter.chest))
         if (! _isDragging)
          maleDragDropPage.objTrouser[3+"_"+0].x = maleDragDropPage.maleCharacter.chest.x;
          maleDragDropPage.objTrouser[3+"_"+0].y = maleDragDropPage.maleCharacter.chest.y;

    You are trying to assign undefined instances of class objects rather than define them...
        objTrouser[0+"_"+0] = new trousers1;
        objTrouser[1+"_"+0] = new trousers2;
        objTrouser[2+"_"+0] = new trousers3;
        objTrouser[3+"_"+0] = new trousers4;
        objTrouser[4+"_"+0] = new trousers5;
    should be
        objTrouser[0+"_"+0] = new Trousers1();
        objTrouser[1+"_"+0] = new Trousers2();
        objTrouser[2+"_"+0] = new Trousers3();
        objTrouser[3+"_"+0] = new Trousers4();
        objTrouser[4+"_"+0] = new Trousers5();
    and I didn't look deeper to see why you aren't creating the instances you declared (trousers1, etc) instead of objTrouser[0+"_"+0] etc.

  • 1180: Call to a possibly undefined method... Possibly?

    I have buttons, that when clicked will create an instance in one of 3 movie clips within a movie clip.
    For instance, this works just fine:
    b_IF_4G5_TOP.addEventListener(MouseEvent.CLICK, b_IF_4G5_TOP_add);
    function b_IF_4G5_TOP_add(event:MouseEvent):void
    var b:MovieClip = new IF_4G5_TOP();
    b.name = "IF_4G5_TOP";
    layout.substrate.addChild(b);
    but this does not:
    p_conn_h.addEventListener(MouseEvent.CLICK, p_conn_h_add);
    function p_conn_h_add(event:MouseEvent):void
    var b:MovieClip = new PC_H(); <- This line produces this error: 1180: Call to a possibly undefined method PC_H.
    b.name = "p_conn";
    layout.connectors.addChild(b);
    Which is odd, because as you can see in the first example, I have not "defined" var b:MovieClip = new IF_4G5_TOP();
    Both objects exist in the library, are movie clips, both targets and objects are accuratley named and exist.
    Am I missing something obvious? Thanks in advance for your help.

    Thanks for the suggestions, guys.
    I did try renaming the movieclips, no success.
    The movieclips that work fine, like IF_4G5_TOP have no as linkage or anything. The code simply places a copy of the movieclip from the library onto the stage within its target movieclip.
    I even tried to change their target to the same target as the ones that work:
    layout.connectors.addChild(b);
    to
    layout.substrate.addChild(b);
    But no go...
    Why do you suppose an identical function would work in one case, but throw errors in another? It's seemingly irrational inconsistencies like this that are so frustrating about actionscript.
    Any ideas? Thanks again.

  • Using Click Functions Inside ItemRenderers Causing "Undefined Method" error

    I have a tilelist which has an item renderer and the item renderer has a small button in it which intentionally should remove the specific item once the button is clicked making each item removable from the tilelist by clicking the little button on each item within the tilelist. However when I try to apply my removeProduct() function, which I've already defined, to the button I get the error "Call to a possibly undefined method" but this function can be applied to other buttons fine so I know it has been defined correctly. It just seems to throw this error when I try to apply it to the button inside the itemrenderer of my tilelist. Anyone else had this problem? Is it to do with it being within a item renderer?
    Here's my code for the function:-
    public function removeProduct():void { 
    var item:Object = cartTilelist.selectedItem; 
    var idx:int = shoppingCartAC.getItemIndex(item);shoppingCartAC.removeItemAt(idx);

    forst create custom Event:
    public class MyItemEvent extends Event
            public static const MY_ITEM_REMOVE:String = "MyItemEventRemove";
            private var _myItemClicked:Object;
            public function get myItem() : Object{
                return this._myItemClicked;
            public function MyItemEvent(type:String,itemParam:Object, bubbles:Boolean=true, cancelable:Boolean=false)
                super(type, bubbles, cancelable);
                this._myItemClicked = itemParam;
            override public function clone():Event{
                return new MyItemEvent(this.type,this._myItemClicked,this.bubbles,this.cancelable); // bubbling support inside
    inside you Item renderer create util function (you dont have to, but its cleaner) :
    private function removeItem() : void {
                    this.dispatchEvent(new MyItemEvent (MyItemEvent .MY_ITEM_REMOVE,this.data,true,true));
    and then third step (again inside Item renderer)  asign that function as click event handler to button:
    <mx:LinkButton id="removeButton" label="X" fontSize="8"  paddingLeft="0" paddingRight="0" paddingTop="0" paddingBottom="0" cornerRadius="6" color="#FF0000" click="removeItem()"  x="1" y="-2"/>
    now wherever you have your  tilelist add listiner to it following way , (or any other way you find it fit )
    yourTileListComponent.addEventListener(MyItemEvent .MY_ITEM_REMOVE,
                         function(e:MyItemEvent):void
                            trace(this + "ItemTo Remove is: " + e.myItem);

  • Error 1180 : undefined method stop and gotoAndStop

    Error 1180 : undefined method stop and gotoAndStop
    i don't know why
    Here ,, it's my code is file [.as] and i use as3
    package {
              import flash.display.*;
              import flash.events.*;
              import flash.text.*;
              import flash.utils.Timer;
              import flash.media.Sound;
        import flash.media.SoundChannel;
              import flash.net.URLRequest;
              public class MemoryGame extends Sprite {
                        static const numLights:uint = 5;
                        private var lights:Array; // list of light objects
                        private var playOrder:Array; // growing sequence
                        private var repeatOrder:Array;
                        // timers
                        private var lightTimer:Timer;
                        private var offTimer:Timer;
                        var gameMode:String; // play or replay
                        var currentSelection:MovieClip = null;
                        var soundList:Array = new Array(); // hold sounds
                        public function MemoryGame() {
                                  //soundBG.load(new URLRequest("soundBG.mp3"));
                                  //soundBG.addEventListener(Event.COMPLETE,loadSoungBgComplete);
                                  stop();
                                  StartBtn.addEventListener(MouseEvent.CLICK, clickStart);
                                  function clickStart(e:MouseEvent){
                                            gotoAndStop("startPage");
                                  // load the sounds
                                  soundList = new Array();
                                  for(var i:uint=1;i<=5;i++) {
                                            var thisSound:Sound = new Sound();
                                            var req:URLRequest = new URLRequest("note"+i+".mp3");
                                            thisSound.load(req);
                                            soundList.push(thisSound);
                                  // make lights
                                  lights = new Array();
                                  for(i=0;i<numLights;i++) {
                                            var thisLight:Light = new Light();
                                            thisLight.lightColors.gotoAndStop(i+1); // show proper frame
                                            thisLight.x = i*90+100; // position
                                            thisLight.y = 175;
                                            thisLight.lightNum = i; // remember light number
                                            lights.push(thisLight); // add to array of lights
                                            addChild(thisLight); // add to screen
                                            thisLight.addEventListener(MouseEvent.CLICK,clickLight); // listen for clicks
                                            thisLight.buttonMode = true;
                                  // reset sequence, do first turn
                                  playOrder = new Array();
                                  gameMode = "play";
                                  nextTurn();
                        // add one to the sequence and start
                        public function nextTurn() {
                                  // add new light to sequence
                                  var r:uint = Math.floor(Math.random()*numLights);
                                  playOrder.push(r);
                                  // show text
                                  textMessage.text = "Watch and Listen.";
                                  textScore.text = "Sequence Length: "+playOrder.length;
                                  // set up timers to show sequence
                                  lightTimer = new Timer(1000,playOrder.length+1);
                                  lightTimer.addEventListener(TimerEvent.TIMER,lightSequence);
                                  // start timer
                                  lightTimer.start();
                        // play next in sequence
                        public function lightSequence(event:TimerEvent) {
                                  // where are we in the sequence
                                  var playStep:uint = event.currentTarget.currentCount-1;
                                  if (playStep < playOrder.length) { // not last time
                                            lightOn(playOrder[playStep]);
                                  } else { // sequence over
                                            startPlayerRepeat();
                        // start player repetion
                        public function startPlayerRepeat() {
                                  currentSelection = null;
                                  textMessage.text = "Repeat.";
                                  gameMode = "replay";
                                  repeatOrder = playOrder.concat();
                        // turn on light and set timer to turn it off
                        public function lightOn(newLight) {
                                  soundList[newLight].play(); // play sound
                                  currentSelection = lights[newLight];
                                  currentSelection.gotoAndStop(2); // turn on light
                                  offTimer = new Timer(500,1); // remember to turn it off
                                  offTimer.addEventListener(TimerEvent.TIMER_COMPLETE,lightOff);
                                  offTimer.start();
                        // turn off light if it is still on
                        public function lightOff(event:TimerEvent) {
                                  if (currentSelection != null) {
                                            currentSelection.gotoAndStop(1);
                                            currentSelection = null;
                                            offTimer.stop();
                        // receive mouse clicks on lights
                        public function clickLight(event:MouseEvent) {
                                  // prevent mouse clicks while showing sequence
                                  if (gameMode != "replay") return;
                                  // turn off light if it hasn't gone off by itself
                                  lightOff(null);
                                  // correct match
                                  if (event.currentTarget.lightNum == repeatOrder.shift()) {
                                            lightOn(event.currentTarget.lightNum);
                                            // check to see if sequence is over
                                            if (repeatOrder.length == 0) {
                                                      nextTurn();
                                  // got it wrong
                                  } else {
                                            textMessage.text = "Game Over!";
                                            gameMode = "gameover";
    and i don't push any code
    at fla file
    why i got that help me plss
    that is my homework and i must send it today TT

    can you write how to use ?
    i write
    "import the flash.display.MovieClip; "
    still error ahhh
    i try to change extends MovieClip instead Spirt
    and not error stop(); and gotoAndStop Already
    but
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
              at MemoryGame/nextTurn()
              at MemoryGame/clickStart()
    i got thissssssss TT
    import flash.display.Sprite;
    import flash.events.*;
    import flash.text.*;
    import flash.utils.Timer;
    import flash.media.Sound;
    import flash.media.SoundChannel;
    import flash.net.URLRequest;
    import flash.display.MovieClip;
    that i import

  • ActionScript 3 Noob Help - 1180: Call to a possibly undefined method addChild.

    Hey everyone, i'm in the process of learning ActionScript 3. I'm woking on my first OOP game with a class other than the document class.
    Right now, my game has a preloader library symbol called PreLoader and one called MainMenu (they have been exported for actionscript). All other objects are subobjects of these Movie Clips. My code si split into three actionscript files called Main.as (the document class. I had planned this to load and unload the preloader, mainmenu, and game itself) MainMenu.as (meant to controll the main menu's buttons and listeners) and PreLoader.as (which has the pre-Loader code in it.) I was having a lot of trouble with unloading the main menu and preloader after I was finished with them, so I let the document class handle them, which led to a series of errors as follows:
    C:\Users\...\hamletgame\Main.as, Line 19    1120: Access of undefined property mainMenu.
    C:\Users\...\hamletgame\Main.as, Line 20    1180: Call to a possibly undefined method addChild.
    C:\Users\...\hamletgame\Main.as, Line 20    1120: Access of undefined property mainMenu.
    C:\Users\...\hamletgame\Main.as, Line 21    1180: Call to a possibly undefined method removeChild.
    C:\Users\...\hamletgame\Main.as, Line 21    1120: Access of undefined property preLoader.
    C:\Users\...\hamletgame\Main.as, Line 25    1180: Call to a possibly undefined method removeChild.
    C:\Users\...\hamletgame\Main.as, Line 25    1120: Access of undefined property mainMenu.
    Thank you all very much in advance. I'm sure its something simple i've missed. My code is posted below.
    Main.as
    package
        import flash.display.MovieClip;
        import flash.events.Event;
        import flash.events.MouseEvent;
        public class Main extends MovieClip
            var preLoader:PreLoader;
            var mainMenu:MainMenu;
            public function Main()
                preLoader = new PreLoader;
                addChild(preLoader);
            static public function loadMainMenu():void
                mainMenu = new MainMenu();
                addChild(mainMenu);
                removeChild(preLoader);
            static public function loadGame():void
                removeChild(mainMenu);
    PreLoader.as
    package
        import flash.display.MovieClip;
        import flash.events.Event;
        import flash.events.MouseEvent;
        public class PreLoader extends MovieClip
            //Declare Variables Here
            //Constructor Function
            public function PreLoader()
                gotoAndStop(1);
                addEventListener(Event.ENTER_FRAME, loading);
            //Functions
            private function loading (event:Event):void
                var total:Number = stage.loaderInfo.bytesTotal;
                var loaded:Number = stage.loaderInfo.bytesLoaded;
                loadingBar.scaleX = loaded/total;
                if(loaded==total)
                    gotoAndStop(2);
                    removeEventListener(Event.ENTER_FRAME, loading);
                    playButton.addEventListener(MouseEvent.CLICK, startMovie)
            private function startMovie (event:MouseEvent):void
                removeEventListener(MouseEvent.CLICK, startMovie);
                Main.loadMainMenu();
    MainMenu.as
    package
        import flash.display.MovieClip;
        import flash.events.Event;
        import flash.events.MouseEvent;
        public class MainMenu extends MovieClip
            //Constructor Function
            public function MainMenu()
                addEventListener(Event.ENTER_FRAME, onFrameEnter);
            //Other Functions
            private function onFrameEnter(event:Event):void
                if(currentFrame==30)
                    stop();
                    playGameButton.addEventListener(MouseEvent.CLICK, onPlayGameButtonClick);
                    instructionsButton.addEventListener(MouseEvent.CLICK, onInstructionsButtonClick);
                    creditsButton.addEventListener(MouseEvent.CLICK, onCreditsButtonClick);
                    removeEventListener(Event.ENTER_FRAME, onFrameEnter);
                else
                    removeEventListener(Event.ENTER_FRAME, onFrameEnter);
            private function onPlayGameButtonClick(event:MouseEvent):void
                playGameButton.removeEventListener(MouseEvent.CLICK, onPlayGameButtonClick);
                instructionsButton.removeEventListener(MouseEvent.CLICK, onInstructionsButtonClick);
                creditsButton.removeEventListener(MouseEvent.CLICK, onCreditsButtonClick);
                Main.loadGame();
            private function onInstructionsButtonClick(event:MouseEvent):void
                playGameButton.removeEventListener(MouseEvent.CLICK, onPlayGameButtonClick);
                instructionsButton.removeEventListener(MouseEvent.CLICK, onInstructionsButtonClick);
                creditsButton.removeEventListener(MouseEvent.CLICK, onCreditsButtonClick);
            private function onCreditsButtonClick(event:MouseEvent):void
                playGameButton.removeEventListener(MouseEvent.CLICK, onPlayGameButtonClick);
                instructionsButton.removeEventListener(MouseEvent.CLICK, onInstructionsButtonClick);
                creditsButton.removeEventListener(MouseEvent.CLICK, onCreditsButtonClick);

    I'm not sure why I'm not able to use all 3 of your classes as intended.  I read that you cannot access the Document Class from other classes directly.  So This is what I have:
    Main.as
    package
        import flash.display.MovieClip;
        import flash.events.Event;
        import flash.events.MouseEvent;
        public class Main extends MovieClip
            var preLoader:PreLoader;
            var mainMenu:MainMenu;
            public function Main()
                preLoader = new PreLoader;
                addChild(preLoader);
                                  trace("Main");
            public function loadGame():void
                                  trace("loadGame start");
                //removeChild(mainMenu);
                                  trace("loadGame finish");
    MainMenu.as
    package
        import flash.display.MovieClip;
        import flash.events.Event;
        import flash.events.MouseEvent;
        public class MainMenu extends MovieClip
            //Constructor Function
                        var playGameButton:PlayGameButton;
                        var instructionsButton:InstructionsButton;
                        var creditsButton:CreditsButton;
                        var main:Main;
                        var mainMenu:MainMenu;
                        var preLoader:PreLoader;
                        var container1_mc:MovieClip;
            public function MainMenu()
                                  trace("MainMenu");
    PreLoader.as  (this is where the heart of your app is)
    package
        import flash.display.MovieClip;
        import flash.events.Event;
        import flash.events.MouseEvent;
              import flash.display.Loader;
              import flash.display.LoaderInfo;
        public class PreLoader extends MovieClip
            //Declare Variables Here
                        var playGameButton:PlayGameButton;
                        var instructionsButton:InstructionsButton;
                        var creditsButton:CreditsButton;
            var main:Main;
                        var mainMenu:MainMenu;
                        var preLoader:PreLoader;
                        var loadingBar:LoadingBar;
                        var playsButton;
                        var container_mc:MovieClip;
            //Constructor Function
            public function PreLoader()
                gotoAndStop(1);
                addEventListener(Event.ENTER_FRAME, loading);
            //Functions
            public function loading (event:Event):void
                var total:Number = stage.loaderInfo.bytesTotal;
                var loaded:Number = stage.loaderInfo.bytesLoaded;
                                  loadingBar=new LoadingBar();
                                  addChild(loadingBar);
                                  loadingBar.x=50;
                                  loadingBar.y=50;
                                  var playsButton=new PlaysButton();
                loadingBar.scaleX = loaded/total;
                if(loaded==total)
                                            removeChild(loadingBar);
                                            //stop();
                                            trace("loaded equals total");
                    gotoAndStop(2);
                    removeEventListener(Event.ENTER_FRAME, loading);
                                            addChild(playsButton);
                                            playsButton.x=50;
                                            playsButton.y=250;
                    playsButton.addEventListener(MouseEvent.CLICK, startMovie);
            public function startMovie(event:MouseEvent):void
                //removeEventListener(MouseEvent.CLICK, startMovie);
                                  trace("startMovie");
                                  loadMainMenu();
                         public function loadMainMenu():void
                        var main:Main;
                        var mainMenu:MainMenu;
                        var preLoader:PreLoader;
                        var container1_mc:MovieClip;
                                  trace(currentFrame+"cf");
                                  trace("loadMainMenu start");
                                  container1_mc= new MovieClip();
                                  addChild(container1_mc);
                                  playGameButton=new PlayGameButton();
                                  trace("1");
                                  instructionsButton= new InstructionsButton();
                                  creditsButton = new CreditsButton();
                                  playGameButton.x=100;
                                            playGameButton.y=100;
                                            instructionsButton.x=200;
                                            instructionsButton.y=100;
                                            creditsButton.x=300;
                                            creditsButton.y=100;
                                            trace(creditsButton.name);
                                            trace(creditsButton.x);
                                            trace(creditsButton.y);
                                            trace(container1_mc.x);
                                            trace(container1_mc.y);
                                  addChild(playGameButton);
                                  playGameButton.name="playGameButton";
                                  instructionsButton.name="instructionsButton";
                                  creditsButton.name="creditsButton";
                                  trace(creditsButton.name);
                                  trace("2");
                                            addChild(instructionsButton);
                                            addChild(creditsButton);
                                  trace("loadMainMenu finish");
                                  MainMenus();
                        public function MainMenus():void
                addEventListener(Event.ENTER_FRAME, onFrameEnter);
                                  trace("MainMenus");
                                  //loadMainMenu();
            public function onFrameEnter(event:Event):void
                                  trace("AA");
                if(currentFrame==0)
                                            if(creditsButton.name=="creditsButton"){
                    stop();
                                            trace("frame 30");
                                            trace(currentFrame);
                                            trace(creditsButton.name);
                    playGameButton.addEventListener(MouseEvent.CLICK, onPlayGameButtonClick);
                    instructionsButton.addEventListener(MouseEvent.CLICK, onInstructionsButtonClick);
                    creditsButton.addEventListener(MouseEvent.CLICK, onCreditsButtonClick);
                    removeEventListener(Event.ENTER_FRAME, onFrameEnter);
                else
                    removeEventListener(Event.ENTER_FRAME, onFrameEnter);
            public function onPlayGameButtonClick(event:MouseEvent):void
                                  trace("A");
                playGameButton.removeEventListener(MouseEvent.CLICK, onPlayGameButtonClick);
                instructionsButton.removeEventListener(MouseEvent.CLICK, onInstructionsButtonClick);
                creditsButton.removeEventListener(MouseEvent.CLICK, onCreditsButtonClick);
                //main.loadGame();
            public function onInstructionsButtonClick(event:MouseEvent):void
                                  trace("B");
                playGameButton.removeEventListener(MouseEvent.CLICK, onPlayGameButtonClick);
                instructionsButton.removeEventListener(MouseEvent.CLICK, onInstructionsButtonClick);
                creditsButton.removeEventListener(MouseEvent.CLICK, onCreditsButtonClick);
            public function onCreditsButtonClick(event:MouseEvent):void
                                  trace("C");
                playGameButton.removeEventListener(MouseEvent.CLICK, onPlayGameButtonClick);
                instructionsButton.removeEventListener(MouseEvent.CLICK, onInstructionsButtonClick);
                creditsButton.removeEventListener(MouseEvent.CLICK, onCreditsButtonClick);
    I've exported each button and movie clip which resides on the stage in the Library.  I've removed them from the stage/Timeline and just have the Exports in ActionScript on Frame 1.  I also noticed I couldn't access frame 30 and had to change the code to "if(currentFrame==0)....."
    I hope this gets you started in the right direction though I'm not sure what I've done is what you're looking for.

  • Undefined method addChild

    Greetings,
    I am an AS3 and OOP newbie.  I'm trying to make an instance of a button appear on the stage when I click another button.  I've placed the code to do so in an .as file.  However, when I try to compile, I get the following message:  MenuButtons.as, Line 17    |    1180:Call to a possibly undefined method addChild    |    addChild(loggingInBtn).
    Here is the code from the .as file:
    package {
         import flash.display.SimpleButton;
         import flash.events.MouseEvent;
         import flash.display.*;
         public class MenuButtons extends SimpleButton {
         public function MenuButtons() {
              this.addEventListener(MouseEvent.CLICK, showTasks);
         private function showTasks(Event:MouseEvent):void
              var loggingInBtn = new btn_logging_in();
              addChild(loggingInBtn);
    Any thoughts as to what mindless rookie mistake I've made?  I welcome and appreciate any help.
    Mike

    I did the steps (and named the new library object mc_logging_in) and now the code looks like this:
    package {
         import flash.display.MovieClip;
         import flash.events.MouseEvent;
         import flash.display.*;
         public class MenuButtons() {
              trace("The MenuButtons function and the MenuButtons class are working");
              this.addEventListener(MouseEvent.CLICK, showTasks);
         private function showTasks(Event:MouseEvent):void
              trace("The showTasks custom method is working");
              var loggingInMc = new mc_logging_in();
              trace(loggingInMc);
              addChild(loggingInMc);
    I must have done something funky because the functions aren't running (no trace statements), and when I run the .swf I get the error message:
    MenuButtons.as, Line 15     1180:Call to a possibly undefined method mc_logging in.     var loggingInMc = new mc_logging_in();
    Sorry about my cluelessness.  Not sure where to go from here....
    Mike

  • Windows 8.1 and IE11 - Critical Error: Object doesn't support property or method 'addEventListener'

    Our SharePoint 2010 sites don't work very well in Windows 8.1/IE11!!
    When opening list items or forms etc we get Critical Error : Object doesn't support property or method 'addEventListener'. It looks like it's possibly linked to InfoPath forms. Given that a large chunk of our users will probably be upgrading
    to Windows 8.1 as we speak this is slightly worrying!
    Has anyone else noticed this, or is it something to do with our deployment?  We're running SP2010 SP2 with latest CU.

    In older versions of IE, attachEvent is
    used to attach an event handler for some event on some element. But as per the update , starting with IE11, attachEvent is
    deprecated and you should use addEventListener instead.
    IE has included support for addEventListener from
    IE9 and above only. So if you still need to support IE8, I suggest you use some cross-browser library like jQuery to bind event handlers instead of vanilla javascript.
    As you're already using jQuery, you can bind events like below
    $('#yourElement').on('click', function(){
    // do something when you click on yourElement

  • Access of undefined method/property through reference with a static type Class

    I get the following error: (it's not word for word but you get the idea)
    Error: Access of undefined method getStatus through reference with a static type Class.
    Here's what's happening in the code. I'm trying to create a User class that is instantiated at the start of my app. I want the User class to have properties like mainStatus, with helper methods like setStatus etc. Pretty simple.
    so on my HardDisk I have my flash_working folder with all my flash projects. I created my class file/package under the directory com.mypackage
    package com.mypackage
        import flash.display.*;
        public class User extends Sprite
            public var mainStatus:int;
            public function User()
                trace("User Created!");
                mainStatus = 0;
            public function setStatus(status:int):void
             mainStatus = status;
        public function getStatus():int
            return mainStatus;
    Ok, so far so good.
    now I created a new .fla file under the root of /flash_working/. The class file is in /com/mypackage/User.as
    in my .fla file I have:
    import com.mypackage.User;
    var myUser:User = new User();
    var i = User.getStatus();
    trace(i);
    That's all the code I have. Could someone please explain why it's giving me that error?
    If I try to access the public var mainStatus through user.mainStatus that gives a similar error saying:
    Error: Access of undefined property mainStatus through reference with a static type Class.
    Thanks for any help!
    jef3189

    the public getStatus() function that you created needs to be referred to through an instance of the class.
    So:
    import com.mypackage.User;
    var myUser:User = new User();
    var i = myUser.getStatus();
    trace(i);
    Also, an aside. You can create a getter/setter for status, to avoid having to do the function as such.
    package com.mypackage
        import flash.display.*;
        public class User extends Sprite
            public var mainStatus:int;
            public function get status():int
                return mainStatus;
            public function set status(value:int):void
                 mainStatus = value as int;
              public function User()
                trace("User Created!");
                mainStatus = 0;
    And then, you can call it as:
    import com.mypackage.User;
    var myUser:User = new User();
    trace(myUser.status);
    EDIT
    I just noticed that you made the variable public as well, which means you can access it without getter/setter or function.
    import com.mypackage.User;
    var myUser:User = new User();
    trace(myUser.mainStatus);

  • Call to a possibly undefined method getClipboardContents through a reference with static type flashx.textLayout.edit:ISelectionManager.

    Hi Guys,
    As i am using the nigtly build of TLF 4.0.0.11073.
    I want to copy some text from the TLF, by copy operation. I am getting this type of Error.
    - Call to a possibly undefined method getClipboardContents through a reference with static type flashx.textLayout.edit:ISelectionManager.
    In the previous build, i dont use to get this type of error, but in this nightly builds i am getting this type of error.
    Can anyone help me to fix the same or any workaound.
    Thanks in advance.
    Krishna

    This functionality is still available, but it has moved. It's now in a TextClipboard class, in the same flashx.textLayout.edit package. So you should replace calls to getClipboardFormat() with TextClipboard.getContents().
    Hope this helps,
    - robin

  • Call to a possibly undefined method displays when using static function in Unit Test

    Hello!
    This has been driving me nuts. I am setting up unit tests for a static class which manages a collection of songs. This is how my unit test class looks:
    //START CODE
    package flexUnitTests {
              import com.myapp.managers.MusicManager;
              import flash.utils.Dictionary;
              import flexunit.framework.Assert;
              public class MyAppManagerTest {
                        [Before]
                        public function setUp():void {
                                  var songData:Dictionary = new Dictionary();
                                  songData["mn0012345"] = new Dictionary();
                                  songData["mn0012345"]["title"] = "All the Pretty Little Horses";
                                  songData["mn0012345"]["description"] = "by: American Traditional | Voice, Piano | 3 pages";
                                  MusicManager.setSongData(songData);
                        [Test]
                        public function test_getAuthorsBySKU():void {
                                  var expected:String = "American Traditional";
                                  var given:String = MusicManager.getAuthorsBySKU("mn0012345");
                                  Assert.assertEquals(expected, given);
    //END OF CODE
    You will notice two calls in red above. When I leave them in the code I see a variety of errors which look like this:
    "Call to a possibly undefined method '' through a reference with a static type com.myapp..."
    And
    "Access of possible undefined property '' through a reference with static type com.myapp..."
    Then, when I comment out the two lines in red above, these errors go away. Flash Builder seems really flakey to me. Often I notice that the error list varies, how can it just no longer be an error? Where did this new access error come from, in a no related part of the code, by adding or removing a function call to a static class which remains in the import statement.
    Note that the MusicManager contains no references to any of the UI mxml that is throwing these errors. It just simply loads data into a few globals and allows you to grab info.
    How is my usage of this function making foreign objects inaccessible?
    Please help!!! I am really hoping there is an answer but I have a bad feeling the answer is just that Flash Builder is flakey.

    I did some more work on the issue above. There are functions with in the MusicManager that call the UserManager to get a user's ID. When I comment out these calls then the access errors go away. Well the user manager has some calls back to mxml that tell the class that changes where made. My best guess is this is where it stems into the code that is randomly throwing errors. But, it compiles fine and runs fine on a device. Is there something with test cases which doesn't invoke the UI?

  • Ant tests: undefined method runWithFlexUnit4Runner?

    Hi all!
    I am trying to automate AIR tests that run successfully via Adobe Flash Builder 4.
    I get the following error:
      Error: Call to a possibly undefined method runWithFlexUnit4Runner through a reference with static type flexunit.flexui:FlexUnitTestRunnerUI.
        [mxmlc]
        [mxmlc]                 testRunner.runWithFlexUnit4Runner(currentRunTestSuite(), "unit_tests");
    when I run the tests from command line via: ant -v clean package.
    The part of the build.xml responsible for this is:
    <target name="test" depends="compile">
    <!-- Execute FlexUnit tests and publish reports -->
             <mxmlc
                file="${test.src.loc}/FlexUnitApplication.mxml"
                output="${bin.loc}/FlexUnitApplication.swf"
                actionscript-file-encoding="UTF-8"
                keep-generated-actionscript="true"
                incremental="false"
            >
               <load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
               <source-path path-element="${FLEX_HOME}/frameworks"/>
               <compiler.source-path path-element="${test.src.loc}"/>
               <compiler.include-libraries dir="${lib.loc}" append="true">
                <include name="pb3dlib.swc" />
                <include name="airframework.swc" />
                <include name="airglobal.swc" />
                <include name="airspark.swc" />
                <include name="applicationupdater_ui3.swc" />
                <include name="automation_airspark.swc" />
                <include name="automation_spark.swc" />
                <include name="flexunit_0.9.swc" />
                <include name="flexunit-aircilistener-4.1.0.swc" />
                <include name="flexunit-cilistener-4.1.0.swc" />
                <include name="flexunit-core-flex-4.0.0.2-sdk3.5.0.12683.swc" />
                <include name="flexunit-core-flex-4.1.0.swc" />
                <include name="flexunit-uilistener-4.1.0.swc" />
                <include name="flexunitextended.swc" />
                <include name="hamcrest-1.0.2.swc" />
                <include name="spark.swc" />
                <include name="utilities.swc" />
                <include name="flexunit.swc" />
                <include name="FlexUnitOptional.swc" />
                <include name="FlexUnitTestRunner_rb.swc" />
               </compiler.include-libraries>
            </mxmlc>
    What swc do I need to include?
    Thanks,
    --Andreea

    Andreea,
    The actual tests created by Flash Builder are fine, it is really just the main application file they create. They don't ship the source, so modifying it is difficult.
    You can, however do something like this example:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application
          xmlns:mx="http://www.adobe.com/2006/mxml"
          creationComplete="runMe()" >
    <mx:Script>
      <![CDATA[
        import compilationSuite.SuitesToRun;
        import org.flexunit.listeners.CIListener;
        import org.flexunit.runner.FlexUnitCore;
        import org.flexunit.runner.notification.async.XMLListener;
        private var core:FlexUnitCore;
        public function runMe():void {
            core = new FlexUnitCore();
            //Put this line in if you want to write the XML to disk for use in reporting or a CI server
            core.addListener(new CIListener());
            //Leaving this one in allows you to see the results in Flash Builder as well if it is open
            //Else, it will just fail and go on. The name in the quotes below is your project name
            core.addListener(new XMLListener("unit_tests"));
            //Finally, pass what you want to run to the core.run() method. This could be the result of your currentRunTestSuite() from the
            //previous code you pasted
            core.run( compilationSuite.SuitesToRun );
    ]]>
    </mx:Script>
    </mx:Application>

  • Undefined method error in custom package even with proper import

    I edited the title of this thread to be a little more descriptive about the help I need.
    The background: I have a multi-file Flash application that allows users to navigate through multiple pages (similar to a website). I realized yesterday that with each mouse click, I'm loading a page into memory, but not unloading it. After navigating through several pages, my memory really starts to take a hit. So, I want to define a custom package that loads each page and unloads the previous page.
    I've gotten as far as defining the pageLoad function, but I keep getting an error that doesn't make sense to me (unless I'm importing the wrong flash packages).
    When I test the Flash, I consistently get the following error:
    dtutils.as – 1180: Call to a possibly undefined method addChild. – addChild(pageLoader);
    Everything I have found indicates that to import the addChild method, I need to import flash.display.Sprite, which I'm doing, but I am still getting the error.
    You'll have to forgive me as I'm not extremely familiar with objects or actionscript. I'm more of a hacker, but I grasp things quickly and can build on what I've already learned. This might be obvious to others, but I can't find anything that indicates that I'm doing anything wrong with my code, so any help you can give is greatly appreciated!!
    My package code:
    package com.clientname.demo
        import flash.display.Sprite;
        import flash.display.Loader;
        import flash.events.MouseEvent;
        import flash.net.URLRequest;
        public class dtutils
            //Properties
            public var pageLoader:Loader = new Loader();
            public var pagePath:URLRequest;
            //Constructor
            public function loadPage(url:String)
                pagePath = new URLRequest(url);
                pageLoader.load(pagePath);
                addChild(pageLoader);
    I've also attempted to replace the four import lines in my package with the following 3 import lines, but I still get the same error message:
    import flash.display.*;
    import flash.events.*;
    import flash.net.*;
    The code I'm using to import my package and call the function in my flash file is:
    import com.clientname.demo.dtutils;
    dtutils.loadPage("../filepath/filename.swf");
    I appreciate any help anyone can give me.

    Thanks for the feedback. Being fairly new with actionscript (and an object approach, in general), and not being a real developer, I often struggle with naming conventions. Didn't even realize there was a specific convention for what is considered a utility and what isn't. However, I appreciate your feedback and will rename my package so that it isn't confusing to any other real developers that may need to do something with this code in the future.
    Thanks!

Maybe you are looking for