Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

simple add child issue

Explorer ,
Feb 14, 2014 Feb 14, 2014

stupidly i try to add child mc "green" to "scroll_mc", but green is not visible.

package {

          import fl.containers.ScrollPane;

          import fl.controls.ScrollPolicy;

          import flash.desktop.NativeApplication;

          import flash.desktop.SystemIdleMode;

          import flash.display.MovieClip;

          import flash.media.Video;

          import flash.net.NetConnection;

          import flash.net.NetStream;

          import flash.events.MouseEvent;

          import flash.events.NetStatusEvent;

          import fl.controls.List

          import flash.events.Event;

                    public class Main extends MovieClip {

                              private var song:Array=["lego.flv","hatizmoret.flv","shir_hageshem.flv","ez.flv","tarnegol.flv","se_ugdi.flv","dag.flv","lizard.flv","toy_train_set_qt.flv","hadubim.flv","geveret_shfanfana.flv",

                                                                                                    "parash_ben_hail.flv","snake.flv","pil_pilon.flv","cat.flv","gan_shelanu.flv","purrfect_birthday_qt.flv","nadneda.flv","hatul_ganav.flv",

                                                                                                    "yonatan_hakatan.flv","dog.flv","aviron.flv","zipor.flv","hipo.flv","ladod_moshe.flv","shafan.flv","hipushit.flv","achbar.flv","tolaat.flv","zefardea.flv","dov.flv",

                                                                                                    "shaon_ben_hail.flv","kof.flv","hayom_yom_huledet.flv","ima_yekara.flv","oniya.flv","bee_and_flowers_qt.flv ","hasida.flv","ima_avaza.flv","yedidi_tintan.flv","donkey.flv",

                                                                                                    "haoto_shelanu.flv","bimdinat_hagamadim.flv"]

 

 

                    public var song_number:String

                    private var netConnection:NetConnection;

                    private var netStream:NetStream;

                    private var video:Video;

                    private var VIDEO_URL:String;

                    public var speed:Number;

  public var speedArray:Array;

  public var prevY:Number;

                    public var DRAG:Number = 20;

                    public var HEIGHT:int = 310;

 

 

 

                    public function Main() {

                              public var scroll_mc:MovieClip

                              public var Green:MovieClip=new green()

                              public var posX:int= 10;

                              public var posY:int =20;

                              scroll_mc.addChild(Green)

 

                              Green.x=posX

                              Green.y=posY

                              trace(Green.x)

 

                              scroll_mc.addEventListener(MouseEvent.MOUSE_DOWN, onDown);

 

                              NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;

                              netConnection = new NetConnection();

                              netConnection.connect(null);

                              netStream = new NetStream(netConnection);

                              netStream.client = this;

                              netStream.addEventListener(NetStatusEvent.NET_STATUS, statusUpdated);

 

                              video = new Video();

                              video.attachNetStream(netStream);

                              video.width = 480;

                              video.height = 320;

                              addChildAt(video, 0);

                    }

 

                    private function  fl_ClickToGoToAndStopAtFrame_2(event:MouseEvent):void

{

          gotoAndStop(2);

}

 

 

                    function onDown(evt:MouseEvent):void {

                    speedArray = new Array(0,0,0,0,0,0,0,0,0,0);

                    speed = 0;

                    prevY = this.mouseY;

                    stage.addEventListener(Event.ENTER_FRAME, onDownEnter);

                    stage.addEventListener(MouseEvent.MOUSE_UP, onUp);

                    }

                    function onDownEnter(evt:Event):void {

                    var sp = this.mouseY - prevY;

                    scroll_mc.y += sp;

                    if (scroll_mc.y < (HEIGHT-scroll_mc.height)) {

                    scroll_mc.y = (HEIGHT-scroll_mc.height);

                    }

                    else if (scroll_mc.y > 0) {

                    scroll_mc.y = 0;

                    }

                    speedArray.push(sp);

                    speedArray.shift();

                    prevY = this.mouseY;

                    }

                    function onUp(evt:MouseEvent):void {

                    stage.removeEventListener(Event.ENTER_FRAME, onDownEnter);

                    stage.removeEventListener(MouseEvent.MOUSE_UP, onUp);

 

                    speed = 0;

                    for (var i:int = 0; i<speedArray.length; i++) {

                    speed += speedArray;

                    }

                    speed /= speedArray.length;

                    addEventListener(Event.ENTER_FRAME, onEnter);

                    }

                    function onEnter(evt:Event):void {

                    if (Math.abs(speed) < .5) {

                    speed = 0;

                    }

                    if (speed < 0) {

                    if (scroll_mc.y > (HEIGHT-scroll_mc.height) - speed) {

                    scroll_mc.y += speed;

                    speed -= speed/DRAG;

                    }

                    else {

                    scroll_mc.y = (HEIGHT-scroll_mc.height);

                    speed = 0;

                    }

                    }

                    else {

                    if (scroll_mc.y < 0-speed) {

                    scroll_mc.y += speed;

                    speed -= speed/DRAG;

                    }

                    else {

                    scroll_mc.y = 0;

                    speed = 0;

                    }

                    }

                    }

                    public function itemClick(event:Event):void{

 

                              if(event.target.selectedItem.label==" קוביות לי יש"){

                                        gotoAndStop(2)

                                        song_number=song[0]

                              }

                              if(event.target.selectedItem.label=="התזמורת"){

                                        gotoAndStop(2)

                                        song_number=song[1]

                              }

                              if(event.target.selectedItem.label=="שי ר הגשם"){

                                        gotoAndStop(2)

                                        song_number=song[2]

                              }

                              if(event.target.selectedItem.label==" יש לנו תיש "){

                                        gotoAndStop(2)

                                        song_number=song[3]

                              }

                              if(event.target.selectedItem.label==" גברת תרנגולת "){

                                        gotoAndStop(2)

                                        song_number=song[4]

                              }

                              if(event.target.selectedItem.label==" שה וגדי"){

                                        gotoAndStop(2)

                                        song_number=song[5]

                              }

                              if(event.target.selectedItem.label==" דג קטן"){

                                        gotoAndStop(2)

                                        song_number=song[6]

                              }

                              if(event.target.selectedItem.label==" הלטאה"){

                                        gotoAndStop(2)

                                        song_number=song[7]

                              }

                              if(event.target.selectedItem.label==" הנה באה הרכבת"){

                                        gotoAndStop(2)

                                        song_number=song[8]

                              }

                              if(event.target.selectedItem.label=="הדובים"){

                                        gotoAndStop(2)

                                        song_number=song[9]

                              }

                              if(event.target.selectedItem.label==" לשפן יש בית"){

                                        gotoAndStop(2)

                                        song_number=song[10]

                              }

                              if(event.target.selectedItem.label==" רוץ בן סוסי"){

                                        gotoAndStop(2)

                                        song_number=song[11]

                              }

                              if(event.target.selectedItem.label==" הנחש"){

                                        gotoAndStop(2)

                                        song_number=song[12]

                              }

                              /*if(event.target.selectedItem.label==" במדינת הגמדים"){

                                        gotoAndStop(2)

                                        song_number=song[42]

                              }

                              if(event.target.selectedItem.label==" במדינת הגמדים"){

                                        gotoAndStop(2)

                                        song_number=song[42]

                              }

                              if(event.target.selectedItem.label==" במדינת הגמדים"){

                                        gotoAndStop(2)

                                        song_number=song[42]

                              }

                              if(event.target.selectedItem.label==" במדינת הגמדים"){

                                        gotoAndStop(2)

                                        song_number=song[42]

                              }

                              if(event.target.selectedItem.label==" במדינת הגמדים"){

                                        gotoAndStop(2)

                                        song_number=song[42]

                              }

                              if(event.target.selectedItem.label==" במדינת הגמדים"){

                                        gotoAndStop(2)

                                        song_number=song[42]

                              }

                              if(event.target.selectedItem.label==" במדינת הגמדים"){

                                        gotoAndStop(2)

                                        song_number=song[42]

                              }

                              if(event.target.selectedItem.label==" במדינת הגמדים"){

                                        gotoAndStop(2)

                                        song_number=song[42]

                              }

                              if(event.target.selectedItem.label==" במדינת הגמדים"){

                                        gotoAndStop(2)

                                        song_number=song[42]

                              }

                              if(event.target.selectedItem.label==" במדינת הגמדים"){

                                        gotoAndStop(2)

                                        song_number=song[42]

                              }

                              if(event.target.selectedItem.label==" במדינת הגמדים"){

                                        gotoAndStop(2)

                                        song_number=song[42]

                              }

                              if(event.target.selectedItem.label==" במדינת הגמדים"){

                                        gotoAndStop(2)

                                        song_number=song[42]

                              }

                              if(event.target.selectedItem.label==" במדינת הגמדים"){

                                        gotoAndStop(2)

                                        song_number=song[42]

                              }

                              if(event.target.selectedItem.label==" במדינת הגמדים"){

                                        gotoAndStop(2)

                                        song_number=song[42]

                              }

                              if(event.target.selectedItem.label==" במדינת הגמדים"){

                                        gotoAndStop(2)

                                        song_number=song[42]

                              }

                              if(event.target.selectedItem.label==" במדינת הגמדים"){

                                        gotoAndStop(2)

                                        song_number=song[42]

                              }

                              if(event.target.selectedItem.label==" במדינת הגמדים"){

                                        gotoAndStop(2)

                                        song_number=song[42]

                              }

                              if(event.target.selectedItem.label==" במדינת הגמדים"){

                                        gotoAndStop(2)

                                        song_number=song[42]

                              }

                              if(event.target.selectedItem.label==" במדינת הגמדים"){

                                        gotoAndStop(2)

                                        song_number=song[42]

                              }

                              if(event.target.selectedItem.label==" במדינת הגמדים"){

                                        gotoAndStop(2)

                                        song_number=song[42]

                              }

                              if(event.target.selectedItem.label==" במדינת הגמדים"){

                                        gotoAndStop(2)

                                        song_number=song[42]

                              }

                              if(event.target.selectedItem.label==" במדינת הגמדים"){

                                        gotoAndStop(2)

                                        song_number=song[42]

                              }

                              if(event.target.selectedItem.label==" במדינת הגמדים"){

                                        gotoAndStop(2)

                                        song_number=song[42]

                              }

                              if(event.target.selectedItem.label==" במדינת הגמדים"){

                                        gotoAndStop(2)

                                        song_number=song[42]

                              }

                              if(event.target.selectedItem.label==" במדינת הגמדים"){

                                        gotoAndStop(2)

                                        song_number=song[42]

                              }

                              if(event.target.selectedItem.label==" במדינת הגמדים"){

                                        gotoAndStop(2)

                                        song_number=song[42]

                              }

                              if(event.target.selectedItem.label==" במדינת הגמדים"){

                                        gotoAndStop(2)

                                        song_number=song[42]

                              }

                              if(event.target.selectedItem.label==" במדינת הגמדים"){

                                        gotoAndStop(2)

                                        song_number=song[42]

                              }

                              if(event.target.selectedItem.label==" במדינת הגמדים"){

                                        gotoAndStop(2)

                                        song_number=song[42]

                              }*/

                              setupControls();

                    }

 

                    public function onMetaData(dataObj:Object):void {

                              ; // Do nothing.

                    }

 

 

                    public function onXMPData(dataObj:Object):void {

                              ; // Do nothing.

                    }

 

                    private function statusUpdated(e:NetStatusEvent):void {

                              if(e.info.code == "NetStream.Play.Stop")

                              {

                                        showBtns(["playBtn"]);

                              }

                    }

 

                    private function setupControls():void {

                              controls.playBtn.addEventListener(MouseEvent.MOUSE_UP, playVideo);

                              controls.restartBtn.addEventListener(MouseEvent.MOUSE_UP, restartVideo);

                              controls.resumeBtn.addEventListener(MouseEvent.MOUSE_UP, resumeVideo);

 

                              stage.addEventListener(MouseEvent.MOUSE_UP, pauseVideo);

 

                              showBtns(["playBtn"]);

                    }

 

private function playVideo(e:MouseEvent):void {

VIDEO_URL = "http://www.tovale.co.il/ktantanim/"+song_number

netStream.play(VIDEO_URL);

hideBtns();

e.stopPropagation();

trace(VIDEO_URL)

trace(song_number)

                    }

 

 

                    private function pauseVideo(e:MouseEvent):void {

                              if(controls.visible == false)

                              {

                                        netStream.pause();

                                        showBtns(["resumeBtn", "restartBtn"]);

                              }

                    }

 

                    private function restartVideo(e:MouseEvent):void {

                              netStream.seek(0);

                              netStream.resume();

                              hideBtns();

                              e.stopPropagation();

                    }

 

                    private function resumeVideo(e:MouseEvent):void {

                              netStream.resume();

                              hideBtns();

                              e.stopPropagation();

                    }

 

                    private function hideBtns():void {

                              controls.visible = false;

                              blocker.visible = false;

                    }

 

                    private function showBtns(btns:Array):void {

                              controls.visible = true;

                              blocker.visible = true;

                              for(var instName:String in controls)

                              {

                                        if(btns.indexOf(instName) != -1)

                                        {

                                                  controls[instName].visible = true;

                                        }

                                        else

                                        {

                                                  controls[instName].visible = false;

                                        }

                              }

 

                    }

 

 

 

          }

 

}

TOPICS
ActionScript
344
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Feb 14, 2014 Feb 14, 2014

You should be declaring your public variables in the public space like the rest... otherwise they only have scope within the function you place them in.

You declare a scroll_mc but you do not create an instance of it.

You should explain more about the problem and only include the code that is relevant to it.

Translate
LEGEND ,
Feb 14, 2014 Feb 14, 2014
LATEST

You should be declaring your public variables in the public space like the rest... otherwise they only have scope within the function you place them in.

You declare a scroll_mc but you do not create an instance of it.

You should explain more about the problem and only include the code that is relevant to it.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines