Comunidad de diseño web y desarrollo en internet online

Ayuda

Citar            
MensajeEscrito el 29 Jun 2009 01:09 pm
Saludos! en el siguiente codigo tengo un problema, y es que el codigo que coloco a continuacion, me bloquea la posibilidad de ejecutar cualquier accion, sea de timeline, o de boton, y yo necesito colocar dos botones, uno que me lleve a un URL y otro que haga quit....alguien sabe como se podria hacer esto?

Código ActionScript :

Stage.scaleMode = 'Scale';

/*
This examples shows how bitmaps can be used to erase or redraw
another bitmap using its alpha channel.
*/

var tool; // used to determine the current tool
var toolsize = 40; // size used for tools (width = height)
var tooloffset = toolsize/2; // offset for cursor placement in using tool
var basepoint = new flash.geom.Point(0, 0); // 0,0 point

// two bitmaps are used with the image being manipulated
// the first, origbmp contains the original image, unaltered
// the second, drawbmp is the working image seen and
// altered on the screen
var origbmp = flash.display.BitmapData.loadBitmap("dragon_bmp");
var drawbmp = new flash.display.BitmapData(origbmp.width, origbmp.height, true, 0);
// drawbmp starts with a copy of the original
drawbmp.draw(origbmp);

// two bitmaps are used for the tools, one for erasing
// and one for redrawing, both same size and settings
var erasebmp = new flash.display.BitmapData(toolsize, toolsize, true, 0);
var redrawbmp = erasebmp.clone();

// create a movie clip, image_mc, to hold the
// image being erased and redrawn
this.createEmptyMovieClip("image_mc", 1);
// position the image to the left
image_mc._x = 0;

// attach the drawing bitmap data object to image_mc
image_mc.attachBitmap(drawbmp, 1);

// -------------------------------------

// TOOLS

// select erase tool
erase_btn.onPress = function(){
   
   // tell button movie clips to navigate to appropriate state
   this.gotoAndStop(2);
   redraw_btn.gotoAndStop(1);
   
   // assign tool to equal "erase"
   // this is checked when drawing starts
   tool = "erase";
}

// select redraw tool
redraw_btn.onPress = function(){
   
   // tell button movie clips to navigate to appropriate state
   this.gotoAndStop(2);
   erase_btn.gotoAndStop(1);
   
   // assign tool to equal "redraw"
   // this is checked when drawing starts
   tool = "redraw";
}

// -------------------------------------

// BRUSHES

// select circle brush
circle_btn.onPress = function(){
   
   // tell button movie clips to navigate to appropriate state
   this.gotoAndStop(2);
   line_btn.gotoAndStop(1);
   
   // call setToolShape with circle_mc to set
   // the tool(s) shape(s) to a circle
   setToolShape(circle_mc);
}
// select line brush
line_btn.onPress = function(){
   
   // tell button movie clips to navigate to appropriate state
   this.gotoAndStop(2);
   circle_btn.gotoAndStop(1);
   
   // call setToolShape with circle_mc to set
   // the tool(s) shape(s) to a line
   setToolShape(line_mc);
}

function setToolShape(shape_mc){
   
   // erasebmp needs to be transparent where it is supposed to
   // be erasing drawbmp.  First fill it with solid white
   erasebmp.fillRect(erasebmp.rectangle, 0xFFFFFFFF);
   // then draw the shape (black) into the bitmap
   erasebmp.draw(shape_mc);
   // copyChannel is used to convert the shape of the tool
   // just added into erasebmp into its alpha channel
   erasebmp.copyChannel(erasebmp, erasebmp.rectangle, basepoint, 1, 8);

   // redrawbmp needs to be solid where it redraws drawbmp
   // fill redrawbmp with invisible black (0x00000000) 
   redrawbmp.fillRect(redrawbmp.rectangle, 0);
   // add the shape (solid color)
   redrawbmp.draw(shape_mc);
}

// -------------------------------------

// WORKING WITH IMAGE

// pressing image to erase or redraw
image_mc.onPress = function(){
   
   // depending on selected tool, assign onMouseMove event handler
   if (tool == "erase") this.onMouseMove = useEraserMouseMove;
   else if (tool == "redraw") this.onMouseMove = useRedrawMouseMove;
   
   // initiate onMouseMove handler to work with onPress
   this.onMouseMove();
}

// releasing after erase or redraw
image_mc.onRelease = image_mc.onReleaseOutside = function(){
   
   // remove onMouseMove handler
   delete this.onMouseMove;
}

// onMouseMove event handler for erasing
function useEraserMouseMove(){
   
   // devise an offset based on the mouse's
   // position in image_mc and tooloffset
   var offset = new flash.geom.Point(image_mc._xmouse - tooloffset, image_mc._ymouse - tooloffset);
   
   // devise a drawing rectangle the size of the
   // the drawing tools at the offset's location
   var drawRect = new flash.geom.Rectangle(offset.x, offset.y, toolsize, toolsize);
   
   // next, copy pixels from the drawbmp back onto itself
   // (makes for no change) but use erasebmp as the alphaBitmap
   // this will add the alpha channel information from erasebmp
   // into drawbmp erasing pixels from drawbmp in the shape of erasebmp
   drawbmp.copyPixels(drawbmp, drawRect, offset, erasebmp, basepoint, false);
   
   // update after each mouse movement
   updateAfterEvent();
}

// onMouseMove event handler for redrawing
function useRedrawMouseMove(){
   
   // devise an offset based on the mouse's
   // position in image_mc and tooloffset
   var offset = new flash.geom.Point(image_mc._xmouse - tooloffset, image_mc._ymouse - tooloffset);
   
   // devise a drawing rectangle the size of the
   // the drawing tools at the offset's location
   var drawRect = new flash.geom.Rectangle(offset.x, offset.y, toolsize, toolsize);
   
   // next, copy pixels from the original bitmap back
   // onto drawbmp to update the image. redrawbmp is
   // used as the alphaBitmap to give the tool shape
   drawbmp.copyPixels(origbmp, drawRect, offset, redrawbmp, basepoint, true);
   
   // update after each mouse movement
   updateAfterEvent();
}

// -------------------------------------

// initialize
erase_btn.onPress(); // start with erase tool
circle_btn.onPress(); // start with circle brush

Por omargalavis

2 de clabLevel



 

firefox
Citar            
MensajeEscrito el 29 Jun 2009 07:22 pm

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 29 Jun 2009 08:20 pm
gracias, no sabia esto! muy amable............. tienes idea de la ayuda que solicito?

Por omargalavis

2 de clabLevel



 

firefox
Citar            
MensajeEscrito el 29 Jun 2009 08:24 pm
Solo dices que algo no anda, no considero eso una pregunta, pero quizás alguien con mas paciencia ...

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.