Search code examples
actionscript-3flashflash-cs6

Error in File Class?


I have a button at the stage of the name "butdin" And add him as the class : I want to when you press the Menu button in the file show Why button does not work..

package {
import flash.display.MovieClip;
import flash.system.fscommand;
import flash.media.SoundMixer;
import flash.events.Event;
import flash.display.MovieClip;
import flash.display.StageScaleMode;

import fl.display.ProLoader;

import flash.system.fscommand;

import fl.video.FLVPlayback;

import flash.display.StageAlign;
import flash.events.Event;
import flash.events.MouseEvent;

import fl.controls.List;

import flash.display.MovieClip;
import flash.display.DisplayObjectContainer;
import flash.display.SimpleButton;
import flash.display.Graphics;
import flash.display.Shape;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.display.SimpleButton;
import flash.events.MouseEvent;
import flash.display.MovieClip;

import fl.controls.Button;

import flash.display.SimpleButton;

public class butdin extends SimpleButton {
    butdin.addEventListener(MouseEvent.CLICK, sayit);
    public function sayit(e : MouseEvent) : void {
        var list : List = new List();
        list.setSize(361, 291);
        list.move(421, 254);
        var i : uint;
        for (i = 1; i < 8; i++) {
            list.addItem({label:"Track " + i});
        }
        list.addItem({label:"Track 1"});
        list.addItem({label:"Track 2"});
        list.addItem({label:"Track 3"});
        list.addItem({label:"Track 4"});
        list.addItem({label:"Track 5"});
        list.addItem({label:"Track 6"});
        list.addItem({label:"Track 7"});
        addChild(list);
    }
    list.addEventListener(Event.CHANGE, itemClick);
    public function itemClick() {
        status_txt.text = "You selected: " + event.target.selectedItem.label;
    }
}

}


Solution

  • Try always to do easy, you don't need the butdin class, and you can insert directly your list in the Stage and then create the document class of your project :

    package  {
    
        import flash.display.MovieClip;
        import flash.events.MouseEvent;
        import flash.events.Event;
    
        public class Main extends MovieClip {
    
            public function Main() {
                butdin.addEventListener(MouseEvent.CLICK, btn_on_Press);
                list.addEventListener(Event.CHANGE, list_on_Change);
            }
            private function btn_on_Press(e:MouseEvent): void {
                for (var i:int = 1; i < 8; i++){
                    list.addItem ({ label: 'Track ' + i });
                }
            }
            private function list_on_Change(e:Event): void {
                trace('You selected : ' + e.target.selectedItem.label);
            }
        }
    
    }
    

    Hope that can help.