Can Evaluate function return object type
Hi
Evaluate function can be used to call db functions in OBIEE. I have a function which returns an object ( pl/sql table).
Created a simple report in Oracle Answers and added following in one of the columns
evaluate( 'get_ccid(%1)' as t_ccid , @{p_request})
When I try to run this in Oracle answers, getting syntax error. If same function returns varchar or number it works well.
evaluate( 'get_ccid(%1)' as t_ccid , @{p_request})Eakta, You syntax seems to be wrong here. What type of data your presentation variable contains here ?? You are saying its working fine with Number datatype..so can you try..somthing like below with some default value..
EVALUATE('get_ccid(%1)',@{p_request}{2})
OR
EVALUATE('get_ccid(%1)' as varchar(250),@{p_request}{ABC})
Also, refer
Syntax for Evaluate function in OBIEE
http://108obiee.blogspot.com/2009/04/using-presentation-variable-from-first.html
Hope its useful
Similar Messages
-
Can stored function return record type or cursor type?
Hi everybody,
I am working with a stored function now.
Can the function output more that ONE result? i.e. cursor or record type.
Thanks.
Brigitta.Brigitta,
If you are calling the stored function from SQL then the function can only return one of the base datatypes, as Murali has said. However, if you are calling the function from PLSQL you can return any complex datatype, eg:
package test_package is
type rec_test is
( col_a number
, col b varchar2(30) );
type tab_test is
table of rec_test
index by binary ineteger;
function test_function (.....)
return tab_test;
end test_package;and to call this function:
declare
l_table test_package.tab_test;
begin
l_table := test_package.test_function(....);
end;Hope that helps! -
How to call a function having OBJECT type as Return type
Hi,
I've the following function returning OBJECT type.
Pease advice me how to call this function
CREATE OR REPLACE TYPE GET_EMP_OBJ is object
( emp_name varchar2(50) ,
mgr_id number,
dept_id number
CREATE OR REPLACE FUNCTION get_emp(P_emp_no NUMBER )
RETURN GET_EMP_OBJ IS
t_emp_info GET_EMP_OBJ ;
v_ename EMP.ename%TYPE;
v_mgr EMP.mgr%TYPE ;
v_deptno EMP.deptno%TYPE;
v_ename1 EMP.ename%TYPE;
v_mgr1 EMP.mgr%TYPE ;
v_deptno1 EMP.deptno%TYPE;
BEGIN
FOR rec IN ( SELECT ename , mgr , deptno
FROM emp )
LOOP
v_ename := rec.ename ;
v_ename1 := v_ename1||'|'||v_ename ;
v_mgr := rec.mgr ;
v_mgr1 := v_mgr1||'|'||v_mgr ;
v_deptno:= rec.deptno;
v_deptno1 := v_deptno1||'|'||v_deptno ;
END LOOP ;
t_emp_info := GET_EMP_OBJ (v_ename,v_mgr,v_deptno ) ;
RETURN t_emp_info ;
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.put_line ('Error'||SQLCODE||','||SQLERRM ) ;
END;The above function got created successfully.
And i'm confused how to call this functions. I tried like below but didn't work
DECLARE
t_emp_info_1 GET_EMP_OBJ ;
BEGIN
t_emp_info_1 := get_emp(7566) ;
for i in 1..t_emp_info_1.COUNT
LOOP
DBMS_OUTPUT.put_line ('Values are'||i.emp_name ) ;
END LOOP;
END;SQL> CREATE OR REPLACE TYPE GET_EMP_OBJ is object
2 ( emp_name varchar2(50) ,
3 mgr_id number,
4 dept_id number
5 );
6 /
Type created.
SQL> ed
Wrote file afiedt.buf
1 CREATE OR REPLACE FUNCTION get_emp(empno NUMBER )
2 RETURN GET_EMP_OBJ IS
3 t_emp_info GET_EMP_OBJ ;
4 BEGIN
5 begin
6 select get_emp_obj(ename, mgr, deptno) into t_emp_info
7 from emp
8 where empno = get_emp.empno;
9 exception
10 when no_data_found then
11 t_emp_info := new get_emp_obj(null,null,null);
12 end;
13 return t_emp_info;
14* END;
SQL> /
Function created.
SQL> set serverout on
SQL>
SQL> declare
2 t_emp_info GET_EMP_OBJ ;
3 BEGIN
4 t_emp_info := get_emp(7566);
5 DBMS_OUTPUT.put_line ('Values are: '||t_emp_info.emp_name||', '||t_emp_info.mgr_id||', '||t_emp_info.dept_id);
6 END;
7 /
Values are: JONES, 7839, 20
PL/SQL procedure successfully completed.
SQL> -
How can a function return a constant reference to an object
how can a function return a constant reference to an object so that the calling party dont have rights to change it.
like this example
class obj = somefunc();
obj.changeit(); // this line lust give error saying that its read only..
somefunc()
return criticalobj;
in c++ we can achieve this by using the const pointer to the object.. how can we do this in java???arun160411 wrote:
in c++ we can achieve this by using the const pointer to the object.. how can we do this in java???Of course the first thing anyone learns about const pointers is how to cast away constness, so this is completely useless, up there with the chastity movement's thong underwear with the stop sign on it. If you can read this, you're too close! -
Function Returning Object
Hi Experts,
Here is my code,
-- DROP TYPE TYP_EMP;
-- DROP TYPE TYP_EMP_OBJ;
CREATE OR REPLACE TYPE TYP_EMP_OBJ AS OBJECT
TOTAL NUMBER,
ROWINDEX NUMBER,
EMPNO NUMBER,
ENAME VARCHAR2(50),
LOC VARCHAR2(100)
CREATE OR REPLACE TYPE TYP_EMP AS TABLE OF TYP_EMP_OBJ;
CREATE OR REPLACE FUNCTION FUN_GETEMP_LOCATION(pmDeptno IN NUMBER) RETURN VARCHAR2
AS
vLocation DEPT.LOC%TYPE;
BEGIN
SELECT LOC INTO vLocation FROM DEPT WHERE DEPTNO=pmDeptno;
RETURN vLocation;
END;
CREATE OR REPLACE FUNCTION FUN_GET_EMP_DETAILS
pmType IN NUMBER,
pmStartPage IN NUMBER,
pmEndPage IN NUMBER,
pmOrderBy IN VARCHAR2
RETURN TYP_EMP PIPELINED
AS
vString VARCHAR2(100);
TYPE vRefCursor IS REF CURSOR;
Cur vRefCursor;
Rec TYP_EMP_OBJ := TYP_EMP_OBJ(NULL,NULL,NULL,NULL,NULL);
BEGIN
IF pmType IS NULL THEN
SELECT 0,NULL,NULL,NULL,NULL INTO Rec.TOTAL,Rec.ROWINDEX,Rec.EMPNO,Rec.ENAME,Rec.LOC FROM DUAL;
RETURN;
END IF;
IF pmType =1 THEN
OPEN Cur FOR
'SELECT * FROM(
SELECT
COUNT(*) OVER(),
ROW_NUMBER() OVER('||pmOrderBy||') ROW_INDEX,
EMPNO,
ENAME,
FUN_GETEMP_LOCATION(EMP.DEPTNO) LOC
FROM EMP)T
WHERE T.ROW_INDEX BETWEEN '||pmStartPage||' AND '||pmEndPage;
ELSE
OPEN Cur FOR
'SELECT * FROM(
SELECT
COUNT(*) OVER(),
ROW_NUMBER() OVER('||pmOrderBy||') ROW_INDEX,
2,
ENAME,
FUN_GETEMP_LOCATION(EMP.DEPTNO) LOC
FROM EMP)T
WHERE T.ROW_INDEX BETWEEN '||pmStartPage||' AND '||pmEndPage;
END IF;
LOOP
FETCH Cur INTO Rec.TOTAL,Rec.ROWINDEX,Rec.EMPNO,Rec.ENAME,Rec.LOC;
EXIT WHEN Cur%NOTFOUND;
PIPE ROW(Rec);
END LOOP;
CLOSE Cur;
RETURN;
END;
SELECT * FROM TABLE(FUN_GET_EMP_DETAILS(NULL,1,10,'ORDER BY EMPNO DESC'));
SELECT * FROM TABLE(FUN_GET_EMP_DETAILS(1,1,10,'ORDER BY EMPNO DESC'));
SELECT * FROM TABLE(FUN_GET_EMP_DETAILS(2,1,10,'ORDER BY EMPNO DESC'));
Executing First Query
Actually Whats happening on Executing first Query, it does not return as specified
SELECT 0,NULL,NULL,NULL,NULL INTO Rec.TOTAL,Rec.ROWINDEX,Rec.EMPNO,Rec.ENAME,Rec.LOC FROM DUAL;
It just returning null;
Executing Second Query
It return correctly.
Executing Third Query
It return correctly.
Can anyone suggest how to work out like this?
Thanks,
Dharan VYou dint pipe the row if pmType is NULL
CREATE OR REPLACE FUNCTION FUN_GET_EMP_DETAILS
pmType IN NUMBER,
pmStartPage IN NUMBER,
pmEndPage IN NUMBER,
pmOrderBy IN VARCHAR2
RETURN TYP_EMP PIPELINED
AS
vString VARCHAR2(100);
TYPE vRefCursor IS REF CURSOR;
Cur vRefCursor;
Rec TYP_EMP_OBJ := TYP_EMP_OBJ(NULL,NULL,NULL,NULL,NULL);
BEGIN
IF pmType IS NULL THEN
SELECT 0,NULL,NULL,NULL,NULL INTO Rec.TOTAL,Rec.ROWINDEX,Rec.EMPNO,Rec.ENAME,Rec.LOC FROM DUAL;
pipe row(rec); ----------------<<<<----------------- This is required
RETURN;
END IF;
IF pmType =1 THEN
OPEN Cur FOR
'SELECT * FROM(
SELECT
COUNT(*) OVER(),
ROW_NUMBER() OVER('||pmOrderBy||') ROW_INDEX,
EMPNO,
ENAME,
FUN_GETEMP_LOCATION(EMP.DEPTNO) LOC
FROM EMP)T
WHERE T.ROW_INDEX BETWEEN '||pmStartPage||' AND '||pmEndPage;
ELSE
OPEN Cur FOR
'SELECT * FROM(
SELECT
COUNT(*) OVER(),
ROW_NUMBER() OVER('||pmOrderBy||') ROW_INDEX,
2,
ENAME,
FUN_GETEMP_LOCATION(EMP.DEPTNO) LOC
FROM EMP)T
WHERE T.ROW_INDEX BETWEEN '||pmStartPage||' AND '||pmEndPage;
END IF;
LOOP
FETCH Cur INTO Rec.TOTAL,Rec.ROWINDEX,Rec.EMPNO,Rec.ENAME,Rec.LOC;
EXIT WHEN Cur%NOTFOUND;
PIPE ROW(Rec);
END LOOP;
CLOSE Cur;
RETURN;
END;Edited by: Karthick_Arp on Dec 24, 2009 2:12 AM -
Cannot call member function on object type
On 8.1.6 I cannot call a member function from SQL in the way described in the manual.
The following example is almost copied from the manual:
create or replace TYPE foo AS OBJECT (a1 NUMBER,
MEMBER FUNCTION getbar RETURN NUMBER);
create or replace type body foo is
MEMBER FUNCTION getbar RETURN NUMBER is
begin
return 45;
end;
end;
CREATE TABLE footab(col foo);
SELECT col,foo.getbar(col) FROM footab; -- OK
select col,col.getbar() from footab; -- ERROR
The second select is the way it should be, but I get an error "invalid column name".
Using the first select, I get the result. This is strange because this is more or less the 'static member' notation (filling in the implicit self parameter myself).
Is this a known bug in 8.1.6, maybe fixed in later versions?Konstantin,
Did you use loadjava to load the compiled class into the Oracle Database?
Regards,
Geoff
Hello!
I need to write a member function for object type with java.
for example:
create type test as object(
id number,
name varchar2(20),
member function hallo return number);
create type body test as
member function hallo return number
as language java
name 'test.hallo() return int;
create table test of test;
My java-file is:
public class test {
public int hallo() {
return 5;
select t.hallo() from test t;
It's does not run. Why?
I get always an error back. Wrong types or numbers of parameters!!
please help me.
thanks in advance
Konstantin -
Can a function return two values???
Hi guys can a function return more than values?
Or even better return an Object.
ie
public class Tester{
public static Multi getM()
Multi m=new Multi();
m.x="testing";
m.y="new value";
public static void main(String [] args)
Multi mt=getM();
System.out.println(mt.x);
System.out.println(mt.y);
class Multi{
public String x;
public String y;
} -
Can oracle function return more than one value
Hi All
please answer can oracle function return more than one value
need one schenario
regardsCan any function, irrespective of the language, return multiple values?
OF COURSE NOT!!
So why do you think Oracle will now suddenly do it differently than all other languages? Never mind that it is impossible for a function (a unit/module of code) returning a memory address, to return multiple memory addresses. The machine code that does that, has not been yet been designed/implemented.
I am continually amazed that this question is asked. It is about something so fundamental in almost every single 3rd and 4th generation language... something that is taught right at the start... the definition of what a procedure and what a function is.
Sorry, but I simply cannot pull punches on this subject and smooth it over. There is something fundamentally wrong with your training as a programmer if you have to ask such a question about a function.
And whatever programming skills you build on such a foundation, will be seriously lacking.
I kindly suggest that you get back to the very basics of programming - and review and revisit until you fully understand it. There are no shortcuts in becomming a good programmer.
Message was edited by:
Billy Verreynne -
Materialized View with column based on PL/SQL function returning object
I have the following problem - it is known that materialized view wants PL/SQL functions used in it to be DETERMINISTIC. And it appears that a function which returns SDO_GEOMETRY cannot be DETERMINISTIC - I can add DETERMINISTIC modifier to my function which returns sdo_geometry based on USNG grid ID and save the package, and it compiles and runs fine with regular queries, but when it comes to materialized view (mview), the following error is thrown:
ORA-12018: following error encountered during code generation for "SCHEMA"."MVIEW_NAME"
ORA-00932: inconsistent datatypes: expected NUMBER got MDSYS.SDO_GEOMETRY
Looks like DETERMINISTIC modifier is not fully supported for object types. I have tried to use SDO_CS.FROM_USNG Oracle's function, and it appeared that this function is also non-deterministic - I cannot refresh mview with P or F on-demand refresh method (see http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14223/refresh.htm#i1008349 for a list of on-demand refresh methods). Without that function I can refresh mview with P or F flags.Hi,
Yes, the Chart Series can be based on "Function Returing SQL Query" and the "SQL" would be something like:
DECLARE
vSQL VARCHAR2(1000);
BEGIN
vSQL := 'SELECT NULL LINK, ENAME LABEL, SAL VALUE FROM EMP ORDER BY ENAME';
RETURN vSQL;
END;You should tick the "Save query without validation" underneath that. Without this, there is a validation error - the ; at the end is required to get the chart to function correctly but the validator sees this as an error.
You would need to create this separately from the report. No matter how you did it, the chart would still run a SQL statement to generate the output. If you wanted to use the "same data", then you could create a collection using the PL/SQL and base both the report and the chart on the collection instead.
Andy -
Stored procedure and function - return table type
Hello again :)
I have one simple question :) Maybe on this forum the question was asked, but I found only similar question and they didn't help me.
It's possible return in Stored Function (with StoredProcedureFunction) as result return TABLE type? Or return table type with output parametr with Stored Procedure? Or instead of the table return the db object, but it is similar problem:)
Now, I can using db types TABLES or DB OBJECTS as INPUT parameters with call stored functions or procedures, for example:
I have this simple db object:
create or replace type BUFFER_DATA_R as object( detail VARCHAR2(4000 ))
And this simple table:
CREATE OR REPLACE TYPE BUFFER_DATA_T IS TABLE OF BUFFER_DATA_R
I create simple domain class object:
*public class DMBufferDataStruct {*
public String bufferData;
And I mapped in java with ObjectRelationalDataTypeDescriptor:
ObjectRelationalDataTypeDescriptor descriptor = new ObjectRelationalDataTypeDescriptor();
descriptor.setJavaClass(DMBufferDataStruct.class);
descriptor.setTableName("BUFFER_DATA_T");
descriptor.setStructureName("BUFFER_DATA_R");
descriptor.setPrimaryKeyFieldName("DETAIL");
descriptor.addFieldOrdering("DETAIL");
descriptor.addDirectMapping("bufferData", "DETAIL");
and join to server session ...
Well, i using this doimain class object as input parametr wih stored procedure call:
ObjectRelationalDatabaseField ordf = new ObjectRelationalDatabaseField("");
ordf.setSqlType(Types.STRUCT);
spCall.addNamedArgument(key, key,
Types.ARRAY,
"BUFFER_DATA_T",
ordf);
query.addArgument(key);
args.add(paramsInputs.get(key));
in paramsInputs is Vector of DMBufferDataStruct...
Well, this work fine!
But I can not figure, how to return this table from output parameters of stored procedure or as a return value from stored function?
Example of exceptions:
The number of arguments provided to the query for execution does not match the number of arguments in the query definition. - return as output parameter
PLS-00382: expression is of wrong type - used as result from stored function
So, my question is: Is possible return this table type from stored procedure or function? And if YES, how can I set output argument for call?
Thx advance!
Sorry for my English! :)
Best regards, KLDYour question is: what is faster PL/SQL or PL/SQL? And the answer is: it is PL/SQL of course!
As a general rule, you use a function when you return exactly one result: a number or a string or (more complex) instance of an object type or REF CURSOR or PL/SQL collection.
You use a procedure when:
a) you just do the job and return no result
b) you return multiple results - you can use multiple IN/OUT or OUT parameters
Imagine you have to write a program unit that performs a partitioned table maintenance by adding a partition.
You can implement this unit:
a) if you want return a "status code" (0 on successful completion or non-zero in case of error) then you should use a function
b) if you want no "status code" (in case of error an exception is raised that is handled outside of the program unit) then you should use a procedure
c) if you want "status code", name of tablespace where a partition was created (assume you program is so complex that it can choose different tablespaces based on metadata and free space available) and free space in that tablespace after the creation of a new partition then you should use a procedure with 3 OUT parameters.
But these are good programming practices that can be applied to (almost) any 3rd generation programming language, not only PL/SQL. -
How to return object type from external c procedure ?
Hello all,
I'm trying for the first time to return an object type as the return value of an external stored procedure (in C ).
I don't have any issue to use an object type parameter for the function but not to return one to the caller.
each time I try I get "ORA-03113: end-of-file on communication channel" and the connection is dropped.
Thanks for any help,
Roye Avidor
here is the code :
=> object type
SQL>create or replace type address as object ( age number, salary float );
=> address typ file
CASE=SAME
TYPE address as address
=> building the dependences structures.
$>ott userid=scott/tiger intype=address.type code=c hfile=address.h
=> the package description
create or replace package userTypeDefined_PKG
is
function getAddr( addr address ) return address;
end;
create or replace package body userTypeDefined_PKG
is
function getAddr( addr address ) return address
AS LANGUAGE C
NAME "addr"
LIBRARY userTypeDefinedLib
WITH CONTEXT
PARAMETERS
( CONTEXT,
addr,
addr INDICATOR STRUCT ,
return address,
return INDICATOR STRUCT
end;
=> The C code for the library in
address* addr(OCIExtProcContext ctx, address address_obj, address_ind address_obj_ind, address_ind ret_ind){
unsigned int tt;
OCIEnv *envh;
OCIError *errh;
OCISvcCtx *svch;
sword err;
address* ret = NULL;
int inum = 69;
float fnum = 12.34;
/* get OCI Environment */
err = OCIExtProcGetEnv(ctx, &envh, &svch, &errh) ;
/* allocate space for return sturcture*/
ret = (address *)OCIExtProcAllocCallMemory(ctx, sizeof(address));
/* set the AGE value */
if ( OCINumberFromInt ( errh, &inum, sizeof(inum), OCI_NUMBER_SIGNED, &(ret->AGE) ) == OCI_ERROR )
OCIExtProcRaiseExcp(ctx,(int)1476); // raise 1476 is fail
/* set the SALARY value */
if ( OCINumberFromReal ( errh, &fnum, sizeof(fnum), &(ret->SALARY) ) == OCI_ERROR )
OCIExtProcRaiseExcp(ctx,(int)1477);// raise 1477 is fail
// set the indicators for the structure as not null
ret_ind->atomic = OCIIND_NOTNULL;
ret_ind->AGE = OCI_IND_NOTNULL;
ret_ind->SALARY = OCI_IND_NOTNULL;
return (ret);
}The return indicator should be declared as double pointer, and need to be allocated in the function body.
-
How can I obtain an object-type variable in Forms 6i?
i create an object-type in oracle 8i database like this:
TYPE OBJ_TYPE_NUMBER AS OBJECT
FIELD1 NUMBER,
MEMBER PROCEDURE INIT, ...
i create a variable of this object-type in a stored procedure in Oracle 8i:
v_Number OBJ_TYPE_NUMBER(10);
and then call it's method:
v_Number.INIT;
it work's!
But when I try to compile a previous variable declaration
(v_Number OBJ_TYPE_NUMBER;) in Oracle Forms 6i I see only an error message.
So my question is How can I declare and use an object-type variable in Forms 6i?Hi,
the release after Forms 6i is Forms9i. Forms9i does have the PLSQL engine of Oracle 9.0.0.2 database which means that it should knwo how to handle object types in PLSQL.
Frank -
Can't access packaged object type in Java
Hi
I am getting the following error while accessing an oracle packaged object type. Can You please give me an advise..!!
java.sql.SQLException: invalid name pattern: XXGW_RMA_CREATION_PKG.XXGW_RMA_RECRegardsHI
I am not asking how to search in google. If You know how to resolve my problem..then help me. I don't what this kind of answers.
This is my problem
Error in java.
java.sql.SQLException: invalid name pattern: XXGW_RMA_CREATION_PKG.XXGW_RMA_REC
This is my package
create or replace package xxgw_rma_creation_pkg
is
type xxgw_rma_rec is record (dealer_name varchar2(40), dealer_desc varchar2(300));
type xxgw_rma_line is table of xxgw_rma_rec; --(item_name varchar2(40), item_desc varchar2(300)) index by binary_integer;
xx_rma_rec xxgw_rma_rec;
xx_rma_line xxgw_rma_line
procedure xxgw_rma_creation (p_rma_rec in xxgw_rma_rec ,p_rma_line in xxgw_rma_line,p_rma_no out varchar2);
end;
create or replace package body xxgw_rma_creation_pkg
is
procedure xxgw_rma_creation (p_rma_rec in xxgw_rma_rec ,p_rma_line in xxgw_rma_line,p_rma_no out varchar2)
is
l_rma_rec xxgw_rma_rec := p_rma_rec;
l_rma_line xxgw_rma_line := p_rma_line;
begin
dbms_output.put_line(l_rma_rec.dealer_name||' '||l_rma_rec.dealer_desc);
for i in l_rma_line.first..l_rma_line.last loop
dbms_output.put_line(l_rma_line(i).dealer_name||' '||l_rma_line(i).dealer_desc);
end loop;
p_rma_no := '20';
end;
end;Rekha -
In CC01, why can I not add object types
Greetings experts.
We need to add an object type to the list which shows on CC01(2 etc) . The New Entries button is greyed out. Can anyone point me to the reason, or what I need to do to make it active?
thanksHi,
Define a profile in OS59. In the profile under Object type profile (detail) section, click on new entries & select the object types from the list as per your need & then save as a custom profile.
Use this profile on the initial screen of CC01 & then go to Object Types, you should find the object types which you need.
Regards,
Vivek -
Can a function return more than one item or object?
Hi I am trying to move text movies and textfields around a stage. This is a learning curve for me. I am confused by an example I have found on the internet.
http://forums.adobe.com/community/flash/flash_actionscript
What type of object is
var letter:Object = getLetterObject(_text.charAt(i)); // in the draw function
as it has properties
letter.stepDegrees = _totalAngle / numOfLetters;
getLetterObject()
seems to return lotts of stuff which would not be done in other languages like C
return
movie:movie,
field:field,
widthInDegrees:0,
fieldWidth:field.width,
fieldHeight:field.height
I would like to get my head around this as this is a good example of what I need. Well parts of it actualy.
I understand that the text field is added as a child to the Movieclip. I would have expected just a MovieClip object returned.
full code including the function getLetterObject()
=======
package
import flash.display.DisplayObject;
import flash.display.MovieClip;
import flash.geom.Rectangle;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
import flash.text.TextFormatAlign;
public class CurvedText extends MovieClip
public static const DIRECTION_UP:String = "up";
public static const DIRECTION_DOWN:String = "down";
public var showLetterBorder:Boolean = false;
public var showCurve:Boolean = false;
private var _letterHolder:MovieClip;
private var _text:String;
private var _radius:Number;
private var _letters:Array;
private var _widthOfText:Number = 0;
private var _startAngle:Number = 0;
private var _endAngle:Number = 360;
private var _totalAngle:Number = 0;
private var _textFormat:TextFormat;
private var _direction:String;
public function CurvedText(text:String = "", radius:Number = 200, startAngle:Number = 0, endAngle:Number = 360, direction:String = "up", textFormat:TextFormat = null)
_text = text;
_radius = radius;
_startAngle = startAngle;
_endAngle = endAngle;
_direction = direction;
_textFormat = textFormat;
_letters = [];
_totalAngle = Math.abs(_startAngle) + Math.abs(_endAngle);
public function draw():void
// checking if there is any text set
if(_text == "")
return;
// clearing the letters' holder
if(_letterHolder && contains(_letterHolder))
removeChild(_letterHolder);
_letterHolder = new MovieClip();
addChild(_letterHolder);
// adding letters
var numOfLetters:int = _text.length;
for(var i:int=0; i<numOfLetters; i++)
var letter:Object = getLetterObject(_text.charAt(i));
letter.stepDegrees = _totalAngle / numOfLetters;
_letters.push(letter);
_widthOfText += letter.fieldWidth;
_letterHolder.addChild(letter.movie);
// positioning
position();
// draw the curve
if(showCurve) {
_letterHolder.graphics.lineStyle(1, 0xFF0000, 1);
_letterHolder.graphics.drawCircle(0, 0, _radius);
private function getLetterObject(letter:String):Object
// setting default text format
if(!_textFormat)
_textFormat = new TextFormat();
_textFormat.align = TextFormatAlign.CENTER;
_textFormat.font = "Verdana";
_textFormat.size = 12;
_textFormat.color = 0x000000;
// creating the field
var movie:MovieClip = new MovieClip();
var field:TextField = new TextField();
field.width = 10;
field.defaultTextFormat = _textFormat;
field.embedFonts = true;
field.multiline = false;
field.autoSize = TextFieldAutoSize.CENTER;
field.text = letter;
field.x = -field.width / 2;
field.y = -field.height / 2;
if(showLetterBorder)
field.border = true;
movie.addChild(field);
return // RETURNS more than one value?
movie:movie,
field:field,
widthInDegrees:0,
fieldWidth:field.width,
fieldHeight:field.height
private function position():void
// position the letters
var numOfLetters:int = _letters.length;
var degrees:Number = _startAngle;
for(var i:int=0; i<numOfLetters; i++)
var angle:Number = _letters[i].stepDegrees + degrees;
if(_direction == DIRECTION_DOWN)
angle -= 180;
_letters[i].movie.scaleY = -1;
} else {
xValue = _radius * Math.cos((angle-90)/180*Math.PI);
yValue = _radius * Math.sin((angle-90)/180*Math.PI);
var xValue:int = _radius * Math.cos((angle-90)/180*Math.PI);
var yValue:int = _radius * Math.sin((angle-90)/180*Math.PI);
_letters[i].movie.x = xValue;
_letters[i].movie.y = yValue;
_letters[i].movie.rotation = angle;
degrees += _letters[i].stepDegrees;
// position the holder
var bounds:Rectangle = _letterHolder.getBounds(this);
_letterHolder.x = -bounds.x;
_letterHolder.y = -bounds.y;
if(_direction == DIRECTION_DOWN)
_letterHolder.scaleX = -1;Hi
I still think I need an Object parent child linkage diagram on this to get my head around it.
It seems that things are reversed so that it is Object:value. Kind of confusing to see movie:movie.
var letter:Object = getLetterObject(_text.charAt(i));
letter holds the following objects
MovieClip:Movie
TextField:field
widthInDegrees:0 // What is this. What type is a widthInDegrees
fieldWidth:field.width // Same as above
fieldHeight:field.height // Same as above
And to cap it all, back in the calling function draw()
letter.stepDegrees = _totalAngle / numOfLetters; // What is stepDegrees a property of? MovieClip,TextField,widthInDegrees,fieldWidth or fieldHeight
I can understand the first two but not the last three
For example widthInDegrees is not mentioned anywhere in the code. and
letter.stepDegrees // implies that stepDegrees is a property of Object:letter.
Do you throw a property and value blindly at the letter object and let flash work out which object it is a property of?
MovieClip & TextField do not have this property. Searched the web for this information. We need an equivelent of MSDN.
Desmond.
Maybe you are looking for
-
List of users who do not have USER GROUP.
Hi friends, I want to find out the list of users who do not have USER GROUP. Can any one please let me know how to find out. Thanks, Ankitha
-
What are those checkboxes?
Hello. What are those little checkboxes next to the song titles, and what are they used for? What's the difference between checking the box, and selecting the song by clicking (highlighting) it? Has Apple published an article that answers my question
-
There must be a simpler way ( from start to finish ). .
( I did a search, but the keywords must have been too broad ) What i describe below worked, but i know a more experienced editor would smile at the unnecessary amount of effort . . . At a recent School Centenary I was contracted to spend the whole da
-
Ipod shuts down on some podcasts
I have recently purchased a new ipod, 80gb, and I love it. I have upgraded from the 60gb. Only problem is that on some podcasts, not all, when I go into the podcast the ipod shuts down and I am unable to play the podcast. After a few seconds the appl
-
Post Author: yoav CA Forum: Migration to XI R2 I hope i am not asking again this question but i haven't found a thread here is the forum,so here goes : Does user objects migrate as well using the import wizard ? if so how ? Do business query reports