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

array problem

Explorer ,
Jan 28, 2014 Jan 28, 2014

i have the following script using an array "song":

when publishing i  get error 1120

access of undefined property song

where is my mistake?

package {

 

          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;

 

          public class Main extends MovieClip {

var song:Array=["http://www.tovale.co.il/ktantanim/lego.flv","dag.flv","ez.flv"]

                    static private const VIDEO_URL:String = song[0]

 

                    private var netConnection:NetConnection;

                    private var netStream:NetStream;

                    private var video:Video;

 

                    public function Main() {

                              NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;

                              netConnection = new NetConnection();

                              netConnection.connect(null);

                              trace (VIDEO_URL)

                              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);

 

                              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 {

                              netStream.play(VIDEO_URL);

                              hideBtns();

                              e.stopPropagation();

                    }

 

                    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;

                                        }

                              }

                    }

          }

}

thanks

udi

TOPICS
ActionScript
538
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

Community Expert , Jan 28, 2014 Jan 28, 2014

song is a class variable and you're trying to use it to define a static variable.

make both static or both not static.

Translate
Community Expert ,
Jan 28, 2014 Jan 28, 2014

song is a class variable and you're trying to use it to define a static variable.

make both static or both not static.

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
Explorer ,
Jan 28, 2014 Jan 28, 2014

excellent

thank you

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
Community Expert ,
Jan 28, 2014 Jan 28, 2014
LATEST

you're welcome.

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