Posted by thr33 in SWF Studio V3 on Dec 21 2008, 02:25 am

Hi..

I have a project I'm working on with FlashCS3. It's in AS3 and it involves lots of classes and XML files. It's basically a Video/Audio Player in addition to a list of some books.

As an SWF file everything works fine and there are no problems. but when compiled in SS 3.6 build 147 no XML Load and I got my buttons but they don't work either.

All the XML files are next to the EXE there are no paths to miss with. And I cn't figure this out. I tried adding the files to the layout and still the same problem.

Even my close button doesn't work, And it has only an EventListener to a functions with this command:
fscommand("quit");

Any help appreciated

P.S: when I first compiled the project I got errors regarding ssCore even though I added the components needed to my library, so to overcome the problem I dragged them to the stage and the errors was gone. Just thought I should mention that :)


Posted by AGo in SWF Studio V3 on Dec 21 2008, 05:06 am

that sounds like you are getting Runtime Errors. Publish your SWF with debugging capabilities enabled, then inS WF Studio select Standalone (Debug) and enable Debug mode on the output tab.
My bets are 10:1 that *something* is going to throw you a runtime exception


Posted by thr33 in SWF Studio V3 on Dec 21 2008, 07:23 am

You were right AGo..

At runtime I got these errors"

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Mp3player/getSettings()
at Mp3player()
at flash.display::Sprite/constructChildren()
at flash.display::Sprite()
at flash.display::MovieClip()
at Design_fla::MainTimeline()
------------
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Design_fla::MainTimeline/frame1()
-----------
Error #2044: Unhandled NetStatusEvent:. level=error, code=NetStream.Play.StreamNotFound
at Design_fla::Symbol1copy_10/frame1()
------------

But I can't figure it out, everything is running OK before compiling into an EXE

any help is most appreciated guys, please help


Posted by AGo in SWF Studio V3 on Dec 21 2008, 07:30 am

check your NetStream code, this error


Error #2044: Unhandled NetStatusEvent:. level=error, code=NetStream.Play.StreamNotFound
at Design_fla::Symbol1copy_10/frame1()


shall be your first clue what's going wrong, NetStream.Play tries to access a nonexistent stream resource, so you most likely mixed up your paths. trace out what stream url is actually tried and then wonder why the player would not be able to access that url.

If this is not the first runtime error you get dig into the first error first. (makes ense, huh ? ) and test which object is not properly initialised and thus giving you the null reference.

If that does not help, set a few breakproints around those calls and head at it using the AS3 remote debugger,


Posted by thr33 in SWF Studio V3 on Dec 21 2008, 10:09 am

Thanks AGo for the help I really appreciate it..

I have cleaned up my code and all the runtime errors is gone except for one.

Error #2044: Unhandled NetStatusEvent:. level=error, code=NetStream.Play.StreamNotFound
at Design_fla::Symbol1copy_10/frame1()


The strange thing is that the FLV files are next to the exe so the path will be just the file name "video.flv"

I've tried everything but nothing seem to solve this problem and it's driving me crazy :twitch:

Can you please point me in the right direction.

My Video code is:



ssCore.init();

import flash.display.Loader;
import flash.events.*
import flash.net.*;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.display.*;
import flash.text.TextField;
import caurina.*;
import caurina.transitions.*;
import flash.ui.*;
import flash.ui.ContextMenu;
import fl.video.*;

//XML Code
var imageLoader:Loader;
var xmlLoader:URLLoader = new URLLoader();
var xml:XML;
var xmlList:XMLList;

xmlLoader.load(new URLRequest("Vlist.xml"))
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);


//Draw Recs Mask
var Rmask:Sprite = new Sprite();
Rmask.graphics.beginFill(0xffffff,1);
Rmask.graphics.drawRect(0,0,615,115);
Rmask.graphics.endFill();
Rmask.x = 0;
Rmask.y = 0;
recsHolder.addChild(Rmask);
recsHolder.recsFull.mask = Rmask;



//Load Video Thumbs
function xmlLoaded(event:Event):void
{
   xml = XML(event.target.data);
   xmlList = xml.children();
   
   for (var q:int = 0; q < xmlList.length(); q++)
   {
      imageLoader = new Loader();
      imageLoader.load(new URLRequest(xmlList[q].attribute("thumb")));
      imageLoader.y = 15;
      imageLoader.x = q * 210 + 10;
      
      //Add the Text
      var VideoTxt:TextField = new TextField();
      VideoTxt.autoSize = TextFieldAutoSize.CENTER;
      VideoTxt..textColor = 0xffffff;
      VideoTxt.multiline = true;
      VideoTxt.selectable = false;
      VideoTxt.wordWrap = true;
      VideoTxt.y = imageLoader.y;
      VideoTxt.x = imageLoader.x + 65;
      VideoTxt.htmlText = xmlList[q];
      
      //Draw Recs BG
      var RecsBg:Sprite = new Sprite();
      RecsBg.graphics.beginFill(0x333333, 1);
      RecsBg.graphics.drawRoundRect(0,0,200,80,0,0);
      RecsBg.graphics.endFill();
      RecsBg.y = 5;
      RecsBg.x = q * 210;
      
      //Draw Recs Btns
      var RecsBtn:Sprite = new Sprite();
      RecsBtn.graphics.beginFill(0x333333, 0);
      RecsBtn.graphics.drawRoundRect(0,0,200,80,0,0);
      RecsBtn.graphics.endFill();
      RecsBtn.y = 5;
      RecsBtn.x = q * 215;
      RecsBtn.buttonMode = true;
      //Reference to the URLs
      RecsBtn.name = xmlList[q].attribute("source");
      
      recsHolder.recsFull.addChild(RecsBg);
      recsHolder.recsFull.addChild(imageLoader);
      recsHolder.recsFull.addChild(VideoTxt);
      recsHolder.recsFull.addChild(RecsBtn);
      
      RecsBtn.addEventListener(MouseEvent.CLICK, getVurl);
   }
}




//Hide Menu Items
//recsHolder.visible = true;

//Scroll Recsvar

var xOffset:Number;
var xMin:Number = 0;
var xMax:Number = recsHolder.sb.track.width - recsHolder.sb.thumb.width;

recsHolder.sb.thumb.addEventListener(MouseEvent.MOUSE_DOWN, thumbDown);
stage.addEventListener(MouseEvent.MOUSE_UP, thumbUp);
recsHolder.sb.track.addEventListener(MouseEvent.CLICK, trackHandle);

function thumbDown(e:MouseEvent):void
{
   stage.addEventListener(MouseEvent.MOUSE_MOVE, thumbMove);
   xOffset = mouseX - recsHolder.sb.thumb.x;
}

function thumbUp(e:MouseEvent):void
{
   stage.removeEventListener(MouseEvent.MOUSE_MOVE, thumbMove);
}

function thumbMove(e:MouseEvent):void
{
   recsHolder.sb.thumb.x = mouseX - xOffset;
   if(recsHolder.sb.thumb.x <= xMin)
      recsHolder.sb.thumb.x = xMin;
   if(recsHolder.sb.thumb.x >= xMax)
      recsHolder.sb.thumb.x = xMax;
   var sp:Number = recsHolder.sb.thumb.x / xMax;
   Tweener.addTween(recsHolder.recsFull, {x:(-sp*(recsHolder.recsFull.width - Rmask.width)),time:1});
   e.updateAfterEvent();
}

//MetaData Code
var videoDuration:Number;
var client:Object = new Object();
client.onMetaData = metaDataHandler;

function metaDataHandler(metaDataObj:Object):void
{
   videoDuration = metaDataObj.duration;
}


function trackHandle(event:MouseEvent):void {
   recsHolder.sb.thumb.x = mouseX - xOffset;
   if(recsHolder.sb.thumb.x <= xMin)
      recsHolder.sb.thumb.x = xMin;
   if(recsHolder.sb.thumb.x >= xMax)
      recsHolder.sb.thumb.x = xMax;
   var sp:Number = recsHolder.sb.thumb.x / xMax;
   Tweener.addTween(recsHolder.recsFull, {x:(-sp*(recsHolder.recsFull.width - Rmask.width)),time:1});
   event.updateAfterEvent();
}


/*
client.onCuePoint = onCue;

function onCue(cinf:Object):void
{
   for (var w:uint = 0; w < xmlList.length(); w++)
   {
      if (cinf.time == xmlList[w].attribute("location"))
      {
         capTxt.text = xmlList[w];
      }
   }
}
*/

//Netconnection & NetStream
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);



//Poster Frame - the image at the beginning
//playBtn.addEventListener(MouseEvent.CLICK, hideImage);

//var thumbImage:Loader = new Loader();
//loadImage(thumbImage, "startpic.jpg");

/*function hideImage(evt:MouseEvent):void
{
   thumbImage.visible = false;
}
*/
/*function loadImage(loader:Loader, imageURL:String):void
{
   var urlRequest:URLRequest = new URLRequest(imageURL);
   loader.load(urlRequest);
   posterFrame.addChild(loader);
}
*/
//CONTINUE Netconnection & NetStream
ns.client = client;
theVideo.attachNetStream(ns);
//ns.play("pray.flv");
//ns.pause();

//Show Video Recs
function getVurl(event:MouseEvent):void
{
   /*var request:URLRequest = new URLRequest(event.target.name);
   var window:String = "_self";
   navigateToURL(request, window);*/
   
   ns.close();
   ns.play(event.target.name);
   trace(event.target.name);
   covBtn.visible = false;
   pauseBtn.visible = true;
}



// Pause Button code
pauseBtn.visible = false;
playBtn.visible = false;

pauseBtn.addEventListener(MouseEvent.CLICK, pauseBtnClickHandler);
function pauseBtnClickHandler(evt:MouseEvent):void {
   ns.pause();
   playBtn.visible = true;
   pauseBtn.visible = false;
};

// Play Button code
playBtn.addEventListener(MouseEvent.CLICK, playBtnClickHandler);
function playBtnClickHandler(evt:MouseEvent):void {
   ns.resume();
   pauseBtn.visible = true;
   playBtn.visible = false;
};

//FullScreen Btns Visibilty

normalMC.visible = false;

//FullScreen Button Code

fullscreenMC.addEventListener(MouseEvent.CLICK, fullscreenMCClickHandler);

function fullscreenMCClickHandler(evt:MouseEvent):void {
   normalMC.visible = true;
   fullscreenMC.visible = false;
   stage.displayState = StageDisplayState.FULL_SCREEN;
}

//NormalScreen Button Code

normalMC.addEventListener(MouseEvent.CLICK, normalMCClickHandler);

function normalMCClickHandler(evt:MouseEvent):void {
   normalMC.visible = false;
   fullscreenMC.visible = true;
   stage.displayState = StageDisplayState.NORMAL;
}

//Rewind Btn Code

rewindMC.addEventListener(MouseEvent.CLICK, rewindMCMouseClickHandler);
function rewindMCMouseClickHandler(event:MouseEvent):void
{
   ns.seek(0);
}

//Menu Btn Code
var Vwidth:Number = 550;
var Vheight:Number = 413;
var Vx:Number = 0;
var Vy:Number = 0;
var BloadX:Number = 203.6;
var BloadY:Number = 181.2;
var BloadXn:Number = 90;
var BloadYn:Number = 100;
var Lx:Number = 438;
var Ly:Number = 5;
var nLx:Number = 184;
var nLy:Number = 23;

//menuBtn.addEventListener(MouseEvent.CLICK, ShowMnu);



//Sound Code
var videoSound:SoundTransform = new SoundTransform();
videoSound.volume = .5;
ns.soundTransform = videoSound;

//Sound Scrub Code
var volumeBounds:Rectangle = new Rectangle(509, 347.5, 77, 0);
//var volumeBounds:Rectangle = new Rectangle(378.5,427.3,77,0);
volumeMC.buttonMode = true;
volumeMC.addEventListener(MouseEvent.MOUSE_DOWN, volumeMCMouseDownHandler);

function volumeMCMouseDownHandler(evt:MouseEvent):void {
   volumeMC.startDrag(false,volumeBounds);
   stage.addEventListener(MouseEvent.MOUSE_UP, volumeMCMouseUpHandler);
   stage.addEventListener(MouseEvent.MOUSE_MOVE, volumeMCMouseMoveHandler);
}
function volumeMCMouseUpHandler(evt:MouseEvent):void {
   volumeMC.stopDrag();
   stage.removeEventListener(MouseEvent.MOUSE_UP, volumeMCMouseUpHandler);
   stage.removeEventListener(MouseEvent.MOUSE_MOVE, volumeMCMouseMoveHandler);
}
function volumeMCMouseMoveHandler(evt:MouseEvent):void {
   videoSound.volume = (volumeMC.x - 509) / 77;
   volumeTB.text = String(Math.round(videoSound.volume * 100) + 1);
   ns.soundTransform = videoSound;
   volumeBarsMaskMC.width = (volumeMC.x - 509) / 2;
   volumeBarMC.width = 3 + (volumeMC.x - 509);
}

//Sound SliderBar Code
vBarClick.addEventListener(MouseEvent.MOUSE_OVER, vBarMcOver);

function vBarMcOver(evt:MouseEvent):void {
   vBarClick.addEventListener(MouseEvent.MOUSE_OUT, vBarMcOut);
   vBarClick.addEventListener(MouseEvent.CLICK, vBarMcClick);
}

function vBarMcOut(evt:MouseEvent):void {
   vBarClick.removeEventListener(MouseEvent.MOUSE_OUT, vBarMcOut);
   vBarClick.removeEventListener(MouseEvent.CLICK, vBarMcClick);
}

function vBarMcClick(evt:MouseEvent):void {
   volumeMC.x = mouseX;
   videoSound.volume = (volumeMC.x - 509) / 77;
   volumeTB.text = String(Math.round(videoSound.volume * 100) + 1);
   ns.soundTransform = videoSound;
   volumeBarsMaskMC.width = (volumeMC.x - 509) / 2;
   volumeBarMC.width = 3 + (volumeMC.x - 509);
}

//Video Scrub Code  + Time Code
var progressBounds:Rectangle = new Rectangle(102.5,346.2,290,0);
var progressDragStatus:Boolean = new Boolean(false);

var playProgressTM:Timer = new Timer(100,0);
playProgressTM.addEventListener(TimerEvent.TIMER, playProgressTMTimerHandler);

function playProgressTMTimerHandler(evt:TimerEvent):void {
   loadProgressMC.width = (290 * ns.bytesLoaded / ns.bytesTotal);
      if(progressDragStatus == false){
         
         //Passed Time
         var Pminutes:Number = int((int(ns.time))/60);
         var Pseconds:Number = (int(ns.time)) % 60;
         var m;
         var s;
         
         if (Pminutes<10)
         {
            m = "0"+Pminutes;
         } 
         else 
         {
            m = Pminutes;
         }
         
         if (Pseconds<10) 
         {
            s = "0"+Pseconds;
         } 
         else 
         {
            s = Pseconds;
         }
         
         //Total Time
         var Tminutes:Number = int((int(videoDuration))/60);
         var Tseconds:Number = (int(videoDuration)) % 60;
         var Tm;
         var Ts;
         
         if (Tminutes<10)
         {
            Tm = "0"+Tminutes;
         } 
         else 
         {
            Tm = Tminutes;
         }
         
         if (Tseconds<10) 
         {
            Ts = "0"+Tseconds;
         } 
         else 
         {
            Ts = Tseconds;
         }
         
         
         progressTB.text = m + ":" + s + '  ||  ' + Tm + ":" + Ts;
         progressMC.x = 102.5 + 290 * (ns.time / videoDuration);
         playProgressMC.width = (290 * ns.time / videoDuration);
         //trace (ns.time);
   }
}
playProgressTM.start();

//Continue Video Scrub -- Draging
progressMC.buttonMode = true;
progressMC.addEventListener(MouseEvent.MOUSE_DOWN, progressMCMouseDownHandler);
function progressMCMouseDownHandler(event:MouseEvent):void {
   progressDragStatus = true;
   progressBounds = new Rectangle(102.5,426,290,0);
   progressMC.startDrag(false,progressBounds);
   stage.addEventListener(MouseEvent.MOUSE_UP, progressMCMouseUpHandler);
   stage.addEventListener(MouseEvent.MOUSE_MOVE, progressMCMouseMoveHandle);
}

function progressMCMouseUpHandler(event:MouseEvent):void {
   progressDragStatus = false;
   progressMC.stopDrag();
   stage.removeEventListener(MouseEvent.MOUSE_UP, progressMCMouseUpHandler);
   stage.removeEventListener(MouseEvent.MOUSE_MOVE, progressMCMouseMoveHandle);
}
function progressMCMouseMoveHandle(event:MouseEvent):void {
   ns.seek(videoDuration * (progressMC.x - 102.5) / 290);
   playProgressMC.width = (progressMC.x - 102.5 + 9);
}

//Video SliderBar Code + Time
PbarClick.addEventListener(MouseEvent.MOUSE_OVER, PBarMcOver);

function PBarMcOver(evt:MouseEvent):void {
   PbarClick.addEventListener(MouseEvent.MOUSE_OUT, PBarMcOut);
   PbarClick.addEventListener(MouseEvent.CLICK, PBarMcClick);
}

function PBarMcOut(evt:MouseEvent):void {
   PbarClick.removeEventListener(MouseEvent.MOUSE_OUT, PBarMcOut);
   PbarClick.removeEventListener(MouseEvent.CLICK, PBarMcClick);
}

function PBarMcClick(evt:MouseEvent):void {
   progressMC.x = mouseX;
   ns.seek(videoDuration * (progressMC.x - 102.5) / 290);
   playProgressMC.width = (progressMC.x - 102.5 + 9);
}

//Load Embed Code & Activate Btns

//var txtLoader:URLLoader = new URLLoader();
//txtLoader.load(new URLRequest("fcodes.txt"))

/*function txtLoaded(event:Event):void {
   var txtVars:URLVariables = new URLVariables(txtLoader.data);
   ecode.embedCode.text = txtVars.elink;
   ecode.URLcode.text = txtVars.ulink;
}

function copyEmbed(evt:MouseEvent):void {
   System.setClipboard(ecode.embedCode.text);
   ecode.embedCode.stage.focus = ecode.embedCode;
   ecode.embedCode.setSelection(0, ecode.embedCode.text.length);
}

function copyUrl(evt:MouseEvent):void {
   System.setClipboard(ecode.URLcode.text);
   ecode.URLcode.stage.focus = ecode.URLcode;
   ecode.URLcode.setSelection(0, ecode.URLcode.text.length);
}
*/

//RightClick Menu

var myCM:ContextMenu = new ContextMenu();    
myCM.hideBuiltInItems();

var ihPlayer:ContextMenuItem = new ContextMenuItem("IHplayer v1.0" );  
ihPlayer.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, ihp);  
myCM.customItems.push( ihPlayer );

var ih:ContextMenuItem = new ContextMenuItem("IslamHouse.com");  
ih.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, ihwww);  
myCM.customItems.push( ih );

contextMenu = myCM;

function ihp(event:ContextMenuEvent):void
{
   var url:String = "http://www.islamhouse.com/IHplayer";
   var request:URLRequest = new URLRequest(url);
   var window:String = "_blank";
   navigateToURL(request, window);
}

function ihwww(event:ContextMenuEvent):void
{
   var url:String = "http://www.islamhouse.com";
   var request:URLRequest = new URLRequest(url);
   var window:String = "_blank";
   navigateToURL(request, window);
}

recSlider.addEventListener(MouseEvent.CLICK, SlideRecs);
recSlider.buttonMode = true;

function SlideRecs(event:MouseEvent):void {
   recsHolder.visible = false;
   recSlider.y = 313.7;
   recSlider.removeEventListener(MouseEvent.CLICK, SlideRecs);
   recSlider.addEventListener(MouseEvent.CLICK, SlideRecsBack);
}

function SlideRecsBack(event:MouseEvent):void {
   recsHolder.visible = true;
   recSlider.y = 202.4;
   recSlider.addEventListener(MouseEvent.CLICK, SlideRecs);
   recSlider.removeEventListener(MouseEvent.CLICK, SlideRecsBack);
}


Posted by northcode in SWF Studio V3 on Dec 21 2008, 11:38 pm

If I'm remembering correctly (Derek may confirm or deny this) relative paths don't work with FLV files so you have to fully qualify them. If the FLV is in the same folder as the EXE, You can do that using ssGlobals.ssStartDir + "\\video.flv" instead of just "video.flv".


Posted by thr33 in SWF Studio V3 on Dec 22 2008, 01:33 am

Thanks a million Tim,

That really fixed everything.

The strange thing is, in my previous project which was AS2 and compiled with a previous version of SS, the flv paths were no problem and I didn't had to use this solution to get them to work.

Well I'm still learning from you guys, you're the best thanks again.


Posted by northcode in SWF Studio V3 on Dec 22 2008, 05:24 am

In AS2 we were able to override some of the default behaviors, in AS3 that's not possible.