Implicit coercion of a value of type String to an unError while Adding Dynamic Rows To Flex DataGrid
Hi friends
I want to add interger for in next next rows while clicking tab button,one i enter all the values in one row if i press tab means next row will be editable.for making that i added the following code.i have some error shows like this
[Bindable]
private var tasks:ArrayCollection;
private static const ADD_TASK:int= "";
private function init():void
tasks = new ArrayCollection();
tasks.addItem(new Task(0.01,100000,0));
tasks.addItem({frmAmount:ADD_TASK});
private function checkEdit(e:DataGridEvent):void
// Do not allow editing of Add Task row except for
// "Click to Add" column
if(e.rowIndex == tasks.length - 1 && e.columnIndex != 0)
e.preventDefault();
private function editEnd(e:DataGridEvent):void
// Adding a new task
if(e.rowIndex == tasks.length - 1)
var txtIn:TextInput =TextInput(e.currentTarget.itemEditorInstance);
var dt:Object = e.itemRenderer.data;
// Add new task
if(parseInt(txtIn.text) != ADD_TASK)
tasks.addItemAt(new Task(parseInt(txtIn.text), 0, ""), e.rowIndex);----->Multiple markers at this line:
-1067: Implicit coercion of a value of type String to an unrelated type int.
-txtIn
// Destroy item editor
commPlanDetGrid.destroyItemEditor();
// Stop default behavior
e.preventDefault();
]]>
Please help if any suggession
Thanks in advance
B.Venkatesan
The error message indicates the problem fairly clearly. _feed_list is defined as a ComboBox in your first line of code. You are passing that as an argument in your populate(_feed_list) line of code. However, the populate function is expecting an XMLList object to be passed, not a ComboBox.
You probably really mean to be using...
populate(feed_items);
since that is the only XMLList to be found
Similar Messages
-
Implicit coercion Error while Adding Dynamic Rows To Flex DataGrid
Hi friends
I want to add interger for in next next rows while clicking tab button,one i enter all the values in one row if i press tab means next row will be editable.for making that i added the following code.i have some error shows like this
[Bindable]
private var tasks:ArrayCollection;
private static const ADD_TASK:int= "";
private function init():void
tasks = new ArrayCollection();
tasks.addItem(new Task(0.01,100000,0));
tasks.addItem({frmAmount:ADD_TASK});
private function checkEdit(e:DataGridEvent):void
// Do not allow editing of Add Task row except for
// "Click to Add" column
if(e.rowIndex == tasks.length - 1 && e.columnIndex != 0)
e.preventDefault();
private function editEnd(e:DataGridEvent):void
// Adding a new task
if(e.rowIndex == tasks.length - 1)
var txtIn:TextInput =TextInput(e.currentTarget.itemEditorInstance);
var dt:Object = e.itemRenderer.data;
// Add new task
if(parseInt(txtIn.text) != ADD_TASK)
tasks.addItemAt(new Task(parseInt(txtIn.text), 0, ""), e.rowIndex);----->Multiple markers at this line:
-1067: Implicit coercion of a value of type String to an unrelated type int.
-txtIn
// Destroy item editor
commPlanDetGrid.destroyItemEditor();
// Stop default behavior
e.preventDefault();
]]>
Please help if any suggession
Thanks in advance
B.VenkatesanVenktesan,
You are trying compare String and int..! which is not possible try to case the txtIn.text to int using parseInt(txtIn.text).
ORIGINAL:
if(txtIn.text != ADD_TASK).---->error : Comparison between a value with static type String and a possibly unrelated type int
tasks.addItemAt(new Task(txtIn.text, 0, ""), e.rowIndex);----> error:Implicit coercion of a value of type String to an unrelated type int.
EDITED:
if(parseInt(txtIn.text) != ADD_TASK).---->error : Comparison between a value with static type String and a possibly unrelated type int
tasks.addItemAt(new Task(parseInt(txtIn.text), 0, ""), e.rowIndex);----> error:Implicit coercion of a value of type String to an unrelated type int.
Thanks
Pradeep -
1067: Implicit coercion of a value of type String to an unrelated type
Hi,
I created a webservice based on sql server 2005 with several methods successfully.
I am having headach now just trying to do some simple tests with Flex :-(
I used the "Import WebService", it created some code "generated webservices".
My test method p_SEARCH_NAME_SOUNDEX is based on a sql procedure wich take a varchar (128) as a parameter => NAL_NOM.
I am just trying to debug this function (error at line in red)
public function searchEntry(name:String):void
// Register the event listener for the findEntry operation.
//agenda.addfindEntryEventListener(handleSearchResult);
myWS.addp_SEARCH_NAME_SOUNDEXEventListener(handleSearchResult);
// Call the operation if we have a valid name.
if(name!= null && name.length > 0)
myWS.p_SEARCH_NAME_SOUNDEX(name);
I got this error message:
067: Implicit coercion of a value of type String to an unrelated type generated.webservices:NAL_NOM_type1.
FLEX has creaetd a type called NAL_NOM_type1 for my class:
* NAL_NOM_type1.as
* This file was auto-generated from WSDL by the Apache Axis2 generator modified by Adobe
* Any change made to this file will be overwritten when the code is re-generated.
package generated.webservices
import mx.utils.ObjectProxy;
import flash.utils.ByteArray;
import mx.rpc.soap.types.*;
* Wrapper class for a operation required type
public class NAL_NOM_type1
* Constructor, initializes the type class
public function NAL_NOM_type1() {}
public var varchar:String;public function toString():String
return varchar.toString();
I tried to do myWS.p_SEARCH_NAME_SOUNDEX(NAL_NOM_type1(name));
and also declared "name" as NAL_NOM_type1... but i still get this error.
This is how it declared my webservice method:
public function p_SEARCH_NAME_SOUNDEX(nAL_NOM:NAL_NOM_type1):AsyncToken
var _internal_token:AsyncToken = _baseService.p_SEARCH_NAME_SOUNDEX(nAL_NOM);
_internal_token.addEventListener("result",_P_SEARCH_NAME_SOUNDEX_populate_results);
_internal_token.addEventListener("fault",throwFault);
return _internal_token;
I am even not on the level of assigning the data to my grid... i just want to see how it gets the data first in debug.
Thanks in advance for you help.
kr,
MetaThanks _Natasha_
I tried this:
var t = new NAL_NOM_type1();
t.varchar = name;
myWS.p_SEARCH_NAME_SOUNDEX(t);
It passes the 1st step :-) but I get another error now :-/
I think it try to get back NAL_NOM_type1 from the server of course on the WSDL side it know only NAL_NOM
Error: Cannot find definition for type 'http://NABSQL64DEV/::NAL_NOM_type1'
at mx.rpc.xml::XMLEncoder/encodeType()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc \xml\XMLEncoder.as:1426]
I guess I have to change my constructor type... i am not used to these stuff :-s
is this generating method the best way to access your data with webservices?
the turorials I saw are xml file or array based... is there any link similar to my issue so I can learn better? -
Hello, i've a class named LoadImages with the code:
package
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.display.Loader;
public class LoadImages extends MovieClip
private var _root:MovieClip=new MovieClip();
public function LoadImages(numImages:Number, rt:MovieClip)
and i've a second class named MainJogo that call's LoadImages:
package
import flash.events.*;
import flash.display.Loader;
import flash.display.MovieClip;
import flash.display.Stage;
import LoadImages;
public class MainJogo
#error
private var imgMc:LoadImages=new LoadImages(2,this);
#error
public function MainJogo(url:String)
if i just post the MainJogo class code in TimeLine there is no problems but if i run the app like this with 2 classes i keep getting the error
1067: Implicit coercion of a value of type Class to an unrelated type flash.display:MovieClip.
Can someone help me please?
thanksMainJogo is not a Movieclip so "this" (in the scope of MainJogo) is not a MovieClip.
if MainJogo did extend the movieclip class, you would probably still need to cast "this" as a MovieClip.
you could use:
package
import flash.events.*;
import flash.display.Loader;
import flash.display.MovieClip;
import flash.display.Stage;
import LoadImages;
public class MainJogo extends MovieClip
private var imgMc:LoadImages=new LoadImages(2,MovieClip(this));
public function MainJogo(url:String) -
Error:1067 - Implicit coercion of a value of type QName to an unrelated type QName
hi,
I'm new in flex and my english not good. I'll try to explain
my problem :(
I have an application mxml and a component mxml. I imported a
wsdl from .net webservice.
In main mxml I added:
<mx:Application .....
xmlns:webservices="generated.webservices.*"/>
and
<webservices:xService id="m_service"/>
there is no problem for this. But when I added into component
mxml like this:
<mx:Canvas.....
xmlns:webservices2="generated.webservices.*"/>
and
<webservices2:xService id="m_service2"/>
I'm getting the following error:
error line sample: (and 633 similar lines in
generated.webservices)
responseMessage.wrappedQName = new QName("
http://tempuri.org/","GetMemberListResponse");
error:
1067: Implicit coercion of a value of type QName to an
unrelated type QName
When I removed the <webservices2:xService
id="m_service2"/> line from component mxml, I'm not getting an
error.
Flex 3.0 - sdk 4.0
Thanx for your helpsthanx your answer,
I changed (like this:[WebService(Namespace = "
http://Info.WebService/MyInfoService"))
but it doesn't work. I still have same problem.
It's really strange problem. When I used in application mxml,
it's working. But when I used in component mxml, I'm getting error.
I tested the web servise in other test application mxml with
following code: (it's working excellent)
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute" xmlns:webservices="generated.webservices.*"
creationComplete="test12()">
<mx:Script>
<![CDATA[
import mx.rpc.AsyncToken;
private function test12():void
m_service12.addgetFuelList_header(GetAuthHeader());
m_service12.getFuelList();
]]>
</mx:Script>
<mx:Script source="***/ServiceAuthHeaderGetter.as"/>
<webservices:TankInfoService id="m_service12"/>
<mx:DataGrid
dataProvider="{m_service12.getFuelList_lastResult}">
</mx:DataGrid>
</mx:Application>
And finally I closed "Enable strict type checking" from
project properties and the errors are disappeared.
But now I got new problems with webservice :)
TypeError: Error #1009: Cannot access a property or method of
a null object reference.
I guess <webservices:TankInfoService id="m_service"/>
is null.
But why?
in component mxml
I added xmlns:webservices="generated.webservices.*" namespace
and
<webservices:TankInfoService id="m_service"/>
my code is:
m_service.addgetMemberList_header(GetAuthHeader());
m_service.getMemberByUserPassword(this.txtUser.text,
this.txtPassword.text);
the error:
TypeError: Error #1009: Cannot access a property or method
of a null object reference.
Any ideas??? -
Here is what I have going on.
When a button in my app is clicked it will instantiate a new object called ButtonCommand, within that object I create a new instance of a ListVO called vo. I then reference my model object that also has a separate instance of the same Value Object ListVO class, reference its properties and place it into the corresponding property of the new VO object. Here is the code.
var vo:ListVO = new ListVO();
vo.name = model.list.name;
vo.id = model.list.id;
vo.amount = model.list.amount;
vo.category = model.list.category;
Within that same ButtonCommand class, next line I am trying to add the new ListVO instance to an arrayCollection that is also referenced from my model object, so here is the code for that.
model.listCollection = model.listCollection.addItem(vo);
I get the following error : -1067: Implicit coercion of a value of type void to an unrelated type mx.collections:ArrayCollection.
And here is my getter/setter for the model.listCollection.
public function get listCollection ():ArrayCollection
return _listCollection;
public function set listCollection(value:ArrayCollection):void
_listCollection = value;
Any Ideas?I thought model.listCollection is an ArrayCollection?
model.listCollection is an ArrayCollection as shown in the example model code a few posts back.
public class Model extends Actor
//- PROPERTIES - //
//-- other properties are here
private var _listCollection:ArrayCollection = new ArrayCollection();
public function Model()
super();
//other getter and setters here
public function get listCollection ():ArrayCollection
return _listCollection;
public function set listCollection(value:ArrayCollection):void
_listCollection = value;
I am finding this to be very odd, seems like a simple getter setter situation, but I feel I must be missing something. The code trace(model.listCollection); should trace out as an ArrayCollection and not the VO object I am trying to add to it. Also when i run the code model.listCollection.addItem(vo); it should add the vo to the array collection through my setter, but yet it seems to try to access my getter.
I took Kglads advice and traced out _listCollection within my getter before my return statement and it returns [object ListVO]..... confused for sure. I am going to change the _listCollection property in the model from private with a getter/setter to a public and see what happens. -
1067: Implicit coercion of a value of type void to an unrelated type Array.
public function Helicopter (stageRef:Stage) : void
this.stageRef =stageRef;
addEventListener(Event.ENTER_FRAME, loop, false, 0, true);
addEventListener(Event.ENTER_FRAME, Backdrop);
key = new KeyObject(stageRef);
x = stageRef.stageWidth/2;
y = stageRef.stageHeight/2;
I'm basically having the following error:
1067: Implicit coercion of a value of type void to an unrelated type Array.
In relation to the event listener that calls 'Backdrop'. Backdrop is a public function in another class, but it does still recognise Backdrop as a function. Any ideas on what might be causing the error?there's no Backdrop method there. and, if you're importing your Backdrop class, you can't use a Backdrop method. i don't know what you're trying to do but if you're trying to create a Backdrop instance use the following:
package com.chopper.helicopter
import flash.display.MovieClip;
import flash.events.Event;
import com.senocular.utils.KeyObject;
import flash.display.Stage;
import flash.ui.Keyboard;
public class Backdrop extends flash.display.MovieClip
public function Backdrop() : void
trace ("Working code")
/* none of this makes sense
x += vx;
if (vx > maxspeed)
vx = maxspeed;
else if (vx < -maxspeed)
vx = -maxspeed;
package com.chopper.helicopter
import flash.display.MovieClip;
import flash.events.Event;
import com.senocular.utils.KeyObject;
import flash.display.Stage;
import flash.ui.Keyboard;
public class Helicopter extends MovieClip
private var gravity:Number = 1;
private var vy:Number = 0;
public var vx:Number = 0;
private var key:KeyObject;
private var stageRef:Stage;
private var bd:Backdrop;
public var maxspeedG:Number = 6;
public var maxspeed:Number = 3;
private var friction:Number = 0.92;
public function Helicopter (_stageRef:Stage) : void
stageRef =_stageRef;
addEventListener(Event.ENTER_FRAME, loop, false, 0, true);
trace ("working code")
addEventListener(Event.ADDED_TO_STAGE, backdropF);
key = new KeyObject(stageRef);
x = stageRef.stageWidth/2;
y = stageRef.stageHeight/2;
private function backdropF(e:Event):void{
bd=new Backdrop();
stageRef.addChild(bd);
public function loop(e:Event) : void
// some of these variables appear to be undefined
vy += gravity;
y += vy;
x += vx;
if (vy > maxspeedG)
vy = maxspeedG;
else if (vy < -maxspeed)
vy = -maxspeed;
if (vx > maxspeed)
vx = maxspeed;
else if (vx < -maxspeed)
vx = -maxspeed;
if (vx > 0)
scaleX = 1;
else if (vx < 0)
scaleX = -1;
if (y > stageRef.stageHeight)
y = stageRef.stageHeight;
vy = -8
rotation = vx*2;
if (key.isDown(Keyboard.RIGHT))
vx += .5;
else if (key.isDown(Keyboard.LEFT))
vx -= .5;
else
vx *= friction;
if (key.isDown(Keyboard.UP))
vy -= 1;
else if (key.isDown(Keyboard.DOWN))
vy += .5; -
These are my errors: in Adobe Flash CS5.5
I don't understand why this script doesn't work. I am new to Action Script 3.0 and I watched this incomplete video on youtube. -- http://www.youtube.com/watch?v=LC7BaZCForE&feature=relmfu -- and I got the fails below.
Scene 1, Layer 'actionscript', Frame 1, Line 11 1067: Implicit coercion of a value of type flash.display:MovieClip to an unrelated type Class.
Scene 1, Layer 'actionscript', Frame 1, Line 11 1118: Implicit coercion of a value with static type Object to a possibly unrelated type flash.display:DisplayObject.
Main Timeline:
import flash.filters.GlowFilter;
import flash.events.MouseEvent;
import flash.display.MovieClip;
var navBtnGlow:GlowFilter = new GlowFilter(0x999999, 0.5, 0, 15, 1, 2, true, false);
navbar_jj.addEventListener(MouseEvent.MOUSE_OVER, navOverF);
navbar_jj.addEventListener(MouseEvent.MOUSE_OUT, navOutF);
function navOverF(event:MouseEvent):void{
event.target.filters = [navBtnGlow];
navbar_jj.setChildIndex(event.target as MovieClip(event.target), 1);
dropmenus_jj.gotoAndStop(navbar_jj.getChildAt(1).name);
trace("We are Rolled Over..." + navbar_jj.getChildAt(1).name)
function navOutF(event:MouseEvent):void{
event.target.filters = [];
Clicker Drop Down
import flash.events.MouseEvent;
stop();
leadersframe_btn.addEventListener(MouseEvent.MOUSE_OVER, goBackF);
function goBackF(event:MouseEvent):void{
gotoAndStop (1);Use:
navbar_jj.setChildIndex(MovieClip(event.target), 1);
Or
navbar_jj.setChildIndex(DisplayObject(event.target), 1); -
Error while saving dynamic row values of datagrid with record.
hi friends,
i am trying to add dynamic row in datagrid and save that value with record.i succeeded in first part while i am saving the record the error show like this.
errro:Property fromAmount not found on com.ci.view.Task and there is no default value.
how i resolve this error.
any suggession welcom
thanks in advance.
B.venkatesan
code:
package:
package com.ci.view
[Bindable]
public class Task
public function Task(frmAmount:String,toAmount:String,commissionPercentage:String)
this.frmAmount=frmAmount;
this.toAmount=toAmount;
this.commissionPercentage=commissionPercentage;
public var frmAmount:String;
public var toAmount:String;
public var commissionPercentage:String;
main mxml:
[Bindable]
private var tasks:ArrayCollection;
private static const ADD_TASK:String= "";
private function init():void
tasks = new ArrayCollection();
tasks.addItem(new Task("0","1000","0"));
tasks.addItem({frmAmount:ADD_TASK});
private function checkEdit(e:DataGridEvent):void
// Do not allow editing of Add Task row except for
// "Click to Add" column
if(e.rowIndex == tasks.length - 1 && e.columnIndex != 0)
e.preventDefault();
private function editEnd(e:DataGridEvent):void
// Adding a new task
if(e.rowIndex == tasks.length - 1)
var txtIn:TextInput =TextInput(e.currentTarget.itemEditorInstance);
var txtIn1:TextInput =TextInput(e.currentTarget.itemEditorInstance);
var txtIn2:TextInput =TextInput(e.currentTarget.itemEditorInstance);
var dt:Object = e.itemRenderer.data;
// Add new task
if((txtIn.text) != ADD_TASK)
var x:String=String(txtIn.text);
tasks.addItemAt(new Task("", "", ""), e.rowIndex);
// Destroy item editor
commPlanDetGrid.destroyItemEditor();
// Stop default behavior
e.preventDefault();Venktesan,
You are trying compare String and int..! which is not possible try to case the txtIn.text to int using parseInt(txtIn.text).
ORIGINAL:
if(txtIn.text != ADD_TASK).---->error : Comparison between a value with static type String and a possibly unrelated type int
tasks.addItemAt(new Task(txtIn.text, 0, ""), e.rowIndex);----> error:Implicit coercion of a value of type String to an unrelated type int.
EDITED:
if(parseInt(txtIn.text) != ADD_TASK).---->error : Comparison between a value with static type String and a possibly unrelated type int
tasks.addItemAt(new Task(parseInt(txtIn.text), 0, ""), e.rowIndex);----> error:Implicit coercion of a value of type String to an unrelated type int.
Thanks
Pradeep -
I am getting the following error while migrating my application from Flex 3.6 to Flex 4.5.1:
1067: Implicit coercion of a value of type __AS3__.vec:Vector.<Object> to an unrelated type Array.
The error is thrown on the following piece of code:
var list:ArrayCollection=new ArrayCollection(dgSoftwareTitles.selectedItems);
dgSoftwareTitles is defined as:
<s:DataGrid id="dgShareCategoryForTransfer"
x="34"
y="369"
requestedRowCount="5"
width="90%"
selectedIndex="-1"
selectionMode="multipleRows">
<s:columns>
<s:ArrayList>
<s:GridColumn headerText="SoftwareTitle"
dataField="idSoftware"
visible="false"/>
<s:GridColumn headerText="SoftwareName"
dataField="softwareName"
visible="false"/>
...more GridColumns
</s:columns>
</s:ArrayList>
</s:DataGrid>
Any ideas why this would trow the "1067: Implicit coercion of a value of type __AS3__.vec:Vector.<Object> to an unrelated type Array" error?
Thanks!
LeeI think that dgSoftwareTitles.selectedItems is a type of Vector while
public function ArrayCollection(source:Array = null) expects an array as a source. -
Hi All,
I am reading notepads files and inserting data in sql tables from the notepad-
while performing sql bulk copy on this line it throws exception - "bulkcopy.WriteToServer(dt); -"data type related(mentioned in subject )".
Please go through my logic and tell me what to change to avoid this error -
public void Main()
Dts.TaskResult = (int)ScriptResults.Success;
string[] filePaths = Directory.GetFiles(@"C:\Users\jainruc\Desktop\Sudhanshu\master_db\Archive\test\content_insert\");
for (int k = 0; k < filePaths.Length; k++)
string[] lines = System.IO.File.ReadAllLines(filePaths[k]);
//table name needs to extract after = sign
string[] pathArr = filePaths[0].Split('\\');
string tablename = pathArr[9].Split('.')[0];
DataTable dt = new DataTable(tablename);
|
string[] arrColumns = lines[1].Split(new char[] { '|' });
foreach (string col in arrColumns)
dt.Columns.Add(col);
for (int i = 2; i < lines.Length; i++)
string[] columnsvals = lines[i].Split(new char[] { '|' });
DataRow dr = dt.NewRow();
for (int j = 0; j < columnsvals.Length; j++)
//Console.Write(columnsvals[j]);
if (string.IsNullOrEmpty(columnsvals[j]))
dr[j] = DBNull.Value;
else
dr[j] = columnsvals[j];
dt.Rows.Add(dr);
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "Data Source=UI3DATS009X;" + "Initial Catalog=BHI_CSP_DB;" + "User Id=sa;" + "Password=3pp$erv1ce$4";
conn.Open();
SqlBulkCopy bulkcopy = new SqlBulkCopy(conn);
bulkcopy.DestinationTableName = dt.TableName;
bulkcopy.WriteToServer(dt);
conn.Close();
Issue 1:-
I am reading notepad: getting all column and values in my data table now while inserting for date and time or integer field i need to do explicit conversion how to write for specific column before bulkcopy.WriteToServer(dt);
Issue 2:- Notepad does not contains all columns nor in specific sequence in that case i can add few column ehich i am doing now but the issue is now data table will add my columns + notepad columns and while inserting how to assign in perticular colums?
sudhanshu sharma Do good and cast it into river :)Hi,
I think you'll have to do an explicit column mapping if they are not in exact sequence in both source and destination.
Have a look at this link:
https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopycolumnmapping(v=vs.110).aspx
Good Luck!
Kaur.
Please mark as answer if this resolves your issue. -
Hi All,
I've got the following code:
var currentStateIndex:int = 0;
for (var index:int in this.states){
if(this.currentState == this.states[index].name){
currentStateIndex = index;
break;
I'm trying to identify the index of the current state. It's giving me an error on the for line, saying "Implicit coercion of a value of type String to an unrelated type int." Hmm, strange, I thought--wouldn't the keys of the this.states array (and it is just a plain vanilla array) be integers?
So, I tried this:
var currentStateIndex:int = 0;
for (var index:* in this.states){
var theType:* = flash.utils.describeType(index);
if(this.currentState == this.states[index].name){
currentStateIndex = index;
break;
I used the debugger to inspect the value of theType. It's this:
<type name="int" base="Object" isDynamic="false" isFinal="true" isStatic="false">
<extendsClass type="Object"/>
<constructor>
<parameter index="1" type="*" optional="true"/>
</constructor>
</type>
So, indeed, describeType says that the index value is of type "int"... so why can't I strongly type it as an int?rtalton wrote:
This works:
var currentStateIndex:int;
for (var idx:String in this.states) {
if (this.currentState == this.states[idx].name) {
//the names match!
currentStateIndex = int(idx);//cast as an integer.
break;
But using your method you will never get a match for the base state, which is always "null", and does not have a name property.
What is the right way to identify the index of the current state, if the current state is the default state? -
AS3: Classes, subclasses and "implicit coercion"
Hi.
I have created several custom classes:
- Category, containing a string with the category's name.
- SubCategory, extends Category.
- CategoryList, containing an array of Category instances and
a function getCategoryByName.
- SubCategoryTracer, with a function subTrace that traces the
name of a given SubCategory.
When I use subTrace, if the argument is a direct SubCategory,
it works fine, but if it's the result of getCategoryByName, even
when it does return a SubCategory object, I get the following
error:
1118: Implicit coercion of a value with static type
tests:Category to a possibly unrelated type tests:SubCategory.
How can I get this to work? Thanks in advance.1. I guess you need to change the code to the following (read the comments):
// Creates an object from the class called mySample
var externalFile:mySample = new mySample();
// allows the program to read the text box as a number
* these two lines DO NOT read text field values when they change
* so these two vars are useless unless you want to retain original values
var num1 = Number(txtBox1.text)
var num2 = Number(txtBox2.text)
//Button event listener
btnCalc.addEventListener(MouseEvent.CLICK, clickHandler);
function clickHandler(e:MouseEvent):void
// read textfields' values every time user clicks the button
resultTextBox.text = String(externalFile.addNumbers(Number(txtBox1.text), Number(txtBox2.text)));
2. You need to get into a habit to strictly type you variables and objects.
3. You should get into a habit to declare variable namespace (private, public, etc.) of the variables. SO you class variables declarations should be:
private var num1:Number;
private var num2:Number;
private var answer:Number;
4. It is wise to name classes starting with upper case - it is a convention that makes AS programmer life easier.
5. Since your class has no other task but calculate and return new value - declaring additional calss level variables (num1, num2, and answer) introduces an unnecessary overhead. These variables existence would be justified only if they were reused.
I suggest your class should be like that (note that addNumber method's parameters are typed to Number):
package
public class MySample
//create a function
public function addNumbers(num1:Number, num2:Number):Number
return num1 + num2; //this function returns something that can be used elsewhere -
Problem in getting last value of a string in Function Module
Hi,
I am working on FM in which i have to put highfen mark which is working ok,but the problem if there is when the value of string finds a space it should not insert highfen in it and i am not able to put the condition in it as it showing the higfen even when the word is full in the first line.i want to show highfen where the word is not able to display complete. here is d code which i am using right now. plzz provide me guidlines to solve this problem.
here's d code:-
FUNCTION Z_STRING_LENGTH1.
*"*"Local Interface:
*" IMPORTING
*" VALUE(I_STRING) TYPE STRING
*" VALUE(LENGTH) TYPE I
*" EXPORTING
*" VALUE(E_STRING) TYPE STRING
data: STRING_F type string, "Stores the value in string format
STRING_LENGTH type i, "Length of the string
DIFF type i, "Difference among the value
DIFF1 TYPE C,
STRING1 type string, "Stores the 1st String
STRING2 type string, "Stores the 2nd String
STRING3 type string, "Stores the 3rd String
STRING4 type string, "Stores the 3rd String
STRING5 type string, "Stores the 3rd String
LENGTH2 type I.
STRING_F = I_STRING.
STRING_LENGTH = STRLEN( I_STRING ).
DIFF = STRING_LENGTH - LENGTH.
IF DIFF LE 0.
DIFF = 0.
ENDIF.
IF LENGTH LE STRING_LENGTH.
STRING1 = STRING_F(LENGTH).
ELSE.
STRING1 = STRING_F(STRING_LENGTH).
ENDIF.
IF LENGTH LE STRING_LENGTH.
STRING2 = STRING_F+LENGTH(DIFF).
ELSE.
STRING2 = STRING_F+STRING_LENGTH(DIFF).
ENDIF.
length2 = length - 1.
STRING3 = STRING1+length2(1).
STRING4 = STRING2+0(1).
IF LENGTH LE STRING_LENGTH AND STRING3 NE SPACE AND STRING4 NE SPACE.
concatenate STRING1 '-' STRING2 into STRING5.
e_string = STRING5.
ELSE.
concatenate STRING1 STRING2 into STRING5.
e_string = STRING5.
ENDIF.
ENDFUNCTION.
Edited by: ricx .s on May 12, 2009 5:20 AMHi,
I checked your code... its working fine except for some cases it is giving dumps for which I have added certain if conditions....
Please check the modified code below... have optimized it as well by removing one extra if condition....
you can copy and paste the code below...
DATA: STRING_F TYPE STRING, "Stores the value in string format
STRING_LENGTH TYPE I, "Length of the string
DIFF TYPE I, "Difference among the value
DIFF1 TYPE C,
STRING1 TYPE STRING, "Stores the 1st String
STRING2 TYPE STRING, "Stores the 2nd String
STRING3 TYPE STRING, "Stores the 3rd String
STRING4 TYPE STRING, "Stores the 3rd String
STRING5 TYPE STRING, "Stores the 3rd String
LENGTH2 TYPE I.
STRING_F = I_STRING.
STRING_LENGTH = STRLEN( I_STRING ).
DIFF = STRING_LENGTH - LENGTH.
IF DIFF LE 0.
DIFF = 0.
ENDIF.
IF LENGTH LE STRING_LENGTH.
STRING1 = STRING_F(LENGTH).
STRING2 = STRING_F+LENGTH(DIFF). " added this statement in this if itself instead of one extra if
" which is not required
ELSE.
STRING1 = STRING_F(STRING_LENGTH).
STRING2 = STRING_F+STRING_LENGTH(DIFF).
ENDIF.
IF LENGTH IS NOT INITIAL.
LENGTH2 = LENGTH - 1.
ENDIF.
" put this if condition as there is a dump occuring at this place.
" Dump occurs when you give the length value as 0
" Say for example the value of I_STRING, I passed it as SIDDARTH
" and the length I passed as 0, then it gives me a dump
STRING3 = STRING1+LENGTH2(1).
IF STRING2 IS NOT INITIAL.
STRING4 = STRING2+0(1).
ENDIF.
" put this if condition as there is a dump occuring at this place.
" Dump occurs when you give the length value greater than or equal to
" the string length
" Say for example the value of I_STRING, I passed it as SIDDARTH
" and the length I passed as 8, then it gives me a dump
IF LENGTH LE STRING_LENGTH AND STRING3 NE SPACE AND STRING4 NE SPACE.
CONCATENATE STRING1 '-' STRING2 INTO STRING5.
E_STRING = STRING5.
ELSE.
CONCATENATE STRING1 STRING2 INTO STRING5.
E_STRING = STRING5.
ENDIF. -
How to refresh the grid so that default values come on adding new row.
Hi Experts,
In alv grid while adding new row, i want some 2-3 column values to come by default from already existing row in grid.
i am getting new row in internal table with 2-3 default values and rest columns blank on adding new row in alv grid
but the entire row is coming blank, not able to get the default values in new row
how can i refresh the grid so that default values come on adding new row.
thanksHi Surabhi,
Use this in Interactive section even if you are doing simple ALV.
DATA:
lv_ref_grid TYPE REF TO cl_gui_alv_grid.
CLEAR : gv_tcode.
*-- to ensure that only new processed data is displayed
IF lv_ref_grid IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = lv_ref_grid.
ENDIF.
IF NOT lv_ref_grid IS INITIAL.
CALL METHOD lv_ref_grid->check_changed_data.
ENDIF.
THis will solve your problem.
Regards,
Vijay
Maybe you are looking for
-
New iMac won't recognize my external monitor.
I just upgraded my workplace computer to a late-2012 iMac (with the thin edges) from the previous older model. I have an external monitor that I use as a secondary screen - a Samsung SyncMaster BX2440 - that worked great on my older machine using the
-
Since iDvd is no longer supplied with Lion, what is best to use to burn to dvd for TV?
Since iDvd is no longer supplied with Lion, what is the best product to use to burn to dvd for TV from iMac? Is there a free solution?
-
Ok so my problem is when i plugged my ipad to restore and update to the new firmware update 3.2.2, everything was going smoothly, untill i got a error numbered 1014, Please help me i have tried everything many times, im trying to restore it in my mac
-
IPhoto '11 - when I click to 'confirm additional faces', most images are duplicated.
when I click to 'confirm additional faces', most images are duplicated. iPhoto '11 using 'Faces' - when I click to 'confirm additional faces', most images are duplicated. It has become a hassle. Even after confirming and not confirming images, some
-
Any one can help the highlighted question pz..thank you!!
Declare Cursor c_sale is Select order_line.product_id,quantity, unit_cost,unit_price, client_id, SR_id, order_date From sale Where product_id = : CLIENT_TYPE_ID VARCHAR2(10), PRODUCT_ID VARCHAR2(10), QUANTITY VARCHAR2(10), UNIT_COST UNIT_PRICE CLIENT