Sprite class problem

Gives an error.
See the code provided herewith.
JST want to draw this sprite and animate.
Thank you very much

You need to add it to the displayList and do that she should be wrapped in a UIComponent:

Tags: Flex

Similar Questions

  • Analog Sprite class

    Hello world.

    In MIDlets there is a Sprite class, which allows to draw a sequence of images (and other useful things).

    At a BB API something like that? I looked through the documentation, but found nothing .

    Can I use a MIDlet 'classic' class Sprite to draw pictures on the screen of BB (in object method)?

    Thank you

    magfed

    Thank you all.

    I made my own Sprite class. But anyway thank you all for your messages.

    class CMySprite {    private Bitmap m_Image;    private int m_FrameWidth;    private int m_FrameHeight;    private int m_XCenter = 0;    private int m_YCenter = 0;    private int m_CurrentFrame = 0;    private int m_FramesCount;        /**     * Constructor     *      * @param Bitmap - bitmap is the row sequence of frames     * @param int - with of each frame     */    CMySprite(Bitmap image, int frameWidth){        m_FrameWidth = frameWidth;        m_FrameHeight = image.getHeight();        m_Image = image;        m_FramesCount = image.getWidth() / frameWidth;    }        /**     * Set coordinates of the center of frame to be painting on the screen     *      * @param int - x coordinate of center point if the frame at the screen     * @param int - y coordinate of center point if the frame at the screen     */    public void setCenterFramePosition(int xCenter, int yCenter){        m_XCenter = xCenter;        m_YCenter = yCenter;    }        /**     * Set zero-based number of frame to be painting on the screen     *      * @param int - zero-based number of frame to be painting on the screen     */    public void setFrame(int frameNum){        m_CurrentFrame = (frameNum >= m_FramesCount) ? 0 : frameNum;    }        /**     * Switch to the next frame of the frame sequence. If the     * next frame greater than frames count, the next frame is the      * first frame.     */    public void nextFrame(){        if((++m_CurrentFrame) >= m_FramesCount)            m_CurrentFrame = 0;    }        /**     * Switch to the previous frame of the frame sequence. If the     * previous frame less than 0, the previous frame is the      * last frame.     */    public void prevFrame(){        if((--m_CurrentFrame) < 0)            m_CurrentFrame = 0;    }        /**     * Paints the sprite frame     *      * @param net.rim.device.api.ui.Graphics - graphic context.     */    public void paint(Graphics g){        g.drawBitmap(m_XCenter - m_FrameWidth / 2,                     m_YCenter - m_FrameWidth / 2,                     m_FrameWidth,                     m_FrameHeight,                     m_Image,                     m_FrameWidth*m_CurrentFrame,                     0);    }};
    

    That, to the paint of the display method:

    Bitmap myFrames = Bitmap.getBitmapResource("img/frames.png");CMySprite tmpSprite = new CMySprite(myFrames, 100, 100);tmpSprite.setFrame(0);tmpSprite.setCenterFramePosition(50, 50);tmpSprite.paint(g);tmpSprite.nextFrame();tmpSprite.setCenterFramePosition(50, 150);tmpSprite.paint(g);tmpSprite.nextFrame();tmpSprite.setCenterFramePosition(50, 250);tmpSprite.paint(g);
    
  • Confused about the extension of the Sprite class

    Howdy-

    I learn programming with object oriented ActionScript and am confused about the class Sprite and OO in general.

    My understanding is that the Sprite class allows you to group a set of objects that you can manipulate all the objects at the same time.

    I explored the Open Flash Chart code and note that the main class extends the Sprite class:

    Base/public class extends Sprite {}

    What this lets you do?

    Also, on a related note, how to draw, say, a line once I extended?

    Without extend Sprite I could write:

    var graphContainer:Sprite = new Sprite();

    var newLine:Graphics = graphContainer.graphics;

    ...

    And it works very well. Once I have extend the Sprite class, I'm lost. How can I modify this code so that it still draws a line? I tried:

    var newLine:Graphics = this.graphics;

    My understanding is that since I extend the Sprite class, I should still be able to call its method chart (or property? I have no idea). But, he screams at me, saying "1046: Type was not found or is not a constant of compilation: graphs.»

    A number of things.

    First of all, I would not use this approach in your table constructor. Setting the width and height only makes sense if you adjust the width and height of the existing content, and the table (Sprite) does not at this time here. If you want to give the table a 'size', you could do it like this:

    public function Chart (width: Number, height: Number) {}
    This.Width = width;
    This.Height = height;
    put in a background invisible to this size:
    this.graphics.beginFill (0,0);
    this.graphics.drawRect (0,0,width,height);
    }

    There are other ways, including putting in a form or a Sprite of child as a child for the background so that clear will not erase the background of the chart. This way you could have properties for the background in your table class and update the background as a child DisplayObject instance... a few ideas to think to...

    Then, after that, your chart should be functional...

    Then back in your scenario, you could do this:

    import graphics. Table;

    Stop()

    var myNewChart:Chart = new Chart (300,200)
    myNewChart.render ();
    addChild (myNewChart)

  • integer to another class problem, please help :D

    I tried a day now to solve this problem and I'm stumped. Could someone please point out what's wrong with the following code? I'm moving an integer of a class to another.

    ButtonField nextBut = new ButtonField ("Next", Field.FIELD_HCENTER) {}
    protected boolean trackwheelClick (int status, int time) {}
    If (firstChoice == 0) {}
    Dialog.Alert ("you must choose!");
    }
    else {}
    int firstChoices = firstChoice;
    UiApplication.getUiApplication () .popScreen (Ui.getUiEngine () .getActiveScreen ());
    UiApplication.getUiApplication () .pushScreen (new newGame3 (firstChoices));
                       
    }
    Returns true;        }
    public int getPreferredWidth() {}
    Return Display.getWidth ();
    }
    Protected Sub paint (Graphics Graphics) {}
    graph.setBackgroundColor (Color.BLUE);
    graph.fillRect (0, 0, getWidth(), getHeight());
    graph.setColor (Color.RED);
    Graph.Clear ();
    Super.Paint (Graph);
    }
    };
           
    nextBut.setFont (Font.getDefault () .derive (Font.BOLD));
           
    FieldChangeListener lnextBut = new FieldChangeListener() {}
    ' Public Sub fieldChanged (field field, int context) {}
    }
    }
    ;
    nextBut.setChangeListener (lnextBut);
    VMAN. Add (nextBut);

    the other class

    public class newGame3 extends form {}
       
    public newGame3 (int firstChoices) {}
    LabelField t1 = new LabelField ("new game 3" + firstChoices);
    Add (T1);
    }
    }

    I think Rexdoug meant firstChoice.

    Give a look at this example. You should get whats wrong on your code.

    public class TestScreen extends MainScreen
    {
        int firstChoice = 5;
        public TestScreen()
        {
            ButtonField nextBut = new ButtonField(" Next ", Field.FIELD_HCENTER | ButtonField.CONSUME_CLICK);
            FieldChangeListener lnextBut = new FieldChangeListener()
            {
                public void fieldChanged(Field field, int context)
                {
                    UiApplication.getUiApplication().popScreen(Ui.getUiEngine().getActiveScreen());
                    UiApplication.getUiApplication().pushScreen(new NewGame3(firstChoice));
                }
            };
            nextBut.setChangeListener(lnextBut);
            this.add(nextBut);
        }
    } 
    
    class NewGame3 extends MainScreen
        {
            public NewGame3(int firstChoice)
            {
                LabelField t1 = new LabelField(" New Game 3 "+ firstChoice);
                this.add(t1);
            }
        }
    

    Concerning

    Bika

  • Class problem

    I try to use a code (it's an API for box.net) who wrote before Flash 5 (I use CS5.5) and get the following compilation error:

    com\Box\Communication.as, line 1 5006: ActionScript file cannot have several definitions visible from the outside:

    Communication.As (irrelevant deleted code) is:

    com of the packaging. Box {}

    import flash.events.Event

    import flash.events.DataEvent

    import flash.events.EventDispatcher

    import flash.net.URLLoader;

    import flash.net.URLRequest;

    import flash.utils.setInterval;

    import flash.utils.clearInterval;

    import com. Box.MD5;

    import com. Box.Folder;

    Communication/public class extends EventDispatcher {}

    public void Communication() {}

    private void GetTicket (): void {}

    }

    private void GetTicketResponse(e:Event):void {}

    }

    private void GetToken() {}

    }

    private void GetTokenResponse(e:Event):void {}

    }

    public function Login (): void {}

    }

    public void getAccountTree(in_folderId:String,_in_onelevel:Boolean):void {}

    }

    private void getAccountTreeResponse(e:Event):void {}

    }

    public void Download(id:String):void {}

    }

    }

    SerializableAttribute public class FolderLoadEvent extends Event {}

    public var: file;

    public void FolderLoadEvent(_Folder:Folder) {}

    Super ("FolderLoad");

    folder = _Folder;

    }

    }

    }

    Code Red is the source of the problem. FolderLoad is dealt with elsewhere. I'm a complete newbie when it comes to solutions or suggestions to work around classes, greatly appreciated.

    I believe that the error is to tell you that you can have two definitions of 'public' class (visible/accessible from the outside) in a single class file.  Try to make a separate .as file.

  • game focusing on the sprite class

    Hi, I'm tryin to set global focus to a specific class that already exists on the scene, after that I deleted a contextual dialog box on the screen. I pass the name of the class that was on the scene before the pop-up dialog box is displayed in the string to the popup class.

    If public void PopupMenu(pClass:String)

    Once I removed the pop-up dialog box, I want to restore developed in the previous class, so it can accept events key again.

    How would I set the focus to an instance of an object on the stage. Currently, I have something like this:

    Main.mainStage.focus = (InteractiveObject) (getDefinitionByName (prevClass));

    but he returned this error: TypeError: Error #1034: Type coercion failed: cannot convert com.cox::IdleScreen$ in flash.display.InteractiveObject.

    My IdleScreen class extends sprite, which is definitely on a higher level than InteractiveObject in the diagram to display objects. How can I set focus to this class on the stage?

    I know it can be focused because I can do Main.mainStage.focus = this inside of the class and it works...

    Mount the DisplayObject to InteractiveObject.

    Main.mainStage.focus = Main.mainStage.getChildAt (2) as InteractiveObject;

  • Tween class problem

    well I can't really see what's wrong. appears to be an error in the flash, but maybe theres a rule im does not suite or something...
    my code:

    (main timeline)

    Import mx.transitions.Tween;
    Import mx.transitions.easing. *;

    mcNum = 1;
    mcStart = 880;
    mcFinish = - 30;
    owner of the image
    var inter = setInterval (transition, 500);

    transition() {} function
    mcName = 'line' + mcNum;
    trace (mcName);
    mcNum ++;
    mcStart = mcStart + 40;
    mcFinish = mcFinish + 40;
    var twMoveClip:Tween = new Tween (mcName, Strong.easeOut, mcStart, mcFinish, 2, true);

    If {(mcNum > 5)
    clearInterval (inter);
    }
    }
    Stop();

    the problem is that nothing moves. the track of "mcName" comes up with "line1, line2... line 5" as it should. However if I change mcName of > 'line' + mcNum < to just > line1 <. He calls line1 and makes it move. It is not not my expected results because none of the others move... ive been at this for hours. and it seems that the tween class will not work when calling on a variable that was added 2 other variables or variable and a number.

    Please help someone :(

    Try this:

  • Java class problem

    upload.png

    Version of forms: Forms [32 bit] Version 6.0.8.25.2 (Production)

    the JDK version:

    Java version "1.7.0_51".

    Java (TM) SE Runtime Environment (build 1.7.0_51 - b13)

    The Client Java VM (build 24.51 - b03, mixed mode, sharing)

    Well, I see several things.

    1 forms 6, which has moreover been desupported for many years, is based on Java version 1.2/1.3, so try to use Java 7 with it, will probably cause problems.

    2. as indicated in the error, 'java' is a reserved package name.  So, you might have to rename your package name of 'java' to something like 'myjava.

    For our benefit, can you help me understand why you use 6 shapes and not a newer version as 11.1.2.2?

  • Controller extension class problem

    Hello

    I have a custom controller class that extends the default class in e-business suite. Before you create new data on the page, I'm trying to do some field validations in the form process request method. However, when I clicked on create a button, system first add new data to the database and then trying to run my controls. Therefore, my controls become meaningless.
    Here is an example;

    public class xxgmSuppCrtCO extends SuppCrtCO {}


    {} public processRequest Sub (pageContext OAPageContext, OAWebBean webBean)

    super.processRequest (pageContext, webBean);
    pageContext.putDialogMessage (new OAException ("s5 :"));

    }

    public void processFormRequest (pageContext, OAPageContext,
    {OAWebBean webBean)
    super.processFormRequest (pageContext, webBean);
    If (pageContext.getParameter ("applyBtn")! = null) {}
    a validation here
    I throw an expection when the condition is met
    throw new OAException (Err2, OAException.ERROR);
    }
    }
    }

    super.processFormRequest (pageContext, webBean);

    This will call methods processFormRequest seeded. that is when you click on any event seeded operations will be first made, then your code if it is necessary.

    So call it "super.processFormRequest (pageContext, webBean);" after your code.

    for example

    public void processFormRequest(OAPageContext pageContext,
    OAWebBean webBean) {
    if (pageContext.getParameter("applyBtn") != null) {
    //your code
    super.processFormRequest(pageContext, webBean);
    }
    else
    {
    super.processFormRequest(pageContext, webBean); // this is required because for other events(apart from apply button) seeded methods should be called
    }
    
    }
    

    -Anand

  • Missing classes (problem FB4)

    I installed FB 4 and created a project that uses the SDK version 3.5

    But I can't compile my code because the classes in the flash.display package are missing:

    where.PNG

    WHRE was therefore the GraphicsPath and other classes go?

    3.5 SDK uses default 9.0.124 player. To change this to 10:

    (1) project properties

    (2) compile flex

    (3) under 'Options of Adobe Flash Player', select use a specific version and enter 10.0.0

    (4) OK

    GraphicsPath classes will be displayed in the code hints and compile fine.

    Jason San Jose

    Software engineer, Flash Builder

  • custom with LoadVars class problem

    Hi all

    What I am trying to create is a 'ping on the server' class, a local Flash application can check if a variable remote server is online.
    As you'll see in the example, I created a ping() function, that executes the pingServer:LoadVars.
    The strange thing for me, is that I can put a variable in a class of a function within this category, but I can't set a variable of pingServer.onLoad located in this feature...
    (It is actually the first time I'm trying to create a class..)

    Any suggestions?

    Inside the callback, class managers ythe members out of reach. There are several ways to resolve this. We use a local variable that maintains a reference to the current object.
    function ping (): Void {}
    var thisObj:ping_server =;

    and to the members of the class:
    thisObj.serverstatus = 'pingServer_lv.onLoad = online;

  • Sprite under problem still clickable sprite?

    >

    Hi there, I wonder if someone can help me, I thought I was getting the hang of things and was well on course when I realized that some sprites I have should not be clickable when behind other sprites are indeed clickable. Even if you don't see them they work even when their area is clicked. ???

    I even went up to open an empty film and creating sprites (squares) 2, place a script on the background sprite that increments a variable and then covering it with another place, when I click on the top square the script on the bottom 1 is still running, I'm not sure if this is normal or I may have something set wrong in the Settings Manager?

    Any help and advice on this issue would be much appreciated... Thank you...

    Paul

    In order to disable clicking on sprites in a lower channel, place a
    behavior of 'empty' on the highest sprite:
    --
    on mouseUp me
    nothing
    end

  • Tween class problems

    IV written an interpolation function a mc that works very well. the problem is that I want to use the same function on 30 different mc so its pointless to me re-writing of it for each of them.

    This version works very well and the trace is showing which is set the page variable:
    function navOut(e:MouseEvent):void {}
    var page: String = e.target.name;
    track (page);
    var myTween:Tween = new Tween (.buttonThumb button, "y", Regular.easeOut,-25, 0, 0.5, true);
    }


    but I need to replace the underlined key with the page variable so I can use it on the MC. and of course does not page.buttonThumb .

    any help is very appreciated!

    and you will probably need to cast e.currentTarget as a movieclip:

    var page = MovieClip (e.currentTarget) .buttonThumb;

  • Class problem after replaced by the new Java class

    Hello

    I made a java class to a ColdFusion 7.02 Server (linux red hat 3.2)
    At the beginning, that it worked perfectly.
    Then I made a new version with some extra methods, succeeded him, restarted the service and empty the cache. Still, he finds none of the new methods, but it is not the 'old'. What can I do?

    Is there a way you can check the version of the file on the server .class? Human error perhaps?

    How you access to and use of the class? Care to post some code snippets?

  • The label on the top of the Sprite event management

    Hi everyone, it's more of a general question of Actionscript, but Google does offer all the answers.

    So I made a custom component, element that extends the Sprite class. I draw things on the graphics in this class and then I add a Label to display text.

    In another class, where I create instances of the previous class, I add an EventListener for MouseEvent.Click.  In this function, there is this line:

    selectedElement = Element(event.target);
    

    In short, I want the variable selectedElement to contain the element on which click it. But I ran into problems, event.target is not always an instance of my class. If I click where the label is, event.target is a Label.

    How can I organize if click anywhere on my element, in particular on the label, it's the element of class that dispatches an event and not on its label. I think I need to intercept events of labels in some way, but no idea how to do this.

    Thank you in advance.

    Too bad, in the event class stopPropagation method has been what I was looking for.

Maybe you are looking for