1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
program survol;
uses Flash8;
{$FRAME_WIDTH 545}
{$FRAME_HEIGHT 150}
{$BACKGROUND $FAEBD7}
{$FRAME_RATE 30}
type
TRect=class(Rectangle)
constructor Create(x, y, width, height: Integer);
top,left,right,Bottom:integer;
end;
MyTextField=class(TextField)
boundsRect:TRect;
constructor Create(Parent: MovieClip; Name: string; Depth, Left, Top, Width, Height: Number);
end;
mymovie=class(movieclip)
ptmouse:Point;
myrect:TRect;
Format1: TextFormat;
Format2: TextFormat;
Field: MyTextField;
lien:movieClip;
constructor Create;
procedure onEnterFrame;
procedure dopress;
end;
function ptinrect(pt:Point;RECT:TRect):Boolean;
begin
if (pt.x>=rect.left) and (pt.x<=rect.right) and (pt.y>=rect.top) and (pt.y<=rect.Bottom) then result:=true else result:=False;
end;
constructor TRect.create(x, y, width, height: Integer);
begin
Inherited Create(x,y,width,height);
left:=x;
top:=y;
right:=x+width;
bottom:=y+height;
end;
constructor MyTextField.Create(Parent: MovieClip; Name: string; Depth, Left, Top, Width, Height: Number);
begin
inherited Create(Parent,name,Depth,Left, Top, Width, Height);
boundsRect:=TRect.Create( floor(Left),floor(Top), floor(Width),floor( Height)); //pas joli, ce serait plus pratique si les paramètres de rectangle étaient en number
end;
constructor mymovie.Create;
begin
inherited Create(nil,'mymovie',1);
lien:=MovieClip.Create(self,'',1);
lien.onPress:=dopress;
Format1 := TextFormat.Create('Arial', 25, $000000,true,false,true);
Format2 := TextFormat.Create('Arial', 25, $ff0000,true,false,true);
Field :=MyTextField.Create(lien, '', 1, 10,10,250,40);
Field.SetNewTextFormat(Format1);
Field.Text:='mon futur lien';
end;
procedure Mymovie.onEnterFrame;
begin
ptmouse:=Point.Create(_xmouse,_ymouse);
//si les ccords de la souris appartiennent à Field alors changer la couleur
if ptinrect(ptmouse,Field.boundsRect) then Field.SetNewTextFormat(Format2) else Field.SetNewTextFormat(Format1);
Field.Text:='mon futur lien';
end;
procedure Mymovie.dopress;
begin
getURL('www.developpez.com','','');
end;
begin
mymovie.Create;
end. |
Partager