r/ActionScript3 • • Oct 17 '16

Recovering from disconnection while publishing a stream

1 Upvotes

I have an app that records webcam/mic into AMS, but recently our IE/Edge users started having issues because flash was disconnecting and reconnecting a few times during the record process. The result is that during the period of the connection been lost and recovered, everything the user says/does is lost (much like Youtubers cuts), because we have to open a new connection, create a new stream and publish(vid,'append') it.

I have already tried to (1)use the same NetConnection and simply call "connect" again, and (2)tried open a new connection and attach it to the current NetStream object (already set using some bufferTime), but in both cases the NetStream call to .publish() does not reach the server.

So far I could not find any solution that would allow me to keep recording while the connection is been remade.


r/ActionScript3 • • Dec 29 '14

.swf file is lagging when I try the animation but not while I preview it on Flash

1 Upvotes

Hello,

I've started a file in Flash CS6 that includes animation and actionscript 3 and everything looked fine when I previewed it with CTRL + ENTER during the process. After I saved and closed my .fla I tried the .swf and it is lagging whenever I reach the part that involved most of the complicated actionscript.

I already tried to downsize the preview settings quality and it's still lagging at 20, so I'm not really sure if it's the actionscript itself.

stop();


var lineSize:Number=400;
// doDraw is true when user's mouse is down
var doDraw:Boolean=false;
// resumeDrawing is true when user drags their mouse off stage while drawing
var resumeDrawing:Boolean=false;

/*
Create a bitmap to act as our image mask
Add it to stage & cache as bitmap
*/
var erasableBitmapData:BitmapData = new BitmapData(1280, 768, true, 0xFFFFFFFF);
var erasableBitmap:Bitmap = new Bitmap(erasableBitmapData);
erasableBitmap.cacheAsBitmap = true;
addChild(erasableBitmap);

/*
Set the erasable bitmap as a mask of our image & cache image as bitmap
*/
puddle_mc.cacheAsBitmap = true;
puddle_mc.mask = erasableBitmap;

/*************************
ERASER
**************************/

/*
Create a sprite for drawing the eraser lines onto
Set its lineStyle, and move the line to the current mouse x,y
*/
var eraserClip:Sprite = new Sprite();
initEraser();
function initEraser():void {
	eraserClip.graphics.lineStyle(lineSize,0xff0000);
	eraserClip.graphics.moveTo(stage.mouseX,stage.mouseY);
}

/* 
This is required to ensure a smooth erase effect (applying eraserClip 
directly to erasableBitmapData leaves jaggy edges  around alpha areas. 
If anyone knows why, I'd love to know!)
*/
var drawnBitmapData:BitmapData = new BitmapData(1280, 768, true, 0x00000000);
var drawnBitmap:Bitmap = new Bitmap(drawnBitmapData);

/*************************
MOUSE EVENTS
**************************/

/*
Add event listeners for mouse movements
*/
stage.addEventListener(MouseEvent.MOUSE_MOVE,puddle_mcMove);
stage.addEventListener(MouseEvent.ROLL_OUT, puddle_mcOut); 
stage.addEventListener(MouseEvent.ROLL_OVER,puddle_mcOver);
stage.addEventListener(MouseEvent.MOUSE_DOWN,startDrawing);
stage.addEventListener(MouseEvent.MOUSE_UP,stopDrawing);

/*
Mouse down handler
Begin drawing
*/
function startDrawing(e:MouseEvent):void {
	eraserClip.graphics.moveTo(stage.mouseX,stage.mouseY);
	doDraw=true;
}

/*
Mouse up handler
Stop drawing
*/
function stopDrawing(e:MouseEvent):void {
	doDraw=false;
	resumeDrawing = false;
}

/*
Mouse out handler
If user was drawing when they moved mouse off stage, we will need
to resume drawing when they move back onto stage.
*/
function puddle_mcOut(e:Event):void {
	if (doDraw){
		resumeDrawing = true;
	}
}

/*
Mouse over handler
If user's mouse if still down, continue drawing from the point where 
the mouse re-entered the stage.
*/
function puddle_mcOver(e:MouseEvent):void {
	if (resumeDrawing){
		resumeDrawing = false;
		eraserClip.graphics.moveTo(stage.mouseX,stage.mouseY);
	}
}

/*
Mouse move handler
*/
function puddle_mcMove(e:MouseEvent):void {
	if (doDraw && !resumeDrawing){
		// Draw a line to current mouse position
		eraserClip.graphics.lineTo(stage.mouseX,stage.mouseY);
		// Clear the drawn bitmap by filling it with a transparent color
		drawnBitmapData.fillRect(drawnBitmapData.rect, 0x00000000); 
		// Copy our eraser drawing into the erasable bitmap
		// (This is required to ensure the smooth alpha edges on our eraser are retained)
		drawnBitmapData.draw(eraserClip , new Matrix(), null, BlendMode.NORMAL);
		// Fill the erasable bitmap with a solid color
		erasableBitmapData.fillRect(erasableBitmapData.rect, 0xFFFFFFFF);
		// Copy the scribble bitmap to our main bitmap, with blendmode set to ERASE
		// This erases the portion of the mask that has been drawn.
		erasableBitmapData.draw(drawnBitmap, new Matrix(), null, BlendMode.ERASE);
	}
	// Update after event to ensure no lag
	e.updateAfterEvent();
}
//MOUSE
Mouse.hide();

mouse_mc.visible = true;
mouseclick_mc.visible = false;



stage.addEventListener(Event.ENTER_FRAME, mouseFollower)
function mouseFollower (e:Event):void {
	mouse_mc.x = mouseX;
	mouse_mc.y = mouseY;
	mouseclick_mc.x = mouseX;
    mouseclick_mc.y = mouseY;
}

stage.addEventListener (MouseEvent.MOUSE_DOWN, mouseClicked)
function mouseClicked (e:Event):void {
	mouse_mc.visible = false;
	mouseclick_mc.visible = true;
}
stage.addEventListener (MouseEvent.MOUSE_UP, mouseRelease)
function mouseRelease (e:Event):void {
	mouse_mc.visible = true;
	mouseclick_mc.visible = false;
}

Thank you!


r/ActionScript3 • • Sep 08 '10

Standardize AS3 DI Metadata Tags

Thumbnail shaun.boyblack.co.za
2 Upvotes

r/ActionScript3 • • Jun 07 '13

Loading multiple images. Help!

1 Upvotes

I'm trying to load four images but I can't work out what's wrong with my code. Any help is greatly appreciated.

var loader:Loader;

function loadImage(url:String):void

{

loader = new Loader();

loader.load(new URLRequest("frame2_um.png"));

loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadedImage);

}

function loadedImage(e:Event):void

{

loader.x = 400;

loader.y = 500;

addChild(loader);

}

loadImage("frame2_um.png");


r/ActionScript3 • • Jun 02 '13

need help polishing my skills

2 Upvotes

so i recently took some actionscript classes and now that i'm finished i don't wan't my skills to deteriorate. at first i was just going to try doing an independent project, like making a video game. turns out thats A LOT harder than it sounds(can't come up with an idea, don't know what kind of game to make, and don't know where to start). so if anyone knows a site that has "assignments" i can complete to stay "in shape", that'd be great.


r/ActionScript3 • • Jun 04 '13

the border won't show...

1 Upvotes

i created a textbox for input and when i start the program the textbox has no border, but it is there. also i keep getting this error: 1151: A conflict exists with definition String in namespace internal.