Foros del Web » Creando para Internet » Flash y Actionscript »

Error #1009: Cannot access a property or method of a null object reference

Estas en el tema de Error #1009: Cannot access a property or method of a null object reference en el foro de Flash y Actionscript en Foros del Web. Muy buenas, estoy montando un player con play/pause en as3 y funciona bien, pero al clickar sobre el pause me da el siguiente error: TypeError: ...
  #1 (permalink)  
Antiguo 25/08/2011, 08:30
 
Fecha de Ingreso: agosto-2011
Mensajes: 3
Antigüedad: 12 años, 7 meses
Puntos: 0
Error #1009: Cannot access a property or method of a null object reference

Muy buenas,
estoy montando un player con play/pause en as3 y funciona bien, pero al clickar sobre el pause me da el siguiente error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Player_as3_prueba4_fla::MainTimeline/onEnterFrame()

El caso es que aun y así la accion de pause se genera bien y funciona. El problema viene porque a este player se le debe llamar mediante un externalInterface desde java...y allí es cuando este problema cobra presencia, ya que es entonces cuando no hace el pause y aparece en el navegador el siguiente error:

Error calling method on NPObject.


Pongo todo el codigo (el del external interface también) a ver si alguien me puede echar un cable.

Graciaaaas! *-*


import flash.events.Event;
import flash.media.Sound;
import flash.net.URLRequest;
import flash.external.ExternalInterface;

var keyStr:String;var valueStr:String;
var texto3:String;

var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;


for (keyStr in paramObj) {
valueStr = String(paramObj[keyStr]);

if(keyStr == "parametro1"){
trace(valueStr);

texto3=valueStr;
//valueStr="http://av.adobe.com/podcast/csbu_dev_podcast_epi_2.mp3";
}
if(keyStr == "parametro2"){
trace(valueStr);
}

}



var snd:Sound = new Sound(new URLRequest("sound.mp3"));
/*var req:URLRequest = new
URLRequest(texto3);
snd.load(req); */

var channel:SoundChannel = snd.play();

var pausePosition:int;
channel.stop();
channel = null;
var musicOn:Boolean = false



function pauseSound(event:MouseEvent):void{
pausePosition = channel.position;
channel.stop();
channel = null;
trace("pauseee!!!");
}
pause_btn.addEventListener(MouseEvent.CLICK, pauseSound);

function playSound(e:Event):void {
if (channel == null){
channel = snd.play(pausePosition);
addEventListener(Event.ENTER_FRAME, onEnterFrame);
channel.addEventListener(Event.SOUND_COMPLETE, onPlaybackComplete);
}

}

play_btn.addEventListener(MouseEvent.CLICK, playSound);


function onEnterFrame(event:Event):void
{
var estimatedLength:int =
Math.ceil(snd.length / (snd.bytesLoaded / snd.bytesTotal));
var playbackPercent:uint =
Math.round(100 * (channel.position / estimatedLength));
trace("Sound playback is " + playbackPercent + "% complete.");
}

function onPlaybackComplete(event:Event)
{
trace("The sound has finished playing.");
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
musicOn=false;
}

//EXTERNAL INTERFACE
function sonidoPlay() {
if (channel == null){
channel = snd.play(pausePosition);
addEventListener(Event.ENTER_FRAME, onEnterFrame);
channel.addEventListener(Event.SOUND_COMPLETE, onPlaybackComplete);
}
}

ExternalInterface.addCallback( "playSWF", sonidoPlay );

function sonidoPause(event:MouseEvent):void{
pausePosition = channel.position;
channel.stop();
channel = null;
}
ExternalInterface.addCallback( "pauseSWF", sonidoPause );
  #2 (permalink)  
Antiguo 31/08/2011, 05:25
 
Fecha de Ingreso: agosto-2011
Mensajes: 3
Antigüedad: 12 años, 7 meses
Puntos: 0
Respuesta: Error #1009: Cannot access a property or method of a null object reference

Ya está solucionado, gracias.

Etiquetas: as3, null, pause, player
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 07:54.