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,
Meta

Thanks _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?

Similar Messages

  • 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 helps

    thanx 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???

  • 1067: Implicit coercion of a value of type void to an unrelated type mx.collections:ArrayCollection.

    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 Class to an unrelated type flash.display:MovieClip

    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?
    thanks

    MainJogo 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)

  • 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;

  • 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

  • Error while migrating to Flex 4.5.1 (1067: Implicit coercion of a value...)

    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!
    Lee

    I think that dgSoftwareTitles.selectedItems is a type of Vector while
    public function ArrayCollection(source:Array = null) expects an array as a source.

  • Implicit coercion of a value of type flash.display:MovieClip to an unrelated type Class.

    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);

  • Loads of errors with classes: 1067 implicit coercion 118 illegal assignment

    Hi
    I have a main.fla and the two classes below VirtualGarage and VirtualCar. Main has VirtualGarage as its class which in turn works with VirtualCar. The code seems quite good but I get these errors. If anybody could help
    Cheers
    //VirtualGarage class
    package
    public class VirtualCar extends VirtualGarage
    var carSpeed:Number;
    var carColour:String;
    var carPrice:String;
    var car;
    public function VirtualCar(speed,colour,price)
    this.carSpeed = speed;
    this.carColour = colour;
    this.carPrice = price;
    //VirtualCar class
    package
    import VirtualCar;
    public class VirtualGarage
    private var newVirtualCar;
    public function VirtualGarage()
    newVirtualCar:VirtualCar = new VirtualCar(20,"red",30000);
    trace(newVirtualCar.speed;

    Hi - thank you very much.
    I know have the concept pretty well learnt. Although I find the statement class extends something to be ambiguous - it doesn't actually extend it - it inherits methods and properties from it. That's why I was so confused.
    However, I still have an error after modifying certain parts of code
    Main is now VirtualGarage.fla
                      VirtualGarage.as - class document
                      VirtualCar.as - another class
    Both .as docs reside in a folder called "garage" therefore there package name is garage.
    I get these errors 1067 implicit coercion... and 1188 illegal assignment to VirtualCar
    VirtualGarage.as
    package garage
    import flash.display.Sprite;
    public class VirtualGarage extends Sprite
    private var newVirtualCar:VirtualCar;
    public function VirtualGarage()
    newVirtualCar:VirtualCar = new VirtualCar("red"); //throws the error - 1067 implicit coercion... and 1188 illegal assignment to VirtualCar
    VirtualCar.as
    package garage
    public class VirtualCar //extends what? ie: a movieclip that calls it or the main class
    public var colour:String;
    public function VirtualCar(newColour)
    colour = newColour;

  • 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.Venkatesan

    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

  • For ... in loop giving me an "implicit coercion" error--but describeType says I've got right type?

    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

  • What is the best way of dealing with an "implicit coercion" of an array to a sprite?

    Hello everyone!
         With continued help from this forum I am getting closer to having a working program. I look forward to being able to help others like myself once I finish learning the AS3 ropes.
         I will briefly explain what I am trying to achieve and then follow it up with my question.
    Background
         I have created a 12 x 9 random number grid that populates each cell with a corresponding image based on each cell's numeric value. I have also created a shuffle button that randomizes the numbers in the grid. The problem I am running into is getting my button-click event to clear the current images off the grid in order to assign new ones (i.e. deleting the display stack objects in order to place news ones in the same locations).
    Question
         My question is this: what is the best way to handle an implicit coercion from an array to a sprite? I have pasted my entire code below so that you can see how the functions are supposed to work together. My trouble apparently lies with not being able to use an array value with a sprite (the sprite represents the actual arrangement of the grid on the display stack while the array starts out as a number than gets assigned an image which should be passed to the sprite).
    ============================================================================
    package 
    import flash.display.MovieClip;
    import flash.display.DisplayObject;
    import flash.events.MouseEvent;
    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.text.TextFormat;
    import flash.utils.getDefinitionByName;
    public class Blanko extends MovieClip
          // Holds 12*9 grid of cells.
          var grid:Sprite;
          // Holds the shuffle button.
          var shuffleButton:Sprite;
          // Equals 12 columns, 9 rows.
          var cols:int = 12;
          var rows:int = 9;
          // Equals number of cells in grid (108).
          var cells:int = cols * rows;
          // Sets cell width and height to 40 pixels.
          var cellW:int = 40;
          var cellH:int = 40;
          // Holds 108 cell images.
          var imageArray:Array = [];
          // Holds 108 numerical values for the cells in the grid.
          var cellNumbers:Array = [];
          // Constructor calls "generateGrid" and "makeShuffleButton" functions.
          public function Blanko()
               generateGrid();
               makeShuffleButton();
      // Creates and displays the 12*9 grid.
      private function generateGrid():void
           grid = new Sprite;
           var i:int = 0;
           for (i = 0; i < cells; i++)
                cellNumbers.push(i % 9 + 1);
           trace("Before shuffle: ", cellNumbers);
           shuffleCells(cellNumbers);
           trace("After shuffle: ", cellNumbers);
           var _cell:Sprite;
           for (i = 0; i < cells; i++)
                // This next line is where the implicit coercion occurs. "_cell" is a sprite that tries
                   to temporarily equal an array value.
                _cell = drawCells(cellNumbers[i]);
                _cell.x = (i % cols) * cellW;
                _cell.y = (i / cols) * cellH;
                grid.addChild(_cell);
      // Creates a "shuffle" button and adds an on-click mouse event.
      private function makeShuffleButton():void
           var _label:TextField = new TextField();
           _label.autoSize = "center";
           TextField(_label).multiline = TextField(_label).wordWrap = false;
           TextField(_label).defaultTextFormat = new TextFormat("Arial", 11, 0xFFFFFF, "bold");
           _label.text = "SHUFFLE";
           _label.x = 4;
           _label.y = 2;
           shuffleButton = new Sprite();
           shuffleButton.graphics.beginFill(0x484848);
           shuffleButton.graphics.drawRoundRect(0, 0, _label.width + _label.x * 2, _label.height +
                                                _label.y * 2, 10);
           shuffleButton.addChild(_label);
           shuffleButton.buttonMode = shuffleButton.useHandCursor = true;
           shuffleButton.mouseChildren = false;
           shuffleButton.x = grid.x + 30 + grid.width - shuffleButton.width;
           shuffleButton.y = grid.y + grid.height + 10;
           this.addChild(shuffleButton);
           shuffleButton.addEventListener(MouseEvent.CLICK, onShuffleButtonClick);
      // Clears cell images, shuffles their numbers and then assigns them new images.
      private function onShuffleButtonClick():void
       eraseCells();
       shuffleCells(cellNumbers);
       trace("After shuffle: ", cellNumbers);
       for (var i:int = 0; i < cells; i++)
        drawCells(cellNumbers[i]);
      // Removes any existing cell images from the display stack.
      private function eraseCells(): void
       while (imageArray.numChildren > 0)
        imageArray.removeChildAt(0);
      // Shuffles cell numbers (randomizes array).
      private function shuffleCells(_array:Array):void
       var _number:int = 0;
       var _a:int = 0;
       var _b:int = 0;
       var _rand:int = 0;
       for (var i:int = _array.length - 1; i > 0; i--)
        _rand = Math.random() * (i - 1);
        _a = _array[i];
        _b = _array[_rand];
        _array[i] = _b;
        _array[_rand] = _a;
      // Retrieves and assigns a custom image to a cell based on its numerical value.
      private function drawCells(_numeral:int):Array
       var _classRef:Class = Class(getDefinitionByName("skin" + _numeral));
       _classRef.x = 30;
       imageArray.push(_classRef);
       imageArray.addChild(_classRef);
       return imageArray;
    ===========================================================================
         Any help with this is greatly appreciated. Thanks!

    Rothrock,
         Thank you for the reply. Let me address a few things here in the hopes of allowing you (and others) to better understand my reasoning for doing things in this manner (admittedly, there is probably a much better/easier approach to what I am trying to accomplish which is one of the things I hope to learn/discover from these posts).
         The elements inside my "imageArray" are all individual graphics that I had imported, changed their type to movie clips using .Sprite as their base class (instead of .MovieClip) and then saved as classes. The reason I did this was because the classes could then be referenced via "getDefinitionByName" by each cell value that was being passed to it. In this grid every number from 1 to 9 appears randomly 12 times each (making the 108 cells which populate the grid). I did not, at the time (nor do I now), know of a better method to implement for making sure that each image appears in the cell that has the corresponding value (i.e. every time a cell has the value of 8 then the custom graphic/class "skin8" will be assigned to it so that the viewer will be able to see a more aesthetically pleasing numerical representation, that is to say a slightly more fancy looking number with a picture behind it). I was advised to store these images in an array so that I could destroy them when I reshuffle the grid in order to make room for the new images (but I probably messed up the instructions).
         If the "drawCell" function only returns a sprite rather than the image array itself, doesn't that mean that my "eraseCells" function won't be able to delete the array's children as their values weren't first returned to the global variable which my erasing function is accessing?
         As for the function name "drawCells," you have to keep in mind that a) my program has been redesigned in stages as I add new functionality/remove old functionality (such as removing text labels and formatting which were originally in this function) and b) that my program is called "Blanko."
         I will try and attach an Illustrator exported JPG file that contains the image I am using as the class "skin7" just to give you an example of what I'm trying to use as labels (although it won't let me insert it here in this post, so I will try it in the next post).
    Thank you for your help!

  • Not able to get the value from type defined in other progarm

    Hi All,
    I have a create a type in one package spec(Globally), now i am using the same type in another package.Simply i am calling the first package and try to store the value in Type and use the same type in second package.
    But i am not able get the value
    Type declaration
    Declared in package Spec
    TYPE t_aa_derive_tbl_type IS TABLE OF xxxx%ROWTYPE;
       t_aa_derive t_aa_derive_tbl_type;
    Package 1
    Package1. PROCEDURE name(
    some parameters);
    is
    Cursor
    c1 is Select * from dual;
    begin
          OPEN c_aa_derive;
            FETCH c_aa_derive
            BULK COLLECT INTO t_aa_derive;
            CLOSE c_aa_derive;
         END get_aa_derive;
    In My second package
    I am calling
    Package1. PROCEDURE name(
    some parameters);
    and then i am trying to
    for i in 1 .. package1.t_aa_derive.COUNT
      LOOP
    end loop;
    I am not able entered the loop for some reason.
    Could some one guide me if anything i missed.
    Cheers,
    San

    I have a create a type in one package spec(Globally), now i am using the same type in another package.Simply i am calling the first package and try to store the value in Type and use the same type in second package.
    Why?
    1. Why aren't you just using SQL to do the work?
    2. Why don't you just open a CURSOR and pass that instead?
    BULK COLLECT INTO t_aa_derive; 
    3. Why aren't you using a LIMIT clause? Are you sure that only a very small number of rows will be queried?
    4. Why aren't you using a PIPELINED function instead of passing a collection?
    Using collections with potentially unlimited numbers of rows is not scalable. Also, using collections can be more difficult for 'data consumers' to work with than if you just use a CURSOR or PIPELINED function.
    Make sure you are using the proper architecture so that your code is both modular, scalable and easy to use.

  • Needing to convert a local "numeric" value to a string type using the expression browser.

    I am trying to convert a "numeric" local value to a string through the expression browser in order to supply a string arguement.  I am currently looking through the expression browser options, but I can not find any type of Number "ToString()" function.
    Solved!
    Go to Solution.

    Hi,
    Str() function
    ie
    locals.tostring = Str(locals.dec_value)
    Regards
    Ray Farmer

Maybe you are looking for

  • Mail no longer works after 10.5.1 upgrade

    Mail didn't really work as well after my Leopard upgrade, but not horrible. Now that the 10.5.1 upgrade has been installed, it doesn't work at all. I get the error "Some actions taken while the account "XXXX" was offline could not be completed online

  • Function Module for incoming payments

    Hi All, I'm currently working on integrating the IVR system with SAP ECC 6.0 - IS-U module. I would like to know if there is any function module or BAPI which I can use to receive the payment information and the credit card information to update the

  • Looking for alternate method for RFC adapter with BAPI

    Hello Friends Right now I have a scenario as follows An External   ==>  SOAP        ==>  XI    ==>   RFC          ==>  SAP TABLE Application   I have an external application that is sending some DATA to XI via SOAP adapter and in turn XI using a ZBAP

  • TABLE function not working in Dreamweaver

    Dreamweaver MX on Vista. My table function has simply stopped working or existing in my program. Everything else still works properly. When I change Table view it does not matter. When I press the table tab or icon, absolutely nothing happens and no

  • Login link does not display on website

    When I visit www.history.com the FULL ACCESS video login link does not appear at the top of the home page. History.com support says this is because Shockwave flash is not working correctly. I am using Firefox 35 on a Win7 computer. The Shockwave flas