Copy link to clipboard
Copied
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
song is a class variable and you're trying to use it to define a static variable.
make both static or both not static.
Copy link to clipboard
Copied
song is a class variable and you're trying to use it to define a static variable.
make both static or both not static.
Copy link to clipboard
Copied
excellent
thank you
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now