How to call a function inside a class?
Hello, i am trying to fire a function onPress .. this
function is inside a class.
In this function i refer to another function inside the calss
to call a Tween. It never arrives in the second function.
I tried to make an example.
In the fla file i have:
var test:makeMovie = new makeMovie(this);
You will see a red squere and you can press on it. It should
run the tween class. Am i using the delegate class wrong?
I always have to use test movie and trace a couple of times
each time I start to use Delegate.
It wraps function.apply I think, which I tend to use more
often.
try using:
Container.onPress = Delegate.create(this,setAlpha);
and then just
setTween()
inside your setAlpha....
That's conceptually how I think I would try it above if I was
doing something similar.
I'm not sure it would have the desired effect even if the
delegate was executed as you have it coded. Unless you want
setTween's execution scope to be the Container clip in which case
you might need to do what kglad said and change the Container
reference to 'this'.
The way you have it at the moment inside setAlpha the
Delegate.create is simply creating a function...and not excuting
it.
its like : function something(){trace('what')}
and not like : something();
Below is some quick code that helps show how things work.
Notice that I assigned the delegate function to mainFunc....so that
along with the last example might provide a clue. Just paste it on
a frame and take a look at what's happening.
Similar Messages
-
Calling a function inside another class
I have the following two classes and can't seem to figure to figure out how to call a function in the top one from the bottom one. The top one get instantiated on the root timeline. The bottom one gets instantiated from the top one. How do I call functions between the classes. Also, what if I had another call instantiated in top one and wanted to call a function in the bottom class from the second class?
Thanks a lot for any help!!!
package
import flash.display.MovieClip;
public class ThumbGridMain extends MovieClip
private var grid:CreateGrid;
public function ThumbGridMain():void
grid = new CreateGrid();
public function testFunc():void
trace("testFunc was called");
package
import flash.display.MovieClip;
public class CreateGrid extends MovieClip
public function CreateGrid():void
parent.testFunc();kglad,
Although I agree that utilizing events the way you attempted in your suggestion is better for at least a reason of eliminating dependency on parent, still you code doesn't not accomplish what Brian needs.
Merely adding event listener to grid instance does nothing - there is no mechanism in the code that invokes callTGMFunction - thus event will not be dispatched. So, either callTGMFunction should be called on the instance (why use events - not direct call - in this case?), or grid instance needs to dispatch this event based on some internal logic ofCreateGrid AFTER it is instantiated - perhaps when it is either added to stage or added to display list via Event.ADDED. Without such a mechanism, how is it a superior correct way OOP?
Also, in your code in ThumbGridMain class testFunc is missing parameter that it expects - Event.
Am I missing something?
I guess the code may be (it still looks more cumbersome and less elegant than direct function call):
package
import flash.display.MovieClip;
import flash.events.Event;
public class ThumbGridMain extends MovieClip
private var grid:CreateGrid;
public function ThumbGridMain():void
grid = new CreateGrid();
grid.addEventListener("callTGMFunction", testFunc);
addChild(grid);
// to call a CreateGrid function named cgFunction()
public function callCG(){
grid.cgFunction();
public function testFunc(e:Event):void
trace("testFunc was called");
package
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.Event;
public class CreateGrid extends MovieClip
public function CreateGrid():void
if (stage) init();
else addEventListener(Event.ADDED, callTGMFunction);
// to call a TGM function
public function callTGMFunction(e:Event = null):void
// I forgot this one
removeEventListener(Event.ADDED, callTGMFunction);
this.dispatchEvent(new Event("callTGMFunction"));
public function cgFunction(){
trace("cg function called");
I think this is a case of personal preference.
With that said, it is definitely better if instance doesn't rely on the object it is instnatiated by - so, in this case, either parent should listen to event or call a function directly. -
How to call a function in a class from the main timeline?
Hey Guys
I have a project in Flash with four external AS files, which are linked to items in the library using AS linkage.
What I want to do is call a function in one of these files from the main timeline, how would I go about doing this? I'm not currently using a document class, most of the code is in Frame 1 of the main timeline.
Thanks// change type to the class name from the instance
ClassNameHere(this.getChildByName('instance_name')).SomeFunction(); -
Call a function inside a package from a stored procedure
Hello:
I am kind of new to the stored procedure. Does anyone know how to call a function inside a package from another stored procedure?
I have a existing function (func_b) inside a package (pack_a) and it returns a cursor. I want to call this function from a stored procedure (proc_c) so that I use the data inside the cursor.
can I do the following in proc_c:
my_cursor1 SYS_REFCURSOR;
begin
my_cursor1 := exec pack_a.func_b
end
It will be very helpful if anyone can point me to any reading or example. Thank you very much for your information.guys:
Thank you for your information so far. I need some more help here. I was able to run the function in my stored procedure. However, I was not able to print the result on the screen to view the cursor result, although I am using dbms_output.put_line statement inside my stored procedure.
I use the following statement to execute my stored procedure on sql*plus. I can tell the stored procedure is executed successfully, but I did see anything printed:
DECLARE TEMP VARCHAR2(100);
BEGIN PROC_LAWS_CAD_NAME_SEARCH('LPD', 'TEST DEVICE ID', 'TEST LAST NAME', 'TEST FIRST NAME', 'F', '11112009', TEMP); END;
I tried to use 'set serveroutput on' and got the following error:
ERROR:
ORA-06502: PL/SQL: numeric or value error: host bind array too small
ORA-06512: at line 1
I am kind of confused now. thank you for your help.
Jack
Here is my procedure:
create or replace
PROCEDURE PROC_SEARCH
( AGENCY_ID IN VARCHAR2,
DEVICE_ID IN VARCHAR2,
L_NAME IN VARCHAR2,
F_NAME IN VARCHAR2,
SEX IN VARCHAR2,
DOB IN VARCHAR2,
CAD_NAME_SCH_RESULT_STR OUT VARCHAR2)
AS
v_agy_id varchar2(10);
v_device_id varchar2(20);
v_l_name varchar2(25);
v_f_name varchar2(15);
v_sex varchar2(1);
v_dob date;
-- this cursor is going to be used to store a list of warrant matching
-- name search criteria
cad_srch_cursor sys_refcursor;
objSrch SEARCH_RESULT_TEMP%ROWTYPE;
BEGIN
cad_srch_cursor := SEARCH_PKG.SEARCH('TESTING', 'TESTER', null, null,null, null, getPhonetic('TESTING'));
LOOP
FETCH cad_srch_cursor INTO objSrch;
EXIT WHEN cad_srch_cursor%NOTFOUND;
--insert into SEARCH_RESULT_TEMP (name_last) values (objSrch.name_last);
CAD_NAME_SCH_RESULT_STR := objSrch.name_last;
dbms_output.put_line('First:'||objSrch.name_first||':Last:'||objSrch.name_last||':Middle:'||objSrch.name_middle);
end LOOP;
END PROC_LAWS_SEARCH;
----------------------------------------- -
Call function inside running class
Hey All,
i have a two question in classes.
1- i have class and i called its before and its running on runtime. i need to call function inside this class from another class, but without call the first one again, because if i called it, it will run default class function again
is this doable ?
2- What super() mean ?
Thanks a lot.this is the default call, and when i call the method by this way its will run the default class function before call the method.
here my example:
i need to call checkboxes function in ChannelsMain class without pass by the grey script.
Note: the call_cb is working and the trace is working
so i now the class is running, i need to call the checkboxes without ( var ci:YourClass = new YourClass(); )
package com.link
import fl.controls.CheckBox;
import flash.events.*;
public class ChannelsMain
var cbLength:uint = Main.PV.channel_id.length;
public function ChannelsMain()
// constructor code
for (var i:int = 0; i < cbLength; i++)
var cb:CheckBox = new CheckBox;
cb.name = Main.PV.channel_id[i];
cb.label = Main.PV.channel_name[i];
cb.x = 50;
cb.y = 50 + i * 30;
cb.addEventListener(Event.CHANGE,call_cb);
Main.MS.addChild(cb);
//call xml function
if(i == cbLength - 1)
new ChannelsXML();
private function call_cb(evt:Event)
trace(evt.currentTarget.name,evt.currentTarget.selected);
public function checkboxes(evt)
trace(evt); -
How to call javascript function from PL/SQL procedure
Can anybody advice me how to call javascript function from PL/SQL procedure in APEX?
Hi,
I have a requirement to call Javascript function inside a After Submit Process.
clear requirement below:
1. User selects set of check boxes [ say user want to save 10 files and ticks 10 checkboxes]
2. user clicks on "save files" button
3. Inside a After submit process, in a loop, i want to call a javascript function for each of the file user want to save with the filename as a parameter.
Hope this clarify U.
Krishna. -
Calling a Function inside a procedure
Can you call a function inside a procedure?...if so....how?
Not all built-in functions can be used directly in an assignment.
SQL> CREATE PROCEDURE p (p_val IN VARCHAR2) AS
2 l_v VARCHAR2(10);
3 BEGIN
4 l_v := DECODE(p_val,'YES','TRUE','FALSE');
5 END;
6 /
Warning: Procedure created with compilation errors.
SQL> show error
Errors for PROCEDURE P:
LINE/COL ERROR
4/4 PL/SQL: Statement ignored
4/11 PLS-00204: function or pseudo-column 'DECODE' may be used inside
a SQL statement onlyTTFN
John -
How to call oracle function from ejb3
i'm trying to call an oracle query-function from ejb3.
The oracle function:
create or replace FUNCTION getSecThreadCount(secId in NUMBER,avai in NUMBER)
RETURN SYS_REFCURSOR is cur SYS_REFCURSOR;
m_sql VARCHAR2(250);
BEGIN
m_sql:='select count(thrId) from thread where secId='|| secid||'
and thrAvai='|| avai;
open cur for m_sql;
return cur;
END;
I'v tried several ways to call it,but all failed:
1. the calling code:
public Object getSectionThreadCount(int secId,int avai){
Query query=manager.createNativeQuery("{call getSecThreadCount(?,?) }");
query.setParameter(1, secId);
query.setParameter(2, avai);
return query.getSingleResult();
but i got the exception:
Exception in thread "main" javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query; nested exception is: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
Caused by: java.sql.SQLException: ORA-06550: row 1, col 7:
PLS-00221: 'GETSECTHREADCOUNT' not procedure or not defined
ORA-06550: row 1, col 7:
PL/SQL: Statement ignored
2. the calling code:
@SqlResultSetMapping(name = "getSecThreadCount_Mapping")
@NamedNativeQuery(name = "getSecThreadCount",
query = "{?=call getSecThreadCount(:secId,:avai)}",
resultSetMapping = "getSecThreadCount_Mapping",
hints = {@QueryHint(name = "org.hibernate.callable", value = "true"),
@QueryHint(name = "org.hibernate.readOnly", value = "true")})
public Object getSectionThreadCount(int secId,int avai){
Query query=manager.createNamedQuery("getSecThreadCount");
query.setParameter("secId", secId);
query.setParameter("avai", avai);
return query.getSingleResult();
but i run into the exception:
Exception in thread "main" javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query; nested exception is: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
Caused by: java.sql.SQLException: lost in index IN or OUT parameter:: 3
By the way, i have successfully called the function from hibernate. And i use oracle 11g, JBoss5 RC1.
Could anyone tell me how to call the function from EJB3?
Thanks.Here's a working model:
package.procedure: (created in example schema scott)
CREATE OR REPLACE package body data_pkg as
type c_refcursor is ref cursor;
-- function that return all emps of a certain dept
function getEmployees ( p_deptId in number
return c_refcursor
is
l_refcursor c_refcursor;
begin
open l_refcursor
for
select e.empno as emp_id
, e.ename as emp_name
, e.job as emp_job
, e.hiredate as emp_hiredate
from emp e
where e.DEPTNO = p_deptId;
return l_refcursor;
end getEmployees;
end data_pkg;
/entity class:
package net.app.entity;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedNativeQuery;
import javax.persistence.QueryHint;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
@SuppressWarnings("serial")
@Entity
@Table (name="emp")
@SequenceGenerator(name = "EmployeeSequence", sequenceName = "emp_seq")
@NamedNativeQuery( name = "getEmpsByDeptId"
, query = "{ ? = call data_pkg.getEmployees(?)}"
, resultClass = Employee.class
, hints = { @QueryHint(name = "org.hibernate.callable", value = "true")
, @QueryHint(name = "org.hibernate.readOnly", value = "true")
public class Employee implements Serializable
@Id
@Column(name="emp_id")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "EmployeeSequence")
private int id;
@Column(name="emp_name")
private String name;
@Column(name="emp_job")
private String job;
@Column(name="emp_hiredate")
private Date hiredate;
// constructor
public Employee (){}
// getters and setters
public int getId()
return id;
etc...session bean:
package net.app.entity;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import net.app.entity.Employee;
import net.app.iface.ScottAdmin;
@Stateless
public class ScottAdminImpl implements ScottAdmin
@PersistenceContext
private EntityManager entityManager;
@SuppressWarnings("unchecked")
public List<Employee> getEmployeesByDeptId(int deptId)
ArrayList<Employee> empList;
try
Query query = entityManager.createNamedQuery("getEmpsByDeptId");
query.setParameter(1, deptId);
empList = (ArrayList<Employee>) query.getResultList();
return empList;
catch (Exception e)
e.printStackTrace(System.out);
return null;
}client:
package net.app.client;
import java.util.List;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import net.app.entity.Employee;
import net.app.iface.ScottAdmin;
public class ScottClient
public static void main(String[] args)
try
// create local interface
InitialContext ctx = new InitialContext();
ScottAdmin adminInterface = (ScottAdmin) ctx.lookup("ScottAdminImpl/remote");
// select employees by deptno
int deptno = 20;
List<Employee> empList = adminInterface.getEmployeesByDeptId(deptno);
// output
System.out.println("Listing employees:");
for (Employee emp : empList)
System.out.println(emp.getId() + ": " + emp.getName() + ", " + emp.getJob() + ", " + emp.getHiredate());
catch (NamingException e)
e.printStackTrace(System.out);
}Basically you just ignore the refcursor outbound parameter.
This is a stored function, have yet to try outbound refcursor parameters in stored procedures...
Edited by: _Locutus on Apr 2, 2009 2:37 PM -
How to call javascript function?
Hi,
How to call javascript function for SAP button
control onclick event?
Thanks in advance.Hi Sundar,
u can call java script in design mode.
Add this code in ur design part inside body and call the function as
<sap:button id="a" onSelect="javascript:go();"
Add inside body:
<script language="javascript>
function go(){
alert("hai");
</script>
Regards,
Vinoth.M -
Calling a function inside a symbol?
Hi there,
I'm one of those flash-devs that are trying to get Edge Animate to do what I usually do in Flash, so I might be doing this the wrong way, but I've got a symbol with a function "inside" on my stage, and I wanna call that function from the stage.
I've been trying to use sym.getComposition().getStage().getSymbol("symbolName").functionName(); but it doesn't work.
I don't have any problems manipulating the symbol itself by calling .play() or .hide() so I know the path works....can anyone show me the right syntax to call a function inside a symbol?
Thx in advanceHi Abnesher,
An important principle to grasp is that symbols (and the stage is one of them) lies in parallel, despite the fact of instances of different symbols being nested one in another (and all in fine nested in the stage).
The consequence is that from inside your nested symbol you have no direct visibility of the function defined inside the stage symbol !
Inside the Stage symbol, in the document.compositionReady event handler :
sym.yourGlobalFunction = function( firstParameter)
// your stuff
Inside another symbol, in one of its events handlers :
sym.getComposition().getStage().yourGlobalFunction( 5);
Gil -
How to call java function from PL/sql in oracle applications
I am trying to call a java function from plsql procedure. Can any one explain how to call java function, and in which directory I have to store my java function in oracle applications. Do I need to register that java function from Application developer.
Thanks
Kranthihttp://www.oracle.com/technology/tech/java/jsp/index.html
Good Luck,
Avi. -
Call library function inside a conditiona​l disable bug
i'm trying to call a function in a dll using the call library function inside a conditional disable structure.
one of the parameters is a pointer to a C structure.
here is the prototype:
short in myfunction(short in DevNum, void *pMetrics);
outside of the conditional disable, LabVIEW allows me to wire the pMetrics parameter to a cluster.
if i put the function inside the conditional disable, LabVIEW doesn't allow me to wire it.
as a workaround, i put the cluster inside the conditional disable as well.
any ideas?Simply create a constant of the cluster and and put it outside the disable structure. Wire this constant to all inputs (left side terminal) of the Call Library Node. A Call Library Node (CLN) set to Adapt to Type does need a valid datatype to adapt too. This works from the outside side (right side terminal) of the CLN only if the according indicator is inside the same data structure. In older LabVIEW versions you actually had to always define the left side by wiring a constant or a dummy control to it.
This has to do with the algorithme that evaluates datatypes along wires. Making that algorithme go backwards (against the natural dataflow) inside one subdiagram without causing circular references or similar is already a challange. Doing that across diagram boundaries (case, disable, loop, etc. structures) is basically impossible without causing the entire edit operation to get very slow.
Message Edited by rolfk on 10-20-2009 08:28 AM
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions -
How to call stored function in my jsp
how to call stored function in my jsp?
please give me a example.Hi,
think we need mor einformation, like JDeveloper release and the how you do access the database (JDBC, BC4J, EJB,ADF...)
Frank -
Calling a function in another class that is not the App delegate nor a sngl
Hi all-
OK- I have searched and read and searched, however I cannot figure out an easy way to call a function in another class if that class is not the app delegate (I have that down) nor a singleton (done that also- but too much code)
If you use the method Rick posted:
MainView *myMainView = [[MainView alloc] init];
[MyMainView goTell];
That works, however myMainView is a second instance of the class MainView- I want to talk to the instance/Class already instantiated.
Is there a way to do that without making the class a singleton?
Thanks!I had some trouble wrapping my head around this stuff at first too.
I've gotten pretty good at letting my objects communicate with one another, however I don't think my method is the most efficient or organized way but I'll try to explain the basic idea.
When you want a class to be able to talk to another class that's initialized elsewhere, the class your making should just have a pointer in it to the class you want to communicate with. Then at some point (during your init function for example) you should set the pointer to the class you're trying to message.
for example in the app-delegate assume you have an instance of a MainView class
and the app-delegate also makes an instance of a class called WorkClass
If you want WorkClass to know about MainView just give it a pointer of MainView and set it when it's instantiated.
So WorkClass might be defined something like this
//WorkClass.h
@import "MainView.h"
@interface WorkClass : NSObject
MainView *myPointerToTheMainView;
@property (retain) myPointerToTheMainView;
-(void)tellMainViewHello;
@end
//WorkClass.m
@import "WorkClass.h"
@implementation WorkClass
@synthesize myPointerToTheMainView;//this makes getter and setter functions for
//the pointer and allows us to use the dot
//syntax to refrence it.
-(void)tellMainViewHello
[myPointerToTheMainView hello]; //sends a message to the main view
//assume the class MainView has defined a
//method -(void)hello
@end
now somewhere in the app delegate you would make the WorkClass instance and pass it a reference to the MainView class so that WorkClass would be able to call it's say hello method, and have the method go where you want (to the single instance of MainView owned by the app-delegate)
ex:
//somewhere in app-delegate's initialization
//assume MainView *theMainView exists and is instantiated.
WorkClass *myWorkClass = [[WorkClass alloc] init];
myWorkClass.myPointerToTheMainView = theMainView; //now myWorkClass can speak with
// the main view through it's
// reference to it
I hope that gets the basic idea across.
I'm pretty new to Obj-c myself so if I made any mistakes or if anyone has a better way to go about this please feel free to add
Message was edited by: kodafox -
How can call a function module(RFC)in one server to another sever in my rep
How can call a function module(RFC)in one server to another sever in my report program.
What i am know whenever rfc enabled immediately radio button checks then only it will come.
please justify.Syntax
CALL FUNCTION func DESTINATION dest [EXPORTING p1 = a1 p2 = a2 ...]
[IMPORTING p1 = a1 p2 = a2 ...]
[CHANGING p1 = a1 p2 = a2 ...]
[TABLES t1 = itab1 t2 = itab2 ...]
[EXCEPTIONS [exc1 = n1 exc2 = n2 ...]
[system_failure = ns [MESSAGE smess]]
[communication_failure = nc [MESSAGE cmess]]
[OTHERS = n_others]].
http://help.sap.com/saphelp_47x200/helpdata/en/22/042537488911d189490000e829fbbd/frameset.htm
Maybe you are looking for
-
I downloaded Lion yesterday. What a nightmare. Before even using it, I noticed several of my programs would not work with Lion. My Appleworks 6 program was dead as well as some other programs that I had been using for yrs. I have a dual core iMac. If
-
Does a printer expect crop marks?
Hi! If I am sending something to a printer as a photoshop pdf, should I put crop marks? I've seen some people saying that it's their job as the printer to do that. I don't speak directly with the printing company so I can't just ask them, also I want
-
Nokia X1-01 Cell Info Display Problem
My X1-01 sw version 05.27 ,26-05-11,RM -713, Language: MG The problem is that it does not display Cell Info display correctly. Only few times it shows, But only for sometime. Is this bug fixed in the latest version 5.44 ???? and it also has the signa
-
Isight camera not working in iMovie '08 since upgrade to lion
Two weeks ago we were able to create a movie in imovie '08 by directly clicking on the camera symbol to start the recording of a new project. Since I have recently downloaded Lion it now says that I have to connect a camera and isight is no longer av
-
Changing LSMW in Quality server
Hi All, I have created an LSMW in development server and moved it to quality server through a transport. I need to make some changes in the LSMW. I need to know whether I can make changes in quality server directly (as the system is allowing me to ma