2 Replies Latest reply on Nov 14, 2008 5:10 PM by Gregory Lafrance

    Displaying a shape

    jcahill23 Level 1
      Hi.
      Opened a new Flex Project and was just messing around to see if I could create a shape in AS3 in b/w <Script> tags and display it when a button was clicked....but I keep getting a 1034 error....i'm sure it's simple...do I need to create some kind of "stage" like in flash cs3....? thanks.

      <?xml version="1.0" encoding="utf-8"?>
      <mx:WindowedApplication xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">

      <mx:Script>
      <![CDATA[

      import flash.display.*;

      public function show_shape():void {

      var rect:Shape = new Shape();
      rect.graphics.lineStyle(1);
      rect.graphics.beginFill(0x0000FF);
      rect.graphics.drawRect(0,0,150,75);
      addChild(rect);
      }

      ]]>
      </mx:Script>
      <mx:Button x="221" y="54" label="shape" click="show_shape()"/>

      </mx:WindowedApplication>
        • 1. Re: Displaying a shape
          Level 7
          And off the top of my head I'm sure I don' know what the text of a 1034
          error would be.

          Probly has something to do with the fact that you're trying to add something
          that's not a UIComponent to a container though.

          "jcahill23" <webforumsuser@macromedia.com> wrote in message
          news:gfkqf4$s5t$1@forums.macromedia.com...
          > Hi.
          > Opened a new Flex Project and was just messing around to see if I could
          > create
          > a shape in AS3 in b/w <Script> tags and display it when a button was
          > clicked....but I keep getting a 1034 error....i'm sure it's simple...do I
          > need
          > to create some kind of "stage" like in flash cs3....? thanks.
          >
          > <?xml version="1.0" encoding="utf-8"?>
          > <mx:WindowedApplication xmlns:mx=" http://www.adobe.com/2006/mxml"
          > layout="absolute">
          >
          > <mx:Script>
          > <![CDATA[
          >
          > import flash.display.*;
          >
          > public function show_shape():void {
          >
          > var rect:Shape = new Shape();
          > rect.graphics.lineStyle(1);
          > rect.graphics.beginFill(0x0000FF);
          > rect.graphics.drawRect(0,0,150,75);
          > addChild(rect);
          > }
          >
          > ]]>
          > </mx:Script>
          > <mx:Button x="221" y="54" label="shape" click="show_shape()"/>
          >
          > </mx:WindowedApplication>
          >
          >


          • 2. Re: Displaying a shape
            Gregory Lafrance Level 6
            var uic:UIComponent = new UIComponent();
            uic.addChild(rect);
            this.addChild(uic);