Quantcast
Channel: Adobe Community: Message List
Viewing all articles
Browse latest Browse all 110690

AS3 show hide movie clip array items, single button.

$
0
0

Hello and please pardon my Noobdity I am teaching myself AS3 and stuck on what are obviously basics.

I have made the simplest of animations for years without using any AS3 at all, the time has come to get serious.

I do read the daylights out of all Adobe reference material now but I am stuck on this task.

 

I have 4 movie clip objects whose visibility I would like to control with two buttons.

First button will make two of these movie clips visible and the other two visible = false

Eg: Mc1 & Mc2> visible, Mc3 &Mc4> visible = false

 

The second button will perform the same function but in reverse

Eg: Mc1 & Mc2> visible = false, Mc3 & Mc4> visible

 

I have determined either correctly or incorrectly from endless reading & searching an array should be the best way to do this.

I may have to utilise the add child functionality but *shrugs I am lost atmo

I have been blundering about with the code for the first of the two simple buttons.

I am slowly starting to form a mindmap of what should be done but it is early days.

 

Here is my code and please feel free to

Latest attempt is trying to use the mouse out trigger to control the visible state of the second two movie clips.

 

var wcArray:Array = [myMovieclip1, myMovieclip2];

var acArray:Array = [myMovieclip3, myMovieclip4];

 

acComp_btn.addEventListener(MouseEvent.CLICK, _acComp); 

internal function _acComp(e:MouseEvent) : void {

    for each(var item:MovieClip in acArray) {

        item.visible = !item.visible;

     }

}

acComp_btn.addEventListener(MouseEvent.MOUSE_OUT, _wcComp);

internal function _wcComp(e:MouseEvent) : void {

    for each(var item:MovieClip in wcArray) {

        item.visible = !item.visible = false;

     }

}

 

Currently throwing error 1050: cannot assign to a non reference value.

The blue text works with the 2 acArray movie clips of course, hence the attempt to use mouse out. 

Any advice on the solution or best method to implement would be greatly appreciated.


Viewing all articles
Browse latest Browse all 110690

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>