Positioning TextFields in Sprites?

Hello
First i will explain what i want to do,then explain the problem i am having.
I am trying to create my own dynamic select list,that does more than the built in Flash components.
all my list info is pulled from my database, and returned to flash swf using AMF services as a Object
I want my list it to include face images at 50px by 50px and the persons full name  and other useful bits of information i can fit in each list item, which make scrolling a large list of people more manageable more interesting and less of a chore, than just scrolling a list of names in plain text.
Problem
only the first top item is positioned the way i want, the rest of the textfields are off or out side there parent objects, how do i force them all to stay in there parent objects? any help would be great...
Example : i have a screen shot and code of the problem.
public function setList(userlist:Object):void
                              var images:Array = new Array("http://localhost/faceIcon2/img1.jpg",
                                                                                                     "http://localhost/faceIcon2/img2.jpg",
                                                                                                     "http://localhost/faceIcon2/img3.jpg",
                                                                                                     "http://localhost/faceIcon2/img4.jpg",
                                                                                                     "http://localhost/faceIcon2/img5.jpg",
                                                                                                     "http://localhost/faceIcon2/img6.jpg",
                                                                                                     "http://localhost/faceIcon2/img7.jpg");
                              var personNames:Array = new Array("Henry William",
                                                                                                                "Ava Sambora",
                                                                                                                "Amy Lou",
                                                                                                                "Freddie Benson",
                                                                                                                "Richard Schiff",
                                                                                                                "Laurence Fishburne",
                                                                                                                "Joseph Cranford");
                              var countY = setTextFieldYPos(images.length);
                              for(var i:Number=0; i < images.length; i++)
                                        /* Set sprite and image elements */
                                        var listItems:Sprite = new Sprite();
                                        listItems.graphics.lineStyle(1,textColorRGB.grey);
                                        listItems.graphics.drawRect(0,0,600,50);
                                        listItems.name = "item_" + i;
                                        listItems.y = i*50;
                                        addChild(listItems);
                                        var urls:URLRequest = new URLRequest(images[i]);
                                        var imgLoader:Loader = new Loader();
                                        imgLoader.load(urls);
                                        listItems.addChild(imgLoader);
                                        /* Set username text fields */
                                        var myFormat:TextFormat = new TextFormat();
                                        myFormat.font = robotoLight.fontName;
                                        myFormat.size = 14;
                                        myFormat.color = textColorRGB.grey;
                                        myFormat.blockIndent = 55;
                                        var myTextField:TextField = new TextField();
                                        listItems.addChild(myTextField);
                                        myTextField.autoSize = TextFieldAutoSize.LEFT;
                                        myTextField.y = countY[i];
                                        //myTextField.height = 50;
                                        myTextField.border = true;
                                        //myTextField.background = true;
                                        //myTextField.backgroundColor = 0xeeaaaa;
                                        myTextField.defaultTextFormat = myFormat;
                                        myTextField.embedFonts = true;
                                        myTextField.antiAliasType = AntiAliasType.ADVANCED;
                                        //myTextField.text = userlist[i]["name"];
                                        myTextField.text = personNames[i];
public function setTextFieldYPos(thisLength:int):Array
var res:int = 0;
var counts:Array = new Array();
for(var i:int=0; i < thisLength; i++)
res +=15;
counts.push(res);
return counts;

again, use:
   var myTextField:TextField = new TextField();
                                        listItems.addChild(myTextField);
                                        myTextField.autoSize = TextFieldAutoSize.LEFT;
                                        //myTextField.height = 50;
                                        myTextField.border = true;
                                        //myTextField.background = true;
                                        //myTextField.backgroundColor = 0xeeaaaa;
                                        myTextField.defaultTextFormat = myFormat;
                                        myTextField.embedFonts = true;
                                        myTextField.antiAliasType = AntiAliasType.ADVANCED;
                                        //myTextField.text = userlist[i]["name"];
                                        myTextField.text = personNames[i];
   myTextField.y =50-myTextField.height;
mTextField.x=50;

Similar Messages

  • How can I check the locV of a sprite on every frame?

    I'd like to know how can I tell Director, in Lingo, to check
    the position of a sprite in every frame in order to use that
    position to set the value of a global variable. I want to avoid
    having an on enterFrame script on every frame as I will need to do
    this with various sprites all the time. I tried an on enterFrame
    movie script but when I check the value of the variable with the
    message window it's always 1 (I initialized the variable with that
    value), regardless of wether the condition is being met on that
    specific frame or not. I also placed an on enterFrame script on the
    sprite and it would not work either. According to the
    documentation, on beginSprite only works if the sprite was not on
    the stage previous, and this sprite will always be on the stage,
    just in a different locV when I need it to be.
    Any suggestions please?

    Here's how you could create a single list containing all the
    locV values that you want:
    global gLocVList
    on enterFrame
    if ilk(gLocVList) <> #propList then
    gLocVList = [:]
    end if
    vSpriteList = [2, 3, 5, 7, 11, 13, 17, 19] -- or other
    spriteNums
    repeat with vSpriteNum in vSpriteList
    vLocV = sprite(vSpriteNum).locV
    gLocVList.setaProp(vSpriteNum, vLocV)
    end repeat
    end enterFrame
    However, it seems rather pointless to do this, as it checks
    the locV of every sprite on every frame whether you need that
    information or not. Since the sprite references are globally
    available anyway, you would use fewer CPU cycles if you just asked
    for...
    sprite(x).locV
    ... (where x is a sprite name or spriteNum, or a variable
    holding such information ) whenever you actually require the value
    of the locV.

  • Subpixel drawing of slow-moving sprites

    Hi.
    I've been working on an iOS game with Flash for a while. Now I'm stuck with a display problem.
    My game objects move very slowly and steadily and I notice pretty bad jittering/stuttering. This is GPU mode in Air 2.7, CPU mode is too slow. The cause of the jittering seems to be that Air moves my sprites (based on PNGs) only in full- and half-pixel steps, regardless of whether cacheAsBitmap/-Matrix are enabled. Is this an optimization by Adobe or can I get rid of this somehow? It's really annoying.
    Thank you!

    Thank you for your answers.
    I'm currently only developing a low-res (iPhone 3GS) prototype, so I can't say how it will look on iPhone 4.
    No caching at all or cacheAsBitmap + -Matrix both look the same: the very discernible half-pixel stepping effect.
    Just cacheAsBitmap looks much worse as it produces full-pixel stepping.
    I also tried using a larger Matrix and larger, down-scaled PNGs, but that didn't help either, unfortunately.
    Positions of the sprites are all Numbers with no rounding. On the desktop in Flash player (with no caching), this produces beautiful fluid motions, but on the iPhone, it still snaps to half-pixels. That's why I was wondering if that was an optimization in Air.

  • Resizing a movie in a window and it's sprites

    I'm working on a kind-of slide show project. The 'show' runs
    in a resizable window. The projector (created with Director v10)
    has a lot of sprites (>60). Most of them should not be resized
    and should stay at a fixed position (e.g. at the right margin),
    other sprites should be resized (e.g. the 'slide'). It is more or
    less as the Director authoring environment window where windows are
    docked.
    My question is if someone has a concept on how to deal with
    this. I appreciate any help.

    "ArmanIc" <[email protected]> wrote in
    message
    news:fjuiml$mj1$[email protected]..
    > I'm working on a kind-of slide show project. The 'show'
    runs in a
    > resizable
    > window. The projector (created with Director v10) has a
    lot of
    > sprites (>60).
    > Most of them should not be resized and should stay at a
    fixed
    > position (e.g. at
    > the right margin), other sprites should be resized (e.g.
    the
    > 'slide'). It is
    > more or less as the Director authoring environment
    window where
    > windows are
    > docked.
    >
    > My question is if someone has a concept on how to deal
    with this. I
    > appreciate
    > any help.
    Hi,
    I have a set of behaviours for that.
    They make a sprite keep its distance to the edge of the
    stage, and you
    can choose which edge (Left, Right, Top, Bottom). And then
    there is
    one other that sets a sprites position relative to the
    centre.
    I wrote them years ago for Dir 8, and are still in Lingo not
    Javascript.
    I could post them here, but they are not difficult to write,
    and
    besides, what is the fun? ;)
    Basically it goes like this:
    - store the starting position of the sprite or the offset to
    its
    reference (left edge, right edge...etc) on startmovie or
    beginSprite
    - detect the resizing of the window and send all sprites a
    message
    (sendAllSprites()).
    - in the sprites' handler, calculate the new position of the
    sprite
    and put it there.
    If you want to have them anyway, send me an email info
    looping nl.
    Good luck,
    Richard.

  • How do i move a sprite across the stage using the arrow keys on my keyboard?

    I'm a high school student and i love director. I recently have become interested in game development, and i am completely lost in how to move a sprite across the stage. I have tried toying around and google hasn't been very helpful. An example of something i found is
    on keyUp
      if (_key.keyCode = 124) then sprite(4).locH = sprite(2).locH -25
      if (_key.keyCode = 123) then sprite(4).locH = sprite(2).locH -25
    end keyUp
    I don't understand why this wont work.
    HELP

    This code moves sprite 2 to a position relative to sprite 4. If sprite 4 is not moving, then sprite 2 will always move to the same position, so it will not appear to move at all.
    Perhaps this code makes more sense:
    on keyUp
      if (_key.keyCode = 124) then sprite(2).locH = sprite(2).locH +25
      if (_key.keyCode = 123) then sprite(2).locH = sprite(2).locH -25
    end keyUp

  • IR - 9.2 - how to format a number to a textfield in dashboard

    Hello,
    i am going to develop an individual Dashboard with free positionung textfields, almost all works, but how can i formatting the numbers?
    here the script:
    var Ausfall=ActiveDocument.Sections["Ergebnisse"].Columns["Ausfall"].GetCell(1);
    var AB=ActiveDocument.Sections["Ergebnisse"].Columns["A B"].GetCell(1);
    var ABprozw=AB/Ausfall;
    AnzeigeABProz.Text=ABprozw; /* is a free positioning textfield in dashboard */
    in the dashboard ist the value shown as
    0.7793775542282301
    but how can i get a number format as:
    0,78
    or
    78,9%
    are there any convert/formating function (to dashboard-textfields) in IR ?
    mfg
    Jens Rohloff

    If you want the Percent signt o show up then you will need to treat the number as a string.
    Another option
    var ABprozw=AB/Ausfall * 100;
    var ABprozw = Math.round(ABprozw)
    var ABprozw = ABprozw/100
    This will give you tne 0.78
    Wayne Van Sluys
    TopDown Consulting

  • Loading images sprite

    when I pass a sprite variable to a class to place images in it the spite doesnt display all the image as it should. It is unstable.
    [CODE]
    canvas1=new Sprite();
    addChild(canvas1);
    mybackground=new ClassBackGroundtile(canvas1);
    canvas1.addChild(mybackground);
    classbackgroundTile
    private var canvas1:Sprite;
    public function ClassBackGroundTile(ccanvas1:Sprite...) {
    canvas1=ccanvas1;
    //addChild(img1);
    canvas1.addChild(img1); //this causes the problem
    [/CODE]
    the problem

    jag,
    You're probably going to have to post more of your code to get any help.  There's nothing specificly wrong with what you are doing there.  But, when objects I add to the stage don't seem to be appearing here are some things to check for:
    The x,y position of the sprite - Was it added, but just off of the stage somewhere.
    Are you setting the visibility property of these sprites to false anywhere.
    Are newer sprites covering up older sprites? Again - check x,y, coords.
    To see if your objects are really being added- after adding them, print out the PARENT_SPRITE.numChildren property and see if it matches how many children should have been added.
    Write back with more details about the problem and someone will help you out.

  • I want to write text in graphics sprite

    i want to write text in this sprite
    i use thes method but not work when i add textfield to sprite the rect become very small
    function drawRect():Sprite
                var redRect:Sprite = new Sprite();
                redRect.graphics.beginFill(0xff0000);    // red
                redRect.graphics.drawRect(0,0,30, 30);
                redRect.graphics.endFill();
                var number:TextField =new TextField();
                number.text = "1";
                number.x= 15;
                number.y= 15;
                redRect.addChild(number);
                return redRect;

    Hi:
    What you wanted is to make a Red Sprite contains a TextField in the inline graphic element, right?
    I think you needed to handle the source Sprite's width and height by yourself. The width and height parameter in the EditManager's insertInlineGraphic function is to set the width and height of the Inline Graphic Element which is the container of your source sprite. The following codes work  fine on my envirnoment. Hope they are helpful:
    package
    import flash.display.Sprite;
    import flash.text.TextField;
    import flashx.textLayout.container.ContainerController;
    import flashx.textLayout.edit.EditManager;
    import flashx.textLayout.conversion.TextConverter;
    import flashx.textLayout.edit.EditManager;
    import flashx.textLayout.elements.TextFlow;
    import flashx.undo.UndoManager;
    public class TestInlineGraphic extends Sprite
    private var redRect:Sprite=null;
    public function TestInlineGraphic()
    var textFlow:TextFlow = TextConverter.importToFlow( "How now brown cow.", TextConverter.PLAIN_TEXT_FORMAT );
    textFlow.flowComposer.addController( new ContainerController( this ));
    var editManager:EditManager = new EditManager( new UndoManager() );
    textFlow.interactionManager = editManager;
    textFlow.flowComposer.updateAllControllers();
    editManager.selectRange( 3,  3);
    editManager.insertInlineGraphic( drawRect(), 20, 20, "none" );
    function drawRect():Sprite
    redRect  = new Sprite ();
    redRect.graphics.beginFill(0xff0000);    // red
    redRect.graphics.drawRect(0,0,30, 30);
    redRect.graphics.endFill();
    var number:TextField =new TextField();
    number.text = "1";
    number.width=20;
    number.height=20;
    redRect.addChild(number);
    return redRect;

  • Character (sprite) animation

    What is the best way to handle character animation on the iPhone.
    Is using the UIImageView method the best to handle simple sprite animation using a number of PNG's.
    Is there a limit to the number of PNG images you should use?
    Also what is the best way to handle simple effects like zoom and pan, on a block of animation?
    Can a block of animation follow a curved path. e.g. a character walk cycle moving over a hill.
    I appreciate any response. I have a background in 2D animation and need some direction to how best to create animations on the iPhone and also what limitations I am up against.
    Thanks, Steve

    Okay, that is something different. I misunderstood what you meant by 'animation'.
    Moving 2D sprites in a game is done by creating a virtual model of the game world in the code that represents game objects by their positions in 2D space and their "movement" as a numerical velocity vector that specifies the number of pixels that the object should move per unit time. Time is simulated by updating the objects' position and redrawing the screen at some fixed time interval (the frame rate) determined by a timer.
    Here is a simple ball animation sample that assumes you have a 48x48 pixel image named ball.png. It creates a UIView subclass that should be loaded by the AppDelegate class.
    The header:
    #import <UIKit/UIKit.h>
    typedef struct
    CGFloat x;
    CGFloat y;
    } Vector2D;
    typedef struct
    Vector2D position;
    Vector2D velocity;
    } Sprite;
    @interface GameWorld : UIView {
    Sprite ball;
    UIImageView *ballImage;
    @end
    and the implementation:
    #import "GameWorld.h"
    #define kDotRadius 24
    @implementation GameWorld
    - (id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
    [UIApplication sharedApplication].statusBarHidden = YES;
    ball.position.x = 200.0;
    ball.position.y = 300.0;
    ball.velocity.x = 3.0;
    ball.velocity.y = -3.0;
    ballImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ball.png"]];
    [self addSubview:ballImage];
    [NSTimer scheduledTimerWithTimeInterval:(1.0 /30.0) target:self selector:@selector(update) userInfo:nil repeats:YES];
    return self;
    -(void)update {
    if(ball.position.x - kDotRadius <= self.bounds.origin.x || ball.position.x + kDotRadius >= self.bounds.size.width)
    ball.velocity.x *= -1.0; //negate to reverse direction
    if(ball.position.y -kDotRadius <= self.bounds.origin.y || ball.position.y + kDotRadius >= self.bounds.size.height)
    ball.velocity.y *= -1.0;
    //commit to changes
    ball.position.x += ball.velocity.x;
    ball.position.y += ball.velocity.y;
    [self setNeedsDisplay];//refresh the view
    - (void)drawRect:(CGRect)rect {
    ballImage.center = CGPointMake(ball.position.x, ball.position.y);
    - (void)dealloc {
    [super dealloc];
    @end
    So it is the UIImageView's center property that is used to create the movement of the image view across the screen. This could be done directly, but the use of C structs (Vector2D and Sprite) make the code easier to read. The center property is updated only at the moment when the screen redraw occurs.

  • Sprite not seen by Director

    Hey guys,
    I have a massive problem that I've been struggling over for days now.  I have a green rectangle that a sprite can travel over.  I have code set up to tell me what colour the next Pixel along is, but for some reason the sprite is seeing the edge of the rectangle sooner than it should be seen.
    I'm not sure whether I have explained that very well.
    The file is here, you will see what I mean.
    My problem is on the "Level 1" Marker.
    Please can somebody help, I'm desperate for an answer on this as my deadline is near.

    Try the following alterations to the script attached to your moveable character:
    -- properties used in this script:
    -- pSprite - the sprite reference
    -- pSpeed - the speed the sprite should move
    -- myLocH - the current horizontal position of the sprite
    -- myLocV - the current vertical position of the sprite
    property spriteNum
    property my
    property myReferenceImage
    property myReferenceImageOffset
    property myWidthOffset
    property myHeightOffset
    property pSprite, pSpeed, myLocH, myLocV
    on beginSprite me
      -- initialise sprite properties
      my = sprite(spriteNum)
      myReferenceImage = member("Level_1_Maze").image
      -- reference bitmap is offset from (0, 0) by (9, 12)
      myReferenceImageOffset = point(9, 12)
      -- account for l, t, r, b colliding with "walls"
      -- regPoint is centered, so:
      myWidthOffset  = my.width/2
      myHeightOffset = my.height/2
      -- controls the speed that the sprite moves at
      pSpeed = 10
    end
    on keyPress me, aDirection
      -- actions THIS sprite should take on key press
      -- store current location
      myLocH = my.locH
      myLocV = my.locV
      -- find which direction to move
      case aDirection of
        #left:  me.goLeft()
        #right: me.goRight()
        #up:    me.goUp()
        #down:  me.goDown()
      end case
    end
    -- individual custom event handlers for movement
    on goLeft me
      -- swap the sprite for one based on the
      -- left film loop cast member
      my.member = member("left")
      -- move the sprite to the left if no hedge to the left of the cast member
      newlocH = myLocH - pSpeed
      iColor = myReferenceImage.getPixel(point(newlocH - myWidthOffset, myLocV) - myReferenceImageOffset, #integer)
      if iColor = -16720640 then
        --grass colour is legal so allow move
        my.locH = newLocH
      else
        put iColor
        beep
      end if
    end
    on goRight me
      my.member = member("right")
      newlocH = myLocH + pSpeed
      iColor = myReferenceImage.getPixel(point(newlocH + myWidthOffset, myLocV) - myReferenceImageOffset, #integer)
      if iColor = -16720640 then
        --grass colour is legal so allow move
        my.locH = newLocH
      else
        put iColor
        beep
      end if
    end
    on goUp me
      my.member = member("up")
      newLocV = myLocV - pSpeed
      --find out if newLoc is a legal space
      iColor = myReferenceImage.getPixel(point(myLocH, newLocV- myHeightOffset) - myReferenceImageOffset, #integer)
      if iColor = -16720640 then
        --grass colour is legal so allow move
        my.locV = newLocV
      else
        put iColor
        beep
      end if
    end
    on goDown me
      my.member = member("down")
      newLocV = myLocV + pSpeed
      --find out if newLoc is a legal space
      iColor = myReferenceImage.getPixel(point(myLocH, newLocV + myHeightOffset) - myReferenceImageOffset, #integer)
      if iColor = -16720640 then
        -- grass colour is legal so allow move
        my.locV = newLocV
      else
        put iColor
        beep
      end if
    end
    This could do with a degree more rationalisation/optimisation/consolidation yet. For example:
    -- properties used in this script:
    -- pSprite - the sprite reference
    -- pSpeed - the speed the sprite should move
    -- myLocH - the current horizontal position of the sprite
    -- myLocV - the current vertical position of the sprite
    property spriteNum
    property my
    property myReferenceImage
    property myReferenceImageOffset
    property myWidthOffset
    property myHeightOffset
    property pSprite, pSpeed, myLocH, myLocV
    on beginSprite me
      -- initialise sprite properties
      my = sprite(spriteNum)
      myReferenceImage = member("Level_1_Maze").image
      -- reference bitmap is offset from (0, 0) by (9, 12)
      myReferenceImageOffset = point(9, 12)
      -- account for l, t, r, b colliding with "walls"
      -- regPoint is centered, so:
      myWidthOffset  = my.width/2
      myHeightOffset = my.height/2
      -- controls the speed that the sprite moves at
      pSpeed = 10
    end
    on keyPress me, aDirection
      -- find which direction to move
      case aDirection of
        #left:
          tMember = member("left")
          tPoint  = my.loc - point(pSpeed + myWidthOffset, 0)
        #right:
          tMember = member("right")
          tPoint  = my.loc + point(pSpeed + myWidthOffset, 0)
        #up:
          tMember = member("up")
          tPoint  = my.loc - point(0, pSpeed + myHeightOffset)
        #down:
          tMember = member("down")
          tPoint  = my.loc + point(0, pSpeed + myHeightOffset)
      end case
      my.member = tMember
      iColor = myReferenceImage.getPixel(tPoint - myReferenceImageOffset, #integer)
      if iColor = -16720640 then
        --grass colour is legal so allow move
        my.loc = tPoint
      else
        put iColor
        beep
      end if
    end

  • Best way to move sprites around in the scene?

    What is the best way to move sprites around on the scene?
    So far I came up with this code to move all the sprites from the right to the left
    var anim = Timeline {
    repeatCount: Timeline.INDEFINITE
    keyFrames: KeyFrame {
    time: 0.1s;
    action : function(){
    for(n in container.content){
    def item = n as Sprite;
    item.posX -= 2;
    it moves the sprites for 2px every 0.1s, but it's not so smoth.
    Is there a better way for doing it?

    netsuvi wrote:
    But this approach limits me in someway that i am unable to change yet. It means that I have to know
    the end position on the sprite at the beginning? But how about user interaction? I would like to adjust the speed, during running.
    Or how about collision detections?To use this technique, you have to know the end position, at least provisionally, at the start.
    If something changes during the timeline (such as the user clicking) you can always stop the timeline
    and recompute a new trajectory and start another timeline.
    Collision detection is harder, especially among objects that are all moving.
    I saw some people are just generation tics. Like 10 per seconds, Then then calculate the whole stuff in a function.
    probably it would be enough to have 2 calculation tics per second and let the javaFX engine calculate the necessary frames in between.This is a reasonable approach, and it's fairly straightforward. However, even in some cases like BrickBreaker, you can compute
    the endpoint or do collision detection (mostly) up front without having to compute frame-by-frame. For example, when the ball
    is heading up, you can tell from its position and velocity whether it's going to hit a brick or a wall and when it will hit. When the
    ball is heading down, you don't know whether the ball will hit the paddle, because the user can move it. However, the paddle
    moves only horizontally along a certain Y-position, so you can compute the time and location at which the ball will reach that
    Y-position. If the paddle is there, it bounces, otherwise the ball drops off the bottom and the turn ends.
    If you want to compute collision detection among two or more moving objects, well, that's a lot harder. It probably requires doing
    a bunch of math, and it might be possible to do in closed form. If not, successive approximation might be the easiest way to do
    it.
    So in pseudo code it would something like this:
    Animation Start 0Seconds: Sprites have this position
    Animation Start 0.5Seconds: Move sprite to this position // JavaFX makes the in between steps
    do function() {
    calculate speed,
    calculate collision detection or whatever
    then restart the Animation steps.I think the key is to decouple the position and collision computations from the actual graphics animation.
    For example, suppose you have an object heading towards a wall that's 500 pixels away, and it's moving at 250
    pixels/sec. (Assume constant velocity.) Then you know that the object will be at the wall in 2 seconds, so
    you just set up a KeyFrame with that information, put it into a Timeline, and run it. You'll need to put an action
    function in the KeyFrame as well. But note that this doesn't necessarily compute the next 0.5 seconds or the
    next 2 seconds. Instead, it should look at the new state and compute the time at which the next event occurs
    and then set up KeyFrames to run all the objects until that time.
    I tried something with the timeline.playFromStart() but it didn't work. It just repeated the same animation instead of doing a new one.
    You have any clue how to do that?The playFromStart() function will simply replay the same animation, as you noted. What you want to do is
    recompute KeyFrames starting from the current state that show animation to some future state. Then,
    load these KeyFrames into the Timeline (or create a new Timeline) and run it.

  • Disable moving sprite on runtime

    HI,
    is it possible to disable to move sprites with arrow keys
    when running a
    project in director-authoring? I use arrowkeys for navigaiton
    and any
    time I have selected a sprite I move the spriteposition. Can
    I disable
    this ?
    TIA

    If you are running your movie in Director, sprites will only
    move when you press the arrow keys if:
    * the sprites are selected in the Score window
    * the Score window has focus
    If you click on the Stage before using the arrow keys, the
    Stage will take the focus from the Score window, and the arrow key
    input will be sent to the Stage instead.
    I assume that you have no Lingo code which alters the
    position of the sprites. If you do, then you will have to modify
    this code so that it is not called when you are in navigation
    mode.

  • Animating Sprites the slow poke approach...

    Hi there, I've got a small application which features small creatures controlled by some fearsome AI dashing around a randomly generated environment trying to kill each other. (it's somewhat more complex than that, but you get the gist). Rather than do the sensible thing and look for examples of Sprite animation, I just got stuck in, thinking, what the hell, I'll give it a shot. This is what I came up with....
    AnimationCanvas class extends JComponent, this is where all the animation stuff is drawn.
    SpriteManager class, contains a vector of all the sprites and is responsible for updates
    abstract Sprite class, provides an extensible template for sprites, I've got things like TreeSprite and RockSprite. Some of the sprites are composite sprites, comprising of several images which are overlapped slightly, an example of this is my AgentSprite it requires a total of 52 images, I load these using a MediaTracker when the object is instanciated before the app is displayed. They are all small images, less than 1k. The animation is done through the use of a Swing Timer which repaints the scene after a delay of 1000/24 ms, which I assume gives me 24fps ( is there a way of checking the fps? ) the AI portion of the app. updates the position of the sprites via the SpriteManager and also tells the Sprite what images to use. This works sweet on Win XP with my 2Ghz machine, but the target was to have it run on anything that runs Java 1.4 +. Running it under Linux on a PIII 500 for example is like watching paint dry. Great! Soooo I can only assume it is my inept implementation that is causing the problem, I have had a little look around and have seen a few people just using a single image with many sprites on it, using a PixelGrabber to get the desired bits, is this a more efficient method? Or does pre-loading the images with a MediaTracker do a better job? Or should a time my animation a different way? I would appreciate it if you could give me a tip or two.... I'm happy to post code snippets, but there's a fair ammount, specific bits might be easier... or if some of you are particularly adventurous i can put the source code up on the net for you to d/l and have a little look at :-)
    Cheers,
    Tom

    My source code, images and pre compiled classes are now available here...
    http://www.macs.hw.ac.uk/~ceetfc/ait/ait.zip

  • Problem controlling a number of x sprites

    I am developing a MIDlet maze game that is controlled by a servlet.
    The servlet sends av maze to every MIDlet connected to it, an the players
    can move around in the maze.
    The MIDlet also recives info about the other players position in the maze.
    I am trying to show this in the canvas so that one player can see where the
    other players are.
    I store the players x and y position and the sprite in a player object. The
    player-objects are put in a vector. I have no problem setting a new postion
    to a sprite, but i can't figure out how to remove the old sprite position.
    Nothing works :(
    Can enyone help?
    Sorry for my bad english.

    if you use MyFaces, use dataList. You can do any loop with it and define some collection in bean for controlling

  • Need urgent help with LayerManager (easy example)

    Im trying to get a scrolling effect by moving the view window.
    THE PROBLEM IS that if I move the view vindow the Sprite (spriteTest) is displayed at the new position AND still at the old position. I don't want it to be displayed on the old position. So if I move it a pixel every 5 ms I get a trail of the Sprite. Why does it happen??? (clueless)
    Here is the code...
    import javax.microedition.lcdui.game.GameCanvas;
    import javax.microedition.lcdui.game.LayerManager;
    import javax.microedition.lcdui.game.Sprite;
    import javax.microedition.lcdui.Graphics;
    import javax.microedition.lcdui.Image;
    public class Game extends GameCanvas implements Runnable
        private Thread t; //the thread running the game
        private Midlet midlet; //the midlet
        private int DISP_WIDTH; //the width of the display
        private int DISP_HEIGHT; //the height of the display
        private int xpositionView, ypositionView; //the x and y coordinates of the view window (used for scrolling)
        private LayerManager world; //the layermanager in which all sprites are added
        private Sprite spriteTest; //a Sprite with an image looking like a goomba from super mario
        /** Creates a new instance of Game */
        public Game(Midlet midlet)
           super(true);
           this.midlet = midlet;
           xpositionView = 1;
           ypositionView = 1;
           DISP_WIDTH = getWidth();
           DISP_HEIGHT = getHeight();
           world = new LayerManager();
           world.setViewWindow(xpositionView, ypositionView, DISP_WIDTH, DISP_HEIGHT);
           try
                spriteTest = new Sprite(Image.createImage("/images/goomba.png")); //creates the sprite containing an image (no frames only 1 picture)
           catch(Exception e)
               System.out.println("Couldn't load sprite image!");
           spriteTest.setPosition(190, 30); //sets the position of the sprite
           world.append(spriteTest);      //appends the sprite to the LayerManager
        /* The game loop */
        public void run()
            Graphics g = getGraphics();
            while(true)
                move();
                render(g);
                try
                    t.sleep(5); //sleeps for 5 ms
                catch (InterruptedException ie)
        /* Moves the view window to the right*/
        private void move()
            xpositionView = xpositionView + 1; //update position 1 pixel to the right
            world.setViewWindow(xpositionView, ypositionView, DISP_WIDTH, DISP_HEIGHT); //sets the view window to the new location
        /* Render the graphics. !!!!PROBLEM!!! */
        public void render(Graphics g)
            world.paint(g, 0, 0); //paints out the LayerManager
            flushGraphics();
       /* Starts the thread */
        public void start()
            t = new Thread(this);
            t.start();
    }

    I already do sleep the Thread 5 milliseconds.
    I've uploaded pictures and other to make you understand the problem:
    http://www.freewebs.com/scrolling/picture2.jpg
    Here is the entire project (its only 122 kb small) if you can help me I would love you forever :) When you run this you will understand the problem.
    http://www.freewebs.com/scrolling/ScrollingSimple.rar
    Im desperate for help :(

Maybe you are looking for

  • Can't open or move file - In use by Mac OS X

    I have a file (movie) I am trying to move to a new external hard drive. I can't move it cause it says it is used by Mac OS X and cannot be moved or if I try to open it says it can't be opened. The permissions are set correctly on this file and it pla

  • Movies edited in QT Pro and saved as self-contained revert in iTunes

    Hi all. I'm having a consistent bad experience editing QT movies in the QT Pro player. This is the typical workflow (on Mac OS X 10.5.7, lates QT update): 1. Screencast captured in iShowU HD saved as .mov with H264 codec 2. Edited .mov in QT Player (

  • Push function is not working

    Hi The Mail push function is not working properly. Sometimes it works for a couple of day, sometimes it is not working anymore. Do anybody know a solution for this? Thanks,

  • HT1338 what is the process to reformat my macBook Pro

    How can I re formate my MacBook Pro?

  • Right mouseclick in "Multicolumn Listbox"

    Hi Programming my application I want to be able to right click in a multicolumn listbox to pop up a small menu concerning the actual row. With normal event structure right click does not change the index. Any solutions?? Thanx Vagn