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

Por que fscommand en AS 3, alenta los gráficos y funciona con ERRORES!

Estas en el tema de Por que fscommand en AS 3, alenta los gráficos y funciona con ERRORES! en el foro de Flash y Actionscript en Foros del Web. Hola amigos de forosdelweb. Tengo este código en el Frame 1 de mi película principal: Código: import flash.system.fscommand; import gs.*; fscommand("fullscreen", "true"); fscommand("allowscale", "false"); flabody.x ...
  #1 (permalink)  
Antiguo 05/07/2010, 08:25
Avatar de buhomorado  
Fecha de Ingreso: enero-2005
Mensajes: 324
Antigüedad: 19 años, 3 meses
Puntos: 1
Por que fscommand en AS 3, alenta los gráficos y funciona con ERRORES!

Hola amigos de forosdelweb.
Tengo este código en el Frame 1 de mi película principal:

Código:
import flash.system.fscommand;
import gs.*;

fscommand("fullscreen", "true");
fscommand("allowscale", "false");

flabody.x = flabody.y = 30;
titulos.x = 2480;

var cargaGal:Loader = new Loader;
var cualGal:URLRequest = new URLRequest("swf/GALERIA_.swf");
cargaGal.load(cualGal);
addChild(cargaGal);

trace (cargaGal.x);
cargaGal.y = -1468;

var coraje:String;
var dondeestamos:String = "inicio";

magicbox.gotoAndPlay (2);

stop();

Tengo en mi escenario una instancia de un VIDEOPLAYER AS 3 que baje por ahí, con sig. código:
[CODE]



--- Ese si lo baje.

Ademas tengo este SoundPlayer, que importa una clase externa llamada Sonido.as, que también baje:
Es un MovieClip con 2 Fotogramas, al cual yo le agregue un tercero, por que quería que cuando le dieras clic al video se callara el loop de fondo, y al cambiar de escena volviera a "tocar". Más me encontre con el problema de que el usuario podría querer apagar de por vida el sonido y por eso creé un tercer fotograma.

EN este Clip que controla el sonido,


///////////////fotograma 1:::::::::::::::::::::::::::::

Código:
import flash.media.SoundMixer;

import Sonido;
var so:Sonido=new Sonido("musica.mp3",3,0,-1);

MovieClip(this.root).coraje="ruido"



function siguiente(e:MouseEvent):void {
	gotoAndStop(3);
}

suena.addEventListener(MouseEvent.CLICK, siguiente);

stop();
///////////// fotograma 2:::::::::::::::::::::::::::::::::::

Código:
import flash.media.SoundMixer;

import Sonido;
var so:Sonido=new Sonido("musica.mp3",3,0,-1);

MovieClip(this.root).coraje="ruido"



function siguiente(e:MouseEvent):void {
	gotoAndStop(3);
}

suena.addEventListener(MouseEvent.CLICK, siguiente);

stop();
////// fotograma 3::::::::::::::::::::::::::::::::::::::

Código:
import flash.media.SoundMixer;

import Sonido;
var so:Sonido=new Sonido("musica.mp3",3,0,-1);

MovieClip(this.root).coraje="ruido"



function siguiente(e:MouseEvent):void {
	gotoAndStop(3);
}

suena.addEventListener(MouseEvent.CLICK, siguiente);

stop();
///////


Y arriba tengo un Menu con 5 botones, cada uno de los cuales posee el sig. código:

Código:
import gs.*;
import gs.easing.*;
import caurina.transitions.*;
import caurina.transitions.properties.DisplayShortcuts;
DisplayShortcuts.init();

stop();

useHandCursor= true;
buttonMode=true;

gis.addEventListener (MouseEvent.CLICK, ira);
gis.addEventListener (MouseEvent.MOUSE_OVER, sobre);
gis.addEventListener (MouseEvent.MOUSE_OUT, fuera);

function sobre (evt:MouseEvent):void {
	Tweener.
	addTween(this,{_frame:15, time:0.5, transition:"linear"}
		 )
	}
	
function fuera (evt:MouseEvent):void {
	Tweener.addTween(this,{_frame:0, time:0.5, transition:"linear"}
		 )
	}


function ira(evt:MouseEvent):void{
	if( MovieClip (this.root).coraje != "silencio"){
		MovieClip(this.root).menuazul.rey.pie.soneto.gotoAndStop(1);
		}
		/// Detiene Video
	
	MovieClip(this.root).magicbox.nsStream.pause();
    MovieClip(this.root).magicbox.nsStream.seek(0);
	MovieClip(this.root).magicbox.vidDisplay.visible = false;
    
	MovieClip(this.root).magicbox.mcVideoControls.btnPause.visible = false;
	MovieClip(this.root).magicbox.mcVideoControls.btnPlay.visible = true;
	
	/////
	MovieClip(this.root).magicbox.gotoAndPlay(2);
    MovieClip(root).dondeestamos = "porquepublirey";
	trace (    "A ver que" + MovieClip(root).dondeestamos );
	TweenMax.to(MovieClip(this.parent.parent).cargaGal, 1.5,{y: -1768});
	TweenMax.to(MovieClip(this.parent).marillo, 1.5,{x: 184, width:180});
	TweenMax.to ( MovieClip(parent).tito.tirilla, 0.6, {y:-46.5});
	TweenMax.to(MovieClip(parent.parent).flabody, 4.5, {x:-2078, ease:Elastic.easeOut});
	
			TweenMax.to (MovieClip(this.root).magicbox , 2.45, {y:105, delay:1.9, ease:Elastic.easeOut});
	
	TweenMax.to(MovieClip(this.parent), 2.5, {y:690, delay:0.3, ease:Elastic.easeInOut});
			TweenMax.to(MovieClip(this.parent).rey, 1.5, {y:5.5, ease:Elastic.easeInOut});
	TweenMax.to(MovieClip(this.parent.parent).titulos, 1.5, {x:650, delay:0.7, ease:Bounce.easeIn});
	
		TweenMax.to(MovieClip(this.parent.parent).titulos.vid_inicio,0.37, {alpha:0});
	TweenMax.to(MovieClip(this.parent.parent).titulos.vid_porquepublirey,0.37, {alpha:0});
	TweenMax.to(MovieClip(this.parent.parent).titulos.vid_servicios,0.37, {alpha:0});
	TweenMax.to(MovieClip(this.parent.parent).titulos.vid_ubicaciones,0.37, {alpha:0});

	}


EN RESUMEN, TODO FUNCIONA A LA PERFECCION EN EL FLASH PLAYER, PERO SOLAMENTE LO MANDO AL PROYECTOR Y ME HACE UN FIASCO... TODO SE ALENTA, NO FUNCIONAN LOS VIDEOS, EL SONIDO SE CORTA TODO HORRRIBLE ETC ETC...

PROBE EXPORTANDO A PROYECTOR SIN EL COMANDO "FULLSCREEN" Y ME DOY CUENTA DEQUE FUNCIONA PERFECTO....

ES EL MALDITO CODIGO PRINCIPAL QUE AQUI REPITO:



Código:
import flash.system.fscommand; ////// ESTE JODIDO CODIGO CAUSA ERROR
import gs.*;   /// ESTE No, NOMAS ANDO IMPORTANDO TweenMax

fscommand("fullscreen", "true");  ///// ESTE JODIDO FULLSCREEN ME PATEA LAS BOLAS
fscommand("allowscale", "false");  ///// Y ESTE OTRO KE SE VAYA A LA "(/"#$()#



//////////// DIOS SALVE A ACTIONSCRIPT 3, TODO ESTO SE VE BIEN SIN LAS P)")##)#))= DE ARRRIBA....
flabody.x = flabody.y = 30;
titulos.x = 2480;

var cargaGal:Loader = new Loader;
var cualGal:URLRequest = new URLRequest("swf/GALERIA_.swf");
cargaGal.load(cualGal);
addChild(cargaGal);

trace (cargaGal.x);
cargaGal.y = -1468;

var coraje:String;
var dondeestamos:String = "inicio";

magicbox.gotoAndPlay (2);

stop();

Y PARA LOS OPTIMISTAS, ME TEMO QUE NO, NO SEÑORES, la SOLUCION NO HA SIDO REEMPLAZAR ESE ESCUATO PALABRERIO COMANDERO POR ESTE OTRO PEDAZO DE CÓDIGO:

Código:
import flash.display.Stage;
import flash.display.StageDisplayState;
import flash.display.StageScaleMode;

stage.scaleMode = StageScaleMode.NO_SCALE;
stage.displayState = StageDisplayState.FULL_SCREEN;
POR QUE PASA EXACTITO LA MISMA "#U(//$())!".

GRACIAS CABALLEROS POR SU ATENCIÓN.
  #2 (permalink)  
Antiguo 05/07/2010, 08:27
Avatar de buhomorado  
Fecha de Ingreso: enero-2005
Mensajes: 324
Antigüedad: 19 años, 3 meses
Puntos: 1
Respuesta: Por que fscommand en AS 3, alenta los gráficos y funciona con ERRORES!

AQUI ESTA EL CÓDIGO DEL VIDEOPLAYER QUE FALTO:

Código:
// ##########################
// ############# CONSTANTS
// ##########################

// time to buffer for the video in sec.
const BUFFER_TIME:Number				= 8;
// start volume when initializing player
const DEFAULT_VOLUME:Number				= 0.6;
// update delay in milliseconds.
const DISPLAY_TIMER_UPDATE_DELAY:int	= 10;
// smoothing for video. may slow down old computers
const SMOOTHING:Boolean					= true;

// ##########################
// ############# VARIABLES
// ##########################

// flag for knowing if flv has been loaded
var bolLoaded:Boolean					= false;
// flag for volume scrubbing
var bolVolumeScrub:Boolean				= false;
// flag for progress scrubbing
var bolProgressScrub:Boolean			= false;
// holds the last used volume, but never 0
var intLastVolume:Number				= DEFAULT_VOLUME;
// net connection object for net stream
var ncConnection:NetConnection;
// net stream object
var nsStream:NetStream;
// object holds all meta data
var objInfo:Object;
// url to flv file
var strSource:String					= "VIDEOS/" + MovieClip(root).dondeestamos + ".flv";
trace (strSource);

// timer for updating player (progress, volume...)
var tmrDisplay:Timer;

// ##########################
// ############# FUNCTIONS
// ##########################

// sets up the player
function initVideoPlayer():void {
	// hide buttons
	mcVideoControls.btnUnmute.visible	= false;
	mcVideoControls.btnPause.visible	= false;
	
	// set the progress/preload fill width to 1
	mcVideoControls.mcProgressFill.mcFillRed.width = 1;
	mcVideoControls.mcProgressFill.mcFillGrey.width = 1;
	
	// add global event listener when mouse is released
	this.addEventListener( MouseEvent.MOUSE_UP, mouseReleased);
	
	// add event listeners to all buttons
	mcVideoControls.btnPause.addEventListener(MouseEvent.CLICK, pauseClicked);
	mcVideoControls.btnPlay.addEventListener(MouseEvent.CLICK, playClicked);
	mcVideoControls.btnStop.addEventListener(MouseEvent.CLICK, stopClicked);
	mcVideoControls.btnMute.addEventListener(MouseEvent.CLICK, muteClicked);
	mcVideoControls.btnUnmute.addEventListener(MouseEvent.CLICK, unmuteClicked);
	mcVideoControls.mcVolumeScrubber.btnVolumeScrubber.addEventListener(MouseEvent.MOUSE_DOWN, volumeScrubberClicked);
	mcVideoControls.mcProgressScrubber.btnProgressScrubber.addEventListener(MouseEvent.MOUSE_DOWN, progressScrubberClicked);
	
	// create timer for updating all visual parts of player and add
	// event listener
	tmrDisplay = new Timer(DISPLAY_TIMER_UPDATE_DELAY);
	tmrDisplay.addEventListener(TimerEvent.TIMER, updateDisplay);
	
	// create a new net connection, add event listener and connect
	// to null because we don't have a media server
	ncConnection = new NetConnection();
	ncConnection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
	ncConnection.connect(null);
	
	// create a new netstream with the net connection, add event
	// listener, set client to this for handling meta data and
	// set the buffer time to the value from the constant
	nsStream = new NetStream(ncConnection);
	nsStream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
	nsStream.client = this;
	nsStream.bufferTime = BUFFER_TIME;
	
	// attach net stream to video object on the stage
	vidDisplay.attachNetStream(nsStream);
	// set the smoothing value from the constant
	vidDisplay.smoothing = SMOOTHING;

	// set default volume
	mcVideoControls.mcVolumeScrubber.x = (52 * DEFAULT_VOLUME) + 341;
	mcVideoControls.mcVolumeFill.mcFillRed.width = mcVideoControls.mcVolumeScrubber.x - 394 + 52;
	setVolume(DEFAULT_VOLUME);
}

function playClicked(e:MouseEvent):void {
	
	MovieClip(this.root).menuazul.rey.pie.soneto.gotoAndStop(2);
	
	// check's, if the flv has already begun
	// to download. if so, resume playback, else
	// load the file
	if(!bolLoaded) {
		nsStream.play(strSource);
		bolLoaded = true;
	}
	else{
		nsStream.resume();
	}
	
	// show video display
	vidDisplay.visible = true;
	
	// switch play/pause visibility
	mcVideoControls.btnPause.visible = true;
	mcVideoControls.btnPlay.visible = false;
}

function pauseClicked(e:MouseEvent):void {
	// pause video
	nsStream.pause();
	
	// switch play/pause visibility
	mcVideoControls.btnPause.visible = false;
	mcVideoControls.btnPlay.visible = true;
}

function stopClicked(e:MouseEvent):void {
	// calls stop function
	stopVideoPlayer();
}

function muteClicked(e:MouseEvent):void {
	// set volume to 0
	setVolume(0);
	
	// update scrubber and fill position/width
	mcVideoControls.mcVolumeScrubber.x				= 341;
	mcVideoControls.mcVolumeFill.mcFillRed.width	= 1;

}

function unmuteClicked(e:MouseEvent):void {
	// set volume to last used value
	setVolume(intLastVolume);

	// update scrubber and fill position/width
	mcVideoControls.mcVolumeScrubber.x = (53 * intLastVolume) + 341;
	mcVideoControls.mcVolumeFill.mcFillRed.width = mcVideoControls.mcVolumeScrubber.x - 394 + 53;
}

function volumeScrubberClicked(e:MouseEvent):void {
	// set volume scrub flag to true
	bolVolumeScrub = true;
	
	// start drag
	mcVideoControls.mcVolumeScrubber.startDrag(false, new Rectangle(341, 19, 53, 0));
}

function progressScrubberClicked(e:MouseEvent):void {
	// set progress scrub flag to true
	bolProgressScrub = true;
	
	// start drag
	mcVideoControls.mcProgressScrubber.startDrag(false, new Rectangle(0, 2, 432, 0));
}

function mouseReleased(e:MouseEvent):void {
	// set progress/volume scrub to false
	bolVolumeScrub		= false;
	bolProgressScrub	= false;
	
	// stop all dragging actions
	mcVideoControls.mcProgressScrubber.stopDrag();
	mcVideoControls.mcVolumeScrubber.stopDrag();
	
	// update progress/volume fill
	mcVideoControls.mcProgressFill.mcFillRed.width	= mcVideoControls.mcProgressScrubber.x + 5;
	mcVideoControls.mcVolumeFill.mcFillRed.width	= mcVideoControls.mcVolumeScrubber.x - 394 + 53;
	
	// save the volume if it's greater than zero
	if((mcVideoControls.mcVolumeScrubber.x - 341) / 53 > 0)
		intLastVolume = (mcVideoControls.mcVolumeScrubber.x - 341) / 53;
}

function updateDisplay(e:TimerEvent):void {
	// checks, if user is scrubbing. if so, seek in the video
	// if not, just update the position of the scrubber according
	// to the current time
	if(bolProgressScrub)
		nsStream.seek(Math.round(mcVideoControls.mcProgressScrubber.x * objInfo.duration / 432))
	else
		mcVideoControls.mcProgressScrubber.x = nsStream.time * 432 / objInfo.duration; 
	
 
	mcVideoControls.lblTimeDuration.htmlText		= "<font color='#ffffff'>" + formatTime(nsStream.time) + "</font> / " + formatTime(objInfo.duration);
	
	// update the width from the progress bar. the grey one displays
	// the loading progress
	mcVideoControls.mcProgressFill.mcFillRed.width	= mcVideoControls.mcProgressScrubber.x + 5;
	mcVideoControls.mcProgressFill.mcFillGrey.width	= nsStream.bytesLoaded * 438 / nsStream.bytesTotal;
	
	// update volume and the red fill width when user is scrubbing
	if(bolVolumeScrub) {
		setVolume((mcVideoControls.mcVolumeScrubber.x - 341) / 53);
		mcVideoControls.mcVolumeFill.mcFillRed.width = mcVideoControls.mcVolumeScrubber.x - 394 + 53;
	}
}

function onMetaData(info:Object):void {
	// stores meta data in a object
	objInfo = info;
	
	// now we can start the timer because
	// we have all the neccesary data
	tmrDisplay.start();
}

function netStatusHandler(event:NetStatusEvent):void {
	// handles net status events
	switch (event.info.code) {
		// trace a messeage when the stream is not found
		case "NetStream.Play.StreamNotFound":
			trace("Stream not found: " + strSource);
		break;
		
		// when the video reaches its end, we stop the player
		case "NetStream.Play.Stop":
			stopVideoPlayer();
		break;
	}
}

function stopVideoPlayer():void {
	// pause netstream, set time position to zero
	nsStream.pause();
	nsStream.seek(0);
	
	// in order to clear the display, we need to
	// set the visibility to false since the clear
	// function has a bug
	vidDisplay.visible					= false;
	
	// switch play/pause button visibility
	mcVideoControls.btnPause.visible	= false;
	mcVideoControls.btnPlay.visible		= true;
}

function setVolume(intVolume:Number = 0):void {
	// create soundtransform object with the volume from
	// the parameter
	var sndTransform		= new SoundTransform(intVolume);
	// assign object to netstream sound transform object
	nsStream.soundTransform	= sndTransform;
	
	// hides/shows mute and unmute button according to the
	// volume
	if(intVolume > 0) {
		mcVideoControls.btnMute.visible		= true;
		mcVideoControls.btnUnmute.visible	= false;
	} else {
		mcVideoControls.btnMute.visible		= false;
		mcVideoControls.btnUnmute.visible	= true;
	}
}

function formatTime(t:int):String {
	// returns the minutes and seconds with leading zeros
	// for example: 70 returns 01:10
	var s:int = Math.round(t);
	var m:int = 0;
	if (s > 0) {
		while (s > 59) {
			m++;
			s -= 60;
		}
		return String((m < 10 ? "0" : "") + m + ":" + (s < 10 ? "0" : "") + s);
	} else {
		return "00:00";
	}
}

// ##########################
// ############# INIT PLAYER
// ##########################
initVideoPlayer();

Etiquetas: fscommand
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 03:26.