Prasad,
 
What I may say about your code :
 
- the function line contains moveTo that you call each time you call the method line(). It's not a good practise.
moveTo is use at the beginning to set the first x,y coordinates, then you use lineTo to draw the shape you want.
 
- arrow seems to be a reserved name
 
- you must createEmptyMovieClip into a control otherwise your Movieclip is overrided by the application
 
I hope that it will help you!
David
 
function fArrow(x1:Number, y1:Number, x2:Number, y2:Number, size:Number, sharpness:Number, obj:Object):Void
 {
  var lines:MovieClip = new MovieClip();
  lines = obj.createEmptyMovieClip("line_mc", -1);
  
  var w:Number = x2 - x1;
  var h:Number = y2 - y1;
  var l:Number = Math.sqrt(w * w + h * h);
 //  Alert.show("w : " + w + " h : " + h + "l : " + l, "______Message__", Alert.OK);        // helpful for debugging, don't forget to import the concerned class;
  w *= size / l;
  h *= size / l;
  var s:Number = Math.sin(sharpness);
  var c:Number = Math.cos(sharpness);
       
  with (lines)
        {
   lineStyle(1, 0x999999, 100);
   moveTo(x1, y1);
   lineTo(x2, y2);
   lineTo(x2 - w * c - s * h, y2 + w * s - h * c);
   lineTo(x2 - w * c + s * h, y2 - w * s - h * c);
   endFill();
  }
 }
 
    function drawlines( event:Object):Void
 {
   fArrow(145, 25, 192, 88, 10, 0.4, event.target);
 }


De : flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] De la part de Prasad Dhananjaya
Envoyé : mardi 23 août 2005 11:53
À : flexcoders@yahoogroups.com
Objet : Re: [flexcoders] Calling functions

Hi,

Thank you very much for the reply.
I tried it. But still not working.(Didn't call "line()" and "arrow()" functions)
Any other errors?

Best Regards,
Prasad

----------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" >
<mx:Panel width="732" title="MyPanel" >
      <mx:Canvas id ="mycanvas" width="715" height="408" backgroundColor="#CCCCFF" initialize="drawlines(event.target)">
      </mx:Canvas>
</mx:Panel>

<mx:Script>
    <![CDATA[
function line(x1, y1, x2, y2) {
      moveTo(x1, y1);
      lineTo(x2, y2);
}
     
function arrow(x1, y1, x2, y2, size, sharpness) {
      var w = x2 - x1;
      var h = y2 - y1;
      var l = Math.sqrt(w * w + h * h);
      w *= size / l;
      h *= size / l;
      var s = Math.sin(sharpness);
      var c = Math.cos(sharpness);
      line(x1, y1, x2, y2);
      line(x2, y2, x2 - w * c - s * h, y2 + w * s - h * c);
      line(x2, y2, x2 - w * c + s * h, y2 - w * s - h * c);
}

    function drawlines(target)
      {
       var lines = target.createEmptyMovieClip("line_mc", 1);
           with (lines)
               {
                     lineStyle(1, 0xff0000, 100);
                     line(145, 25,192, 88);
                     arrow(100, 100, 300, 300, 10, 0.4);
           }
   }
]]>
</mx:Script>
</mx:Application>

----------------------------------------------------------------------------


> Hello,
>
> You had several errors in your script, try this variant:
>
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" >
> <mx:Panel width="732" title="MyPanel" >
>       <mx:Canvas id ="mycanvas" width="715" height="408"
> backgroundColor="#CCCCFF" initialize="drawlines(event.target)">
>       </mx:Canvas>
> </mx:Panel>
>
> <mx:Script>
>     <![CDATA[
>     function line(x1, y1, x2, y2)
>       {
>             trace("func line");
>       }
>      
>     function arrow(x1, y1, x2, y2, size)
>       {
>             trace("func arrow");
>       }
>
>     function drawlines(target)
>       {
>        var lines = target.createEmptyMovieClip("line_mc", 1);
>            with (lines)
>                {
>                      lineStyle(1, 0xff0000, 100);
>                      line(145, 25,192, 88);
>                      arrow(100, 100, 300, 300, 10, 0.4);
>            }
>    }
> ]]>
> </mx:Script>
> </mx:Application>
>
> Best regards
> Stanislav
>
> On 8/23/05, Prasad Dhananjaya <[EMAIL PROTECTED]> wrote:
> > Hi All,
> >
> > I have a small question.
> > I want to call function "line()" and function "arrow()" from
> > function "drawlines&Arrows()". I tried sevaral ways. But failed.
> > Can someone tell me how to do this?
> >
> > Best Regards,
> > Prasad
> > (Absolute beginner of Flex & ActionScript)
> >
> >
> > ----------------------------------------------------------------------------
> > <?xml version="1.0" encoding="utf-8"?>
> > <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" >
> > <mx:Panel width="732" title="MyPanel" >
> > <mx:Canvas id ="mycanvas" width="715" height="408" backgroundColor="#CCCCFF"
> >           initialize="drawlines&Arrows(event.target)">
> > </mx:Canvas>
> > </mx:Panel>
> >
> > <mx:Script>
> >     <![CDATA[
> >     function line(x1, y1, x2, y2) { moveTo(x1, y1);  lineTo(x2, y2);  }
> >     function arrow(x1, y1, x2, y2, size) { ..... }
> >
> >     function drawlines&Arrows(target) {
> >        var lines = target.createEmptyMovieClip("line_mc", 1);
> >            with (lines) {
> >            lineStyle(1, 0xff0000, 100);
> >            //★below  two lines are not working
> >            line(145, 25,192, 88);
> >            arrow(100, 100, 300, 300, 10, 0.4);
> >            }
> >    }
> > ]]>
> > </mx:Script>
> > </mx:Application>
> >
> >
> >
> >
> > --
> > Flexcoders Mailing List
> > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >

**********************************************************************

Coface facilite les echanges entre les entreprises partout dans le monde. Pour cela, elle offre a toutes les entreprises des solutions pour gerer, financer et proteger leur poste client, en leur permettant d'externaliser tout ou partie de la gestion et des risques lies a leurs relations commerciales. Coface est notee AA par Fitch Ratings et Aa3 par Moody's.

Pour en savoir plus, http://www.coface.fr

Coface facilitates business-to-business commerce worldwide. It offers all size companies an array of solutions to manage, finance, and protect their accounts receivables affording them the option of fully or partly outsourcing trade relationship management and attendant risks. Coface is rated AA by Fitch ratings and Aa3 by Moody's.

More about Coface, http://www.coface.com

WARNING :

- Soyez conscient que notre systeme Anti-Spam peut parfois rejeter des messages, soit parce que certains mots et types de fichiers ne sont pas acceptes, ou bien parce que le mail n'a pas ete identifie correctement.

- Be aware that from time to time our Anti-Spam system may reject mails either because some words and types of files are not allowed or because mails are misidentified.

**********************************************************************



--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




YAHOO! GROUPS LINKS




Reply via email to