Actionscript mobile Madcomponents Mapquest - actionscript-3

i am trying to add map in action script mobile app i have created xml for the layout, as the tags for the xml layout are predefined so i believe we cannot create custom tags, so i added that map using image tag but now the trouble is the mad components has disabled its scroll as well, no regrets that was suppose to be happen because i have created map under image, i tried to put the scrollVertical as well but that didn't work because that map was under image tag.
below is my code.
package
{
import com.danielfreeman.madcomponents.*;
import com.mapquest.*;
import com.mapquest.services.geocode.*;
import com.mapquest.tilemap.*;
import com.mapquest.tilemap.controls.inputdevice.*;
import com.mapquest.tilemap.controls.shadymeadow.*;
import com.mapquest.tilemap.pois.*;
import flash.display.Screen;
import flash.display.Sprite;
import flash.display.Stage;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.media.StageWebView;
import flash.system.Capabilities;
import flash.text.TextField;
import flash.utils.flash_proxy;
import mx.events.FlexEvent;
public class map extends Sprite
{
private static var alResults:Array;
static var myMap:TileMap = new TileMap("my Key");
static var geocoder:Geocoder;
public static const LAYOUT:XML = <scrollVertical background="#DADED4" >
<imageLoader id="placeholder"> </imageLoader >
</scrollVertical>;
protected static var _message:UILabel;
public static function initialize():void{
var placeholder:UIImageLoader = UIImageLoader(UI.findViewById("placeholder"));
placeholder.scrollRect
placeholder.addChild(myMap);
myMap.addControl(new SMLargeZoomControl());
myMap.addControl(new SMViewControl());
myMap.addControl(new MouseWheelZoomControl());
myMap.size = new Size(300, 400);
myMap.addControl(new SMLargeZoomControl());
myMap.addControl(new SMViewControl());
myMap.addControl(new MouseWheelZoomControl());
// create a new TileMap object, passing your platform key
geocoder = new Geocoder(myMap);
geocoder.addEventListener(GeocoderEvent.GEOCODE_RESPONSE, onGeocodeResponse);
geocoder.addEventListener(GeocoderEvent.GEOCODE_ERROR_EVENT, onGeocodeError);
geocoder.addEventListener(GeocoderEvent.HTTP_ERROR_EVENT, onHttpError);
doGeocode();
}
public function map()
{
super();
}
private static function onGeocodeResponse(e:GeocoderEvent):void {
alResults = new Array();
for each (var loc:GeocoderLocation in e.geocoderResponse.locations) {
var o:Object = new Object();
o.LatLng = loc.displayLatLng.lat + ", " + loc.displayLatLng.lng;
o.GeocodeQuality = loc.geocodeQuality;
o.GeocodeQualityCode = loc.geocodeQualityCode;
alResults.push(o);
}
//this.dgResults.dataProvider = this.alResults;
//this.vgrpResults.visible = true;
}
private static function doGeocode():void {
//remove all shapes form the map
myMap.removeShapes();
//use the default cursor
//this.cursorManager.setBusyCursor();
//make an array to hold the addresses
var arrAddresses:Array = new Array();
//push the addresses onto the array
arrAddresses.push("placea");
arrAddresses.push("place b");
//call the geocoder object's geocode method, passing the array of addresses
geocoder.geocode(arrAddresses);
}
private static function onGeocodeError(e:GeocoderEvent):void {
//this.cursorManager.removeBusyCursor();
makeErrorList("GEOCODER ERROR");
}
/*
function to handle an error in the result
*/
private static function onHttpError(e:GeocoderEvent):void {
//this.cursorManager.removeBusyCursor();
makeErrorList("HTTP ERROR");
}
/*
function to make an array list to hold an error
*/
private static function makeErrorList(s:String):void {
var o:Object = new Object();
o.LatLng = s;
alResults.push(o);
//this.dgResults.dataProvider = this.alResults;
//this.vgrpResults.visible = true;
}
}
}
has any one got any idea how do i achieve my goal :S
help will be really appreciated.

Instead of using vertical i have used scrollXY than search for scroll see the following code
package
{
import com.danielfreeman.extendedMadness.UIScrollXY;
import com.danielfreeman.madcomponents.*;
import com.mapquest.*;
import com.mapquest.services.geocode.*;
import com.mapquest.tilemap.*;
import com.mapquest.tilemap.controls.inputdevice.*;
import com.mapquest.tilemap.controls.shadymeadow.*;
import com.mapquest.tilemap.pois.*;
import flash.display.Screen;
import flash.display.Sprite;
import flash.display.Stage;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.media.StageWebView;
import flash.system.Capabilities;
import flash.text.TextField;
import flash.utils.flash_proxy;
import mx.events.FlexEvent;
public class map extends Sprite
{
private static var alResults:Array;
static var myMap:TileMap = new TileMap("My Key");
static var geocoder:Geocoder;
public static const LAYOUT:XML =
<scrollXY tapToScale="3.0" stageColour="#666666" scrollBarColour="#FFFFFF" width="480" height="640" border="false" id="scroller">
<imageLoader id="placeholder"> </imageLoader >
</scrollXY>;
protected static var _message:UILabel;
public static function initialize():void{
var scroller:UIScrollXY = UIScrollXY(UI.findViewById("scroller"));
scroller.addChild(myMap);
/*var placeholder:UIImageLoader = UIImageLoader(UI.findViewById("placeholder"));
placeholder.scrollRect
placeholder.addChild(myMap);
*/ myMap.addControl(new SMLargeZoomControl());
myMap.addControl(new SMViewControl());
myMap.addControl(new MouseWheelZoomControl());
myMap.size = new Size(300, 400);
myMap.addControl(new SMLargeZoomControl());
myMap.addControl(new SMViewControl());
myMap.addControl(new MouseWheelZoomControl());
// create a new TileMap object, passing your platform key
geocoder = new Geocoder(myMap);
geocoder.addEventListener(GeocoderEvent.GEOCODE_RESPONSE, onGeocodeResponse);
geocoder.addEventListener(GeocoderEvent.GEOCODE_ERROR_EVENT, onGeocodeError);
geocoder.addEventListener(GeocoderEvent.HTTP_ERROR_EVENT, onHttpError);
doGeocode();
}
public function map()
{
super();
}
private static function onGeocodeResponse(e:GeocoderEvent):void {
alResults = new Array();
for each (var loc:GeocoderLocation in e.geocoderResponse.locations) {
var o:Object = new Object();
o.LatLng = loc.displayLatLng.lat + ", " + loc.displayLatLng.lng;
o.GeocodeQuality = loc.geocodeQuality;
o.GeocodeQualityCode = loc.geocodeQualityCode;
alResults.push(o);
}
//this.dgResults.dataProvider = this.alResults;
//this.vgrpResults.visible = true;
}
private static function doGeocode():void {
//remove all shapes form the map
myMap.removeShapes();
//use the default cursor
//this.cursorManager.setBusyCursor();
//make an array to hold the addresses
var arrAddresses:Array = new Array();
//push the addresses onto the array
arrAddresses.push("Loc1");
arrAddresses.push("Loc2");
//call the geocoder object's geocode method, passing the array of addresses
geocoder.geocode(arrAddresses);
}
private static function onGeocodeError(e:GeocoderEvent):void {
//this.cursorManager.removeBusyCursor();
makeErrorList("GEOCODER ERROR");
}
/*
function to handle an error in the result
*/
private static function onHttpError(e:GeocoderEvent):void {
//this.cursorManager.removeBusyCursor();
makeErrorList("HTTP ERROR");
}
/*
function to make an array list to hold an error
*/
private static function makeErrorList(s:String):void {
var o:Object = new Object();
o.LatLng = s;
alResults.push(o);
//this.dgResults.dataProvider = this.alResults;
//this.vgrpResults.visible = true;
}
}
}

Related

Starling cannot access a property or method of a null object reference

Hey any help appreciated i've been mind boggled by the asset manager for a couple of days
Here is my Hawaii class that I'm trying to reference assets from my asset manager class (MapAssetLoadQeue). and I'm getting the Cannot access a property or method of a null object reference. Error, the error is thrown in my Hawaii class if I don't (Null) the Asset Manager reference, and it is thrown in my Loader Class haw.showHawaii()
Thanks!!!
package Maps
{
import flash.filesystem.File;
import Enqueue.MapAssetLoadQeue;
import starling.animation.IAnimatable;
import starling.animation.Juggler;
import starling.core.Starling;
import starling.display.Image;
import starling.display.MovieClip;
import starling.display.Sprite;
import starling.events.Event;
import starling.textures.Texture;
import starling.textures.TextureAtlas;
import starling.utils.AssetManager;
public class Hawaii extends Sprite
{
public var mal:MapAssetLoadQeue = new MapAssetLoadQeue;
public var Ocean:Image;
public function Hawaii():void{
super();
this.addEventListener
(starling.events.Event.ADDED_TO_STAGE, showHawaii);
}
public function showHawaii(e:Event):void{
if(mal.mapAssets != null) {
Ocean = new Image(mal.mapAssets.getTexture("blue"));
addChild(Ocean);
Ocean.x = 0;
Ocean.y = 0;
}
}
Here is my loader class where I load my assets, and here is where I get my error. haw.showHawaii(null) function. Cannot access a property or method of a null object reference.
package Assets {
import flash.filesystem.File;
import Enqueue.MapAssetLoadQeue;
import GUI.Wave;
import Maps.Hawaii;
import starling.animation.IAnimatable;
import starling.animation.Juggler;
import starling.core.Starling;
import starling.core.starling_internal;
import starling.display.Image;
import starling.display.MovieClip;
import starling.display.Sprite;
import starling.events.Event;
import starling.textures.Texture;
import starling.textures.TextureAtlas;
import starling.utils.AssetManager;
public class Loader extends Sprite {
var loadText: Texture = Texture.fromEmbeddedAsset(loadMCTexture);
var loadXml: XML = XML(new loadMC0Xml());
var loaderAtlas: TextureAtlas = new TextureAtlas(loadText, loadXml);
public var loaderMovie: MovieClip = new MovieClip(loaderAtlas.getTextures("loading_"));
public var mal: MapAssetLoadQeue = new MapAssetLoadQeue;
public var wave:Wave = new Wave;
public var haw:Hawaii;
//Loader MovieClip size 720X233;
[Embed(source = "/../Wavehunter/loadScreenAssets/wm/MovieClips/loader/loader_0.xml", mimeType = "application/octet-stream")]
public static const loadMC0Xml: Class;
[Embed(source = "/../Wavehunter/loadScreenAssets/wm/MovieClips/loader/loader_0.png")]
public static const loadMCTexture: Class;
// public var juggler:Juggler = Starling.juggler;
/*
======================================================================
Every Movieclip asset for the worldMap
> Load WorldMap Assets on stage as Png and Make all alpha to 30%
> and within each function make that png invible to false or remove
> add MoviClip over the invisible png after load is processed
=======================================================================
*/
// Load WorldMap asset function
public function mapLoader(): void {
mal.requestWM();
addChild(loaderMovie);
loaderMovie.x = 347;
loaderMovie.y = 277;
loaderMovie.play();
Starling.juggler.add(loaderMovie);
}
public function mapLdr(){
loaderMovie.visible = true;
addChild(loaderMovie);
loaderMovie.x = 347;
loaderMovie.y = 277;
loaderMovie.play();
Starling.juggler.add(loaderMovie);
}
//this function resizes the loader to original size and places at the bottom corner
public function resizeLdr(){
loaderMovie.width = 72;
loaderMovie.height = 22;
loaderMovie.x =1237;
loaderMovie.y = 712;
}
public function callLoad(): void {
public function callHawaii(): void {
trace(" Hawaii is being runned");
//mal.mapAssets.verbose = true;
mal.mapAssets.loadQueue(function onGo(ratio: Number): void {
trace("Hawaii percentage is", ratio);
if (ratio == 1.0) {
Starling.juggler.delayCall(function (): void {
loaderMovie.visible = false;
//addChild(haw.Ocean);
// addChild(haw);
trace("this is haw value",haw);
//trace("this is the function", haw.showHawaii(null));
haw.showHawaii(null);
}, 0.30);
}
});
}
public function showMap() {
// get texture by name
addChild(mal);
mal.accesMap();
mal.hawaii.addEventListener(Event.TRIGGERED,removeMap);
}
// this code removes the HawaiiMap from the screen and goes directly to the wave
public function removeMap(){
trace("function initated");
mapLdr();
resizeLdr();
mal.mapAssets.purge();
mal.requestHawaii();
callHawaii();
mal.hawaii.removeEventListener(Event.TRIGGERED,removeMap);
}
public function Loader() {
super();
}
}
}
And here is my Asset Manager class
package Enqueue {
import flash.filesystem.File;
import Assets.MapAnimate;
import Assets.MapAssets;
import Maps.Hawaii;
import starling.animation.IAnimatable;
import starling.animation.Juggler;
import starling.animation.Transitions;
import starling.animation.Tween;
import starling.core.Starling;
import starling.core.starling_internal;
import starling.display.Button;
import starling.display.Image;
import starling.display.MovieClip;
import starling.display.Sprite;
import starling.events.EnterFrameEvent;
import starling.events.Event;
import starling.textures.Texture;
import starling.textures.TextureAtlas;
import starling.utils.AssetManager;
public class MapAssetLoadQeue extends Sprite {
public var mapAssets: AssetManager;
public function MapAssetLoadQeue() {
super();
}
public function requestHawaii():void {
// mapAssets.verbose =false;
// mapAssets = new AssetManager;
var appDir:File = File.applicationDirectory;
mapAssets.enqueue(appDir.resolvePath("IslandMaps/Hawaii"));
//mapAssets.enqueue(Hawaii);
mapAssets.verbose = true;
}
If this is all of your code, and if I'm not missing something obvious, I don't see you creating "haw" anywhere. That is, you don't appear to have anything such as...
haw = new Hawaii();
...so, it would be null!

AS3: 1180 Call to a possibly undefined property: Add Child

Pretty big noob at AS3. I'm trying to Load a SWF into another file. (Main .fla loading external SWFS on mouse click)
I keep getting the error: 1180 Call to a possibly undefined property: Add Child, however.
My LoadSWF code is:
package {
import flash.display.*;
import flash.events.*;
import flash.net.*;
public class LoadSWF {
private var loaderFile: Loader;
private var swfFile: Object;
private var sourceFile: String;
private var fileLabel: String;
private var canDrag: Boolean;
private var popX: int;
private var popY: int;
public function LoadSWF(myFile: String, myLabel: String, myX: int = 0, myY: int = 0, myDrag: Boolean = false) {
// constructor code
trace("Loading SWF file:", myFile);
sourceFile = myFile;
fileLabel = myLabel;
canDrag = myDrag;
popX = myX;
popY = myY;
openSWF();
}
private function openSWF(): void {
// initialise variables
loaderFile = new Loader();
swfFile = addChild(loaderFile);
// set initial position of the SWF popup
loaderFile.x = popX;
loaderFile.y = popY;
try {
loaderFile.load(new URLRequest(sourceFile));
// runs after the SWF popup has finished loading
loaderFile.contentLoaderInfo.addEventListener(Event.COMPLETE, SWFloaded);
} catch (err: Error) {
// provide some error messages to help with debugging
trace("Error loading requested document:", sourceFile);
trace("Error:", err);
sourceFile = null;
}
} //end openSWF
private function SWFloaded(evt: Event): void {
// and add the required event listeners
loaderFile.addEventListener(MouseEvent.MOUSE_DOWN, dragSWF);
loaderFile.addEventListener(MouseEvent.MOUSE_UP, dropSWF);
// use the POPUP reference to access MovieClip content
swfFile.content.gotoAndStop(fileLabel);
// assigns a close function to the button inside the popup
swfFile.content.closeBtn.addEventListener(MouseEvent.CLICK, closeSWF);
// remove the COMPLETE event listener as it’s no longer needed
loaderFile.contentLoaderInfo.removeEventListener(Event.COMPLETE, SWFloaded);
} //end SWFLOaded
private function dragSWF(evt: MouseEvent): void {
swfFile.content.startDrag();
}
private function dropSWF(evt: MouseEvent): void {
swfFile.content.stopDrag();
}
private function closeSWF(evt: MouseEvent): void {
// remove the required event listeners first
loaderFile.removeEventListener(MouseEvent.MOUSE_DOWN, dragSWF);
loaderFile.removeEventListener(MouseEvent.MOUSE_UP, dropSWF);
swfFile.content.closeBtn.removeEventListener(MouseEvent.CLICK, closeSWF);
// remove the pop-up
loaderFile.unloadAndStop();
}
} //end class
} //end package
I'm calling it into my main class file, which code is (I left out the rest, guessing its unnecessary):
package {
import flash.display.MovieClip;
import flash.text.TextField;
import flash.display.SimpleButton;
import flash.utils.Dictionary;
import flash.text.TextFormat;
import flash.net.*;
import flash.events.*;
import fl.controls.*;
import flash.media.*;
import fl.events.ComponentEvent;
import fl.managers.StyleManager;
import fl.data.DataProvider;
import fl.data.SimpleCollectionItem;
import fl.managers.StyleManager;
import fl.events.ComponentEvent;
import flash.events.Event;
import flash.net.SharedObject;
import LoadSWF;
public class Main extends MovieClip {
//Declare variables
private var componentFmt: TextFormat;
private var radioBtnFmt: TextFormat;
private var playerData: Object;
private var savedGameData: SharedObject;
// Pop-up Variables
private var popupFile: LoadSWF;
private var swfPath: String;
public function Main() {
// constructor code
this.savedGameData = SharedObject.getLocal("savedPlayerData");
this.setComponents();
this.setPlayerData();
//this.swfPath = "";
//this.isHelpOpen = false;
//this.sndPath = "musicSFX/music2.mp3";
//this.isMuted = false;
//this.sndTrack = new LoadSND(this.sndPath, this.canRepeat);;
//this.muteBtn.addEventListener(MouseEvent.CLICK, this.setMute);
swfPath = "";
helpBtn.addEventListener(MouseEvent.CLICK, openSWF);
//hauntedForestBtn.addEventListener(MouseEvent.CLICK, openSWF);
}
public function openSWF(evt: MouseEvent): void {
// determine which button was pressed
var myFile: String = evt.currentTarget.name.replace("Btn", ".swf");
myFile = (swfPath == "") ? myFile : swfPath + myFile;
if (myFile == "help.swf") {
// load the help SWF file - is draggable
swfFile = new LoadSWF(myFile, currentFrameLabel, 80, 60, true);
} else {
// load the selected SWF file - is not draggable
swfFile = new LoadSWF(myFile, currentFrameLabel);
}
addChild(swfFile);
}
If anyone could help me find a solution, i'd greatly appreciate it.
Thanks :)
addChild is defined by DisplayObjectContainer.
So to access this function, you'll have to alter LoadSWF so that it extends DisplayObjectContainer.

1195 Attempted access of inaccessible method playVideo through a reference with static type NSPv4

Call:
import fl.video.*
import NSPv4;
var playVid:NSPv4 = new NSPv4();
playVid.playVideo(this.parent);
Class:
package
{
import flash.display.MovieClip;
import flash.display.StageAlign;
import flash.events.*;
import flash.net.*;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundMixer;
import fl.video.*;
public class NSPv4 extends MovieClip
{
var __PARENT;
var __PARENT1;
public function playAudio(_PARENT):void
{
__PARENT = _PARENT;
var audioLabel:String = _PARENT.currentLabel;
var audioLabelNum:String = audioLabel.replace("sct","audio/");
audioLabelNum += ".mp3";
var vo:Sound = new Sound(new URLRequest(audioLabelNum));
var channel:SoundChannel = new SoundChannel();
channel = vo.play();
channel.addEventListener(Event.SOUND_COMPLETE, onPlaybackComplete);
}
public function playVideo(_PARENT1):void
{
__PARENT1 = _PARENT1;
var videoLabel:String = _PARENT1.currentLabel;
var videoLabelNum:String = videoLabel.replace("sct","audio/");
videoLabelNum += ".f4v";
var videoPlayer:FLVPlayback = new FLVPlayback();
videoPlayer.source = videoLabelNum;
_PARENT1.addChild(videoPlayer);
}
public function onPlaybackComplete(event:Event):void
{
SoundMixer.stopAll();
MovieClip(__PARENT).nextFrame();
}
}
}
Can call the playAudio with no problems but when I try playVideo() I get the following error:
1195 Attempted access of inaccessible method playVideo through a reference with static type NSPv4
I set up a separate class for the video to stand alone without the playAudio() function and this works too.
Most confused!

AS3 Preloader not updating screen

I've been struggling with a Flash preloader. I just want it to update the text on the screen with the current percentage. Now it basically works as the trace outputs the correct percentages, but it won't update the textfield I have on the screen. Once the trace gets to 100% however, the code does output "100" on the screen, but not until it's all loaded. I don't have the Flash IDE and am just using pure Actionscript with FlashDevelop. Here's my code:
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.display.Loader;
import flash.events.ProgressEvent;
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.display.Loader;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFieldType;
public class Main extends Sprite
{
public var myLoader:Loader = new Loader();
public var image:String = "tmp/Avengers-poster.jpg";
private var Title:TextField;
private var txt:String;
private var Form:TextField;
public function Main():void {
textbox("This is the title","box",100,100,200,30);
myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressStatus);
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaderReady);
var fileRequest:URLRequest = new URLRequest(image);
myLoader.load(fileRequest);
}
public function onProgressStatus(e:ProgressEvent):void {
// this is where progress will be monitored
var perc:int = Math.ceil((e.bytesLoaded/e.bytesTotal)*100);
txt = perc.toString();
Title.text = txt;
addChild (Title);
trace(perc);
}
public function onLoaderReady(e:Event):void {
// the image is now loaded, so let's add it to the display tree!
addChild(myLoader);
}
private function textbox (title_str:String,form_name:String,x:int,y:int,width:int,height:int):void {
Title = new TextField ();
Title.text = title_str;
Title.selectable = false;
Title.setTextFormat (new TextFormat ("Arial", 12, 0x777777, true));
txt = ".";
Title.x = x;
Title.y = y;
addChild (Title);
}
}
}
Thanks for your help.
Darryl
This will work. Don't recreate the TextField on each status. You only need to addChild once and update the reference to it.
package
{
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.text.TextField;
import flash.text.TextFieldType;
import flash.text.TextFormat;
public class Main extends Sprite
{
public var myLoader:Loader = new Loader();
public var image:String = "http://apod.nasa.gov/apod/image/0605/titan5km_huygens_big.jpg";
private var Title:TextField;
private var Form:TextField;
public function Main():void {
createTextField("This is the title","box",100,100,200,30);
myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressStatus);
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaderReady);
var fileRequest:URLRequest = new URLRequest(image);
myLoader.load(fileRequest);
}
public function onProgressStatus(e:ProgressEvent):void {
// this is where progress will be monitored
var perc:int = Math.ceil((e.bytesLoaded/e.bytesTotal)*100);
Title.text = perc.toString();
}
public function onLoaderReady(e:Event):void {
// the image is now loaded, so let's add it to the display tree!
addChild(myLoader);
}
private function createTextField (title_str:String,form_name:String,x:int,y:int,width:int,height:int):void {
Title = new TextField();
Title.text = title_str;
Title.selectable = false;
Title.setTextFormat (new TextFormat ("Arial", 12, 0x777777, true));
Title.text = ".";
Title.x = x;
Title.y = y;
addChild (Title);
}
}
}

NetStream Info Returning 0's (Icecast Stream)

I've searched high and low for a fix to this issue, but cannot find ANYTHING on why almost all the properties are being returned as 0.
I am using FLV wrapping to pull a live audio stream from Icecast (since Adobe, 15 years later, still haven't fixed their live audio memory leak issue). It works great, everything functions perfectly.
However, I'm wanting to create a bandwidth monitor (for my iPhone port, and for my normal Flash player)... But whenever I retrieve netStreamInfo it returns as 0! For dataBytesPerSecond, audioBytesPerSecond, byteCount, dataByteCount, nearly EVERY SINGLE PROPERTY returns 0. I have this run on a 1-second timer.
Here's the total info output:
currentBytesPerSecond=0
byteCount=0
maxBytesPerSecond=0
audioBytesPerSecond=0
audioByteCount=0
videoBytesPerSecond=0
videoByteCount=0
dataBytesPerSecond=0
dataByteCount=0
playbackBytesPerSecond=16296.296296296296
droppedFrames=0
audioBufferLength=0.072
videoBufferLength=0
dataBufferLength=0
audioBufferByteLength=1540
videoBufferByteLength=0
dataBufferByteLength=0
srtt=0
audioLossRate=0
videoLossRate=0 Data Bytes Per Second
That output was about 5 minutes in. I noted the playBackBytesPerSecond never changed, and the audioBufferByteLength liked to switch between 1540 and 23xx randomly.
Can anyone pleaaase help me out here?
My actionscript:
package
{
import flash.display.Sprite;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.media.Video;
import flash.text.TextFieldAutoSize;
import flash.text.TextField;
import flash.events.Event;
import flash.events.TimerEvent;
import flash.events.NetStatusEvent;
import flash.utils.Timer;
import flash.media.Sound;
import flash.net.URLRequest;
import flash.media.SoundChannel;
import flash.media.SoundMixer;
import flash.media.SoundTransform;
import flash.display.Loader;
import flash.errors.IOError;
import flash.events.MouseEvent;
import flash.geom.Rectangle;
import flash.net.NetStreamInfo;
import flash.utils.ByteArray;
import flash.media.*
public class soundContainer extends Sprite
{
public var slider:SliderMC = new SliderMC();
private var _video:Video;
private var _stream:NetStream;
private var _playbackTime:TextField;
private var _duration:uint;
private var _timer:Timer;
private var _soundChannel:SoundChannel;
public var audioTransform:SoundTransform = new SoundTransform();
public var _URL:String;
public var flvUrl:String = "s";
public var dragging:Boolean = false;
public var rectangle:Rectangle = new Rectangle(0,0,100,0);
private var ba:ByteArray;
private var bn;
public function soundContainer() {
addEventListener(Event.ADDED_TO_STAGE, init);
}
public function init(e:Event):void
{
ba = new ByteArray();
slider.x = 73.85;
slider.y = 10.95;
addChild(slider);
slider.slider_mc.addEventListener(MouseEvent.MOUSE_DOWN, dragIt);
stage.addEventListener(MouseEvent.MOUSE_UP, dropIt);
_timer = new Timer(1000);
_timer.addEventListener(TimerEvent.TIMER, onTimer);
_timer.start();
}
public function dragIt(e:MouseEvent):void
{
slider.slider_mc.startDrag(false, rectangle);
dragging = true;
slider.slider_mc.addEventListener(Event.ENTER_FRAME, adjustVolume);
}
public function dropIt(e:MouseEvent = null):void
{
if (dragging)
{
slider.slider_mc.stopDrag();
dragging = false;
}
}
public function adjustVolume(e:Event):void
{
var vol:Number = slider.slider_mc.x / 100;
var st:SoundTransform = new SoundTransform(vol);
SoundMixer.soundTransform = st;
}
public function playMyFlv(flvUrl)
{
_URL = flvUrl;
_video = new Video();
var connection:NetConnection = new NetConnection();
connection.connect(null);
_stream = new NetStream(connection);
_stream.soundTransform = audioTransform;
_stream.play(flvUrl);
var Client:Object = new Object();
_stream.client = Client;
_video.attachNetStream(_stream);
addChild(_video);
}
public function stopMyFlv()
{
SoundMixer.stopAll();
trace("stop");
try
{
_stream.close();
}
catch (error:IOError)
{
}
}
private function onNetStatus(e:NetStatusEvent)
{
}
private function onTimer(t:TimerEvent):Number
{
trace(_stream.info + " Data Bytes Per Second");
}
public function onIOError(e:IOError)
{
trace("Failed to load");
}
}
}