Help me someone please. create a button using class

  • santalea
  • Born
  • Born
  • santalea
  • Posts: 1

Post 3+ Months Ago

how do i create a button using createClassObject?

Quote:
createClassObject(Button,"btnParam", 99, {_height:30, _width:60, _x:100, _y:100});
btnParam._visible = true;
btnParam.enabled = true;
btnParam.label = "Update Move";
btnParam._alpha = 100;


i did this but the button didnt appear.

also help me with another thing... how do i modify the below codes so that i do not need to use hitTest?

Quote:
var targetIndex:Number = 0;
//var xValues:Array = [100,200,220,300,330,370];
//var yValues:Array = [100,150,220,300,310,400];
var tarArray:Array = [[70,120], [80,215], [110,270], [170,320], [225,280], [300,360], [355,430], [520,380], [610,500]];
this.createEmptyMovieClip("line_mc", 1); //creating the line
this.attachMovie("arrowmc", "arrowmc", this.getNextHighestDepth()); //inserting the mc
line_mc.lineStyle(2, 0xFF00FF, 30);
line_mc.moveTo(tarArray[0][0], tarArray[0][1]); // starting point of the target
arrowmc._x = tarArray[targetIndex][0];
arrowmc._y = tarArray[targetIndex][1];

var move_int = setInterval(moveChaser,100); //setting time delay between movements
function moveChaser() {
//works out the angle in radians between tarArray[targetIndex] and arrowmc
var theta:Number = Math.atan2(tarArray[targetIndex][1] - arrowmc._y, tarArray[targetIndex][0] - arrowmc._x);
arrowmc._rotation = (theta * 180 / Math.PI)+90; //makes radians in to degrees and orientates it 90 more degrees

if(Math.abs((tarArray[targetIndex][0]-arrowmc._x)) > 2 || Math.abs((tarArray[targetIndex][1]-arrowmc._y)) > 2){
arrowmc._x += Math.cos(theta) * 3;
arrowmc._y += Math.sin(theta) * 3;
line_mc.lineTo(arrowmc._x , arrowmc._y);
}

if(arrowmc.hitTest(tarArray[targetIndex][0],tarArray[targetIndex][1],false)){
targetIndex++;
}

if(tarArray[targetIndex][0] == undefined){
clearInterval(move_int);
trace("successful");
}
updateAfterEvent();
};
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

better create your own button and customize it as you like, then just attachMovie from library.

about the hitTest, i dont know ... only if you consider the target object as a rectangular shape ... then you can test if _x and _y of the arrow are within the target area. Otherwise use hitTest since it implements collision detectetion between objects with different shapes than rectangular.
something like:
Code: [ Select ]
if (arrow._x >= target._x && arrow._x < target._x + target._width
&& arrow._y >= target._y && arrow._y < target._y + target.height)
{
  trace("arrow hitted the target");
}
  1. if (arrow._x >= target._x && arrow._x < target._x + target._width
  2. && arrow._y >= target._y && arrow._y < target._y + target.height)
  3. {
  4.   trace("arrow hitted the target");
  5. }

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 13 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.