Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 03-25-2006, 11:34 AM   #1
john100
Registered User
 
Join Date: Feb 2006
Posts: 22
Default Any one know how to do drawing in actionscript?

Here the code, it cause error because it try to convert graphics to UI Component
Code:
<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    creationComplete="initApp()"  backgroundAlpha="0">

<mx:Script>
import  flash.display.*;
    import mx.controls.listClasses.*;
    import mx.collections.*;
    import mx.controls.*;
    import com.graphics.*;

    private function initApp():void
    {
			var circle:Shape = new Shape()
			var xPos:Number = 100;
			var yPos:Number = 100;
			var radius:Number = 50;
			circle.graphics.beginFill(0xFF8800);
			circle.graphics.drawCircle(xPos, yPos, radius);
			this.addChild(circle);										 		 
    }
</mx:Script>
<mx:Canvas id="cvs" width="200" height="200">
</mx:Canvas>
    
</mx:Application>
john100 is offline   Reply With Quote
Old 03-25-2006, 04:34 PM   #2
hangalot
lala
 
hangalot's Avatar
 
Join Date: Feb 2002
Location: on the road
Posts: 2,859
Default

there are two sollutions to this problem, and it depends on what you want which one will work for you.

ActionScript Code:
var circle:UIObject = new UIObject();

or
ActionScript Code:
this.allChildrenList.addChild(circle);

so the difference between the two is that in the first case flex will manage all the resizing and the rest of your item for you in the application, in the second case you are bypassing flex and just adding it to the display list directly
__________________
oi poloi
http://www.memorphic.com/news/
hangalot is offline   Reply With Quote
Old 03-25-2006, 10:54 PM   #3
john100
Registered User
 
Join Date: Feb 2006
Posts: 22
Default

Thanks it work.
There is a slightly change. Instead of UIObject. Need to use UIComponent

var circle:UIComponent = new UIComponent();

Code:
<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    creationComplete="initApp()"  backgroundAlpha="0">

<mx:Script>
import  flash.display.*;
import mx.controls.listClasses.*;
import mx.collections.*;
import mx.controls.*;
import com.graphics.*;

private function initApp():void
{
	var circle:UIComponent = new UIComponent();
	var xPos:Number = 100;
	var yPos:Number = 100;
	var radius:Number = 50;
	circle.graphics.beginFill(0xFF8800);
	circle.graphics.drawCircle(xPos, yPos, radius);
	this.addChild(circle)
}
</mx:Script>
<mx:Canvas id="cvs" width="200" height="200">
</mx:Canvas>
    
</mx:Application>
john100 is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting Actionscript 1.0 to Actionscript 2.0 DNG ActionScript 2.0 5 11-30-2005 07:57 PM
drawing using actionscript Animus ActionScript 1.0 (and below) 3 07-12-2005 07:16 PM
all actionscript site...how in the world? dpaslay (work) ActionScript 2.0 1 07-22-2004 03:31 AM
Actionscript shape drawing... johnglynn ActionScript 1.0 (and below) 4 05-17-2004 04:55 PM
Drawing a line with ActionScript?? BeWare ActionScript 1.0 (and below) 5 02-01-2001 10:43 AM


All times are GMT. The time now is 09:32 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.