-1

Flash says the code is on my second line, but I've done some reading and it says this error is mainly due to me trying to assign a value to a value, and I've looked back over my code, and I can't seem to find any instance of this.

Here is my code:

this.mc=new MovieClip();
addChild(mc)=("myButton1", this.DisplayOBjectContainer.numChildren());
myButton1.createEmptyMovieClip("buttonBkg", myButton1.getNextHighestDepth());

myButton1.buttonBkg.lineStyle(0, 0x820F26, 60, true, "none", "square", "round");
myButton1.buttonBkg.lineTo(120, 0);
myButton1.buttonBkg.lineTo(120, 30);
myButton1.buttonBkg.lineTo(0, 30);
myButton1.buttonBkg.lineTo(0, 0);

Thanks!

15leungjs1
  • 35
  • 8

2 Answers2

0

Check what you are trying to in these lines:

 addChild(mc)=("myButton1", this.DisplayOBjectContainer.numChildren());
 myButton1.createEmptyMovieClip("buttonBkg", myButton1.getNextHighestDepth());

To create an empty MovieClip, you can just create a new display object w/o linking it to a clip in the library like this:

 addChild(mc);
 var myButton1:MovieClip = new MovieClip(); // creates an empty MovieClip
 addChildAt(myButton1, numChildren); // adds the MovieClip at a defined level (on this case, the numChildren added on stage
gabriel
  • 2,351
  • 4
  • 20
  • 23
  • I'm trying to create a new movie clip with the name 'myButton1' and to tell it to go to the next greatest depth – 15leungjs1 Sep 11 '14 at 06:54
0

Your code is very confusing. You mix AS2 methods (createEmptyMovieClip, getNextHighestDepth) with AS3 methods (addChild). Here is what you are trying to do:

const MC:Sprite = new Sprite(); // Sprite container
this.addChild(MC);

const MYBUTTON1:Sprite = new Sprite(); // button in container
MC.addChild(MYBUTTON1);

const BUTTONBKG:Shape = new Shape(); // background in button
MYBUTTON1.addChild(BUTTONBKG);
const BTG:* = BUTTONBKG.graphics;

BTG.beginFill(0x86B1FB);
BTG.lineStyle(0, 0x820F26, 0.6, true, "none", "square", "round");
BTG.lineTo(120, 0);
BTG.lineTo(120, 30);
BTG.lineTo(0, 30);
BTG.lineTo(0, 0);

MYBUTTON1.addEventListener(MouseEvent.CLICK, pressButton);

function pressButton(e:MouseEvent):void {
    trace('I click on you');
}

Notes : the alpha value in AS3 is between 0 and 1. If you want your button to be clickable, you should use beginfill method.

helloflash
  • 2,457
  • 2
  • 15
  • 19