Sprite Visible

I have a script that checks for the visibility of checkboxes
-- then it goes to the next marker
go "Plan1"
cursor -1
Now it sets the visibility of certain pictures based on which
checkboxes were selected.
Problem: it sets the visibility of sprites on the original
screen also.
Shouldn't it only set the visibility of the sprites on the
new screen - since I have used go "plan1" to get to the new
screen

The visible property belongs to the sprite channel, not the
item that
currently occupies the sprite channel. So, if you set a
sprite channel
to be not visible, it will stay not visible until you tell it
to be
visible again.
You may want to use the blend property instead, this property
belongs to
the individual element in the sprite channel, not the channel
itself.
Be aware that if a sprite's blend value is set to 0, it is
still an
active sprite and any code attached to it will work. So a
cursor change
will still show if the user slides the cursor over that
hidden sprite.
This will not happen if you use the visible property.
Rob
Rob Dillon
Adobe Community Expert
http://www.ddg-designs.com
412-243-9119
http://www.macromedia.com/software/trial/

Similar Messages

  • Making Sprites visible on seperate frames

    Hi. Im trying to get my head around this and it is doing my
    head in.
    For example, while in frame 1 I want to be able to click a
    button which will then make a sprite visible in frame 10, which is
    a different page, i.e the sprite is only in frame 10 and the button
    is only in frame 1.
    If they were on the same page I could use...
    on mouseup me
    sprite("1").visible=true
    end
    but because they are on different frames to one another it
    tells me there is a property error with "visible". I need to make
    the function global some how but not sure how to do this.
    PLEASE HELP
    Lee

    Set a global variable in your mouseUp handler then use that
    variable's state
    to set the visible of the sprite in frame 10 in its
    beginSprite handler
    -- put this in a movie script
    global gSetVis
    on StartMovie
    gSetVis = FALSE
    end
    -- integrate this into the script/behavior for the button
    global gSetVis
    on mouseUp me
    gSetVis = FALSE
    end
    --Then in frame 10 on the sprite that needs to be made
    visible
    global gSetVis
    on beginSprite me
    sprite (me.spriteNum).visible = gSetVis
    end
    Craig Wollman
    Word of Mouth Productions
    phone 212 928 9581
    fax 212 928 9582
    159-00 Riverside Drive West #5H-70
    NY, NY 10032
    www.wordofmouthpros.com
    "Leegee3" <[email protected]> wrote in
    message
    news:eidcn4$be8$[email protected]..
    > Hi. Im trying to get my head around this and it is doing
    my head in.
    >
    > For example, while in frame 1 I want to be able to click
    a button which
    > will
    > then make a sprite visible in frame 10, which is a
    different page, i.e the
    > sprite is only in frame 10 and the button is only in
    frame 1.
    >
    > If they were on the same page I could use...
    >
    > on mouseup me
    > sprite("1").visible=true
    > end
    >
    > but because they are on different frames to one another
    it tells me there
    > is a
    > property error with "visible". I need to make the
    function global some
    > how but
    > not sure how to do this.
    >
    >
    > PLEASE HELP
    >
    >
    > Lee
    >

  • Director 11.5 activex

    Hi guys, i'm trying to change visibility of ana WMP activex control so that it's shows when i click on a button,
    i used the sprite().visible property in the script but, problem is that change never happens until i stop the movie!!
    the same thing doesn't happen with other sprites on the stage, they appear and disappear instantaneously!!!
    am i missing someting!!
    and another problem is that that WMP activex is always on top of everything else on the stage no matter is it's order!!
    i would appreciate any help on that!!

    bullzyz wrote:
    thanx for your helpful reply and info, very interresting approach, i guess that is exactly what i should do, although a bit messy.
    If could ask another question here related to activex; do the destination systems that the projector would run need to have this activex control installed or does it get bundled with the projector published file. i think all new windows systems already have the WMP ocx but what about older ones! ?
    Thanx in advance!
    Here's the web page that will get you started on the wonderful journey of obtaining a license to distribute the windows media player installer with your software: http://www.microsoft.com/windows/windowsmedia/licensing/distribute.aspx

  • Key press elapsed time

    I'm building a shooting game. I want to record how long the player has the F key pressed in order to use that value to remove ammunition sprites from the stage.
    My application loops in frame 1.
    I have a script that subtracts the key press time from the system time on key release. I think the repeat rate of the keyboard is interfering with this as the output figures are quite random and holding the key down for longer returns a lower number.
    global gFire, gTotal, gStartTime
    on startMovie
      the keyDownScript = "handleKeydown"
      the keyUpScript = "handleKeyUp"
    end startMovie
    --Handler to fire
    on handleKeydown
      if the key = "f" then
        gStartTime = the milliseconds
      end if 
    end handleKeydown
    --Handler to stop firing
    on handleKeyUp
      if the key = "f" then
        gfire = (the milliseconds - gStartTime)/10
        gLeft = gTotal - gFire
        gTotal = gLeft -- gTotal is used to incrementally turn off sprite visibility
        put gfire -- Trace elapsed time to Message window
      end if
    end handleKeyUp
    --This sequence removes bullets from the stage\
    according to he time spent firing
    on enterFrame
      if tTotal < 900 then
        sprite(10).visible = False --this repeated for a sequence of 10 sprites
      end if
    end
    The other problem with this is that it doesn't update the stage till the key is released, so a player can defeat the logic by just holding the key down continuously (especially because the value of gFire doesn't increase as expected)
    Ideally I'd like to record the elapsed time the key is down, add it to a global and have it update the stage at the frame rate, so I guess it would have to be within a frame event handler.
    Any help would be gratefully received.

    MStewart,
    Thanks for doing that. I decided to do a little something like that and just reworked it a bit. Dropped the pause on a case structure and put the timer inside. seemed easier to do it that way for what I wanted to accomplish. The pause is going to be a good thing to have in the event that the heater needs to be turnd off and worked on for any reason, and it won't accrue time or cycles. Used a "in range and coerce" to compare minutes and seconds and then wired a 4 to 15 mA simulated signal to to the timer. All I got to do now is duplicate it 14 more times and then to work on the cDaq part of it to control relays through dig out signals, and sequence the whole thing to write a file for the analog in. Thanks alot for your help and BowenM too. like I said: you guys are awesome. Got me to thinking in other directions.
    Attachments:
    Mexico sentinal loop.vi ‏11 KB
    milliamp timer w pause function.vi ‏24 KB

  • Class with interface, extends Sprite, but get compile error accessing "visible"

    Here is the situation:
    - Class MyLoader extends Sprite implements ILoader
    The class extends Sprite and works perfectly.
    var _loader:DisplayObject = new MyLoader();
    _loader.visible = true;
    Works perfectly.
    var _loader:ILoader = new MyLoader();
    _loader.visible = true;
    Casts a compiler error. Cannot access static property "visible" to a ILoader etc. etc.
    Doesn't make much sense to me, since the class extends a Sprite anyway...
    Am I missing something?
    thanks
    Filippo

    cast _loader as a Sprite (or DisplayObject);
    the flash compiler needs help remembering what's what.
    var _loader:ILoader=...
    Sprite(_loader).visible=true;

  • Flash sprite has to be visible (from YOU !) in authoring mode to   work !

    If this can help (and if you can confirm !).
    I already went through the trouble that you can't put a Flash
    sprite off
    stage otherwise you loose control over it (you have to keep
    one pixel on
    stage), but this is more tricky :
    I suddenly had my Flash sprites working only in projector
    mode and I
    discovered that lower right corner of the stage was not
    visible (stage
    window was resized), which is where I hide my Flash sprites.
    As soon as
    I could see the corner, problem was gone in authoring mode !
    PJ

    Why not make your FlashSprite invisible?
    Or change it's z-index and put it behind everything
    else?

  • Visible of sprite script trouble

    hi list
    I need to have a few sprites invisible on opening of my
    program and have them appear when rolled over. I am using the
    following script in the script channel above the play head:
    on mouseLeave me
    the visible of sprite 34 = 0
    end mouseLeave me
    Trouble is that when the program starts some or all of them
    are visible. It works perfectly when I roll-over them subsequently
    i.e. they all appear and disappear properly. All the sprites are
    visible all the time when I create the projector.
    I have re-booted several times to no avail. Any ideas?
    Eoin

    One of the effects of the visible of sprite property is that
    this
    property will make the sprite active or not. If a sprite is
    not visible,
    it is also not active and won't react to user events like a
    rollover.
    To have a sprite be not visible and still react to user
    events use the
    blend property of the sprite.
    Be aware that the visible of sprite property belongs to the
    sprite
    channel and not to the sprite that may currently occupy that
    channel. If
    you turn off the visible property of a sprite channel, it
    remains off
    throughout the rest of the score unless it is turned on
    again.
    The blend property belongs to the sprite in the channel, so
    setting a
    particular sprite's blend to 0 will not effect any other
    subsequent
    sprite occupying the same channel later in the score.
    If you want the sprites to be not visible initially, then set
    the blend
    property to 0 in the beginSprite function of a behavior
    attached to each
    sprite. Then you can change the blend property's value to 100
    when you
    want the sprite to be visible. For instance:
    property thisSprite
    on beginSprite me
    thisSprite = me.spriteNum
    sprite(thisSprite).blend = 0
    end
    on mouseEnter me
    sprite(thisSprite).blend = 100
    end
    on mouseLeave me
    sprite(thisSprite).blend = 0
    end
    Rob
    Rob Dillon
    Adobe Community Expert
    http://www.ddg-designs.com
    412-243-9119
    http://www.macromedia.com/software/trial/

  • Can a sprite become visible after a certain amount of user inactivity?

    Can a sprite become visible after a certain amount of user inactivity? like a timer triggering an event?

    Hi Kevin,
    You can look at the on timeOut event. (This is not to be confused with timeOut objects)
    There are a number of related properties, which date back from the early days of Director, and which seem to have been omitted from recent versions of the documentation, even though they still function. I give them here with their original names (prior to Director 10):
    the timeOutKeyDown
    the timeOutLapsed
    the timeOutLength
    the timeOutMouse
    the timeOutPlay
    the timeOutScript
    the lastClick
    the lastEvent
    the lastKey
    the lastRoll
    (You can also use the more recent DOM style for these last four properties: _player.lastXXX)
    Here's a very simple script which will make sprite 1 disappear when the movie starts, and reappear if the user does nothing for 5 seconds:
    on startMovie()
      sprite(1).visible = FALSE
      the timeOutLength = 300 -- = 5 seconds * 60 ticks / second
    end startMovie
    on timeOut()
      sprite(1).visible = TRUE
    end timeOut
    If you click the mouse at intervals of less than 5 seconds after starting the movie, then the sprite will remain invisible.
    NOTE: Using sprite(x).visible = FALSE will make the entire sprite channel invisible everywhere in the Score. It's better to use sprite(x).blend = 0, unless the sprite must not react to the mouse while it is invisble, in which case it is better to move it off-stage.
    Is this what you are looking for?
    James

  • Problem in Loading Multiple image in Single Sprite/MovieClip

    Hi All,
    I am having a killing problem in loading multiple images in single movie clip/sprite using a separate class.
    Here is the ImageLoader.as class
    package com.project.utils{
        import com.project.*;
        import com.project.utils.*;
        import flash.events.EventDispatcher;
        import flash.display.MovieClip;
        import flash.events.Event;
        import flash.events.ProgressEvent;
        import flash.display.Loader;
        import flash.events.IOErrorEvent;
        import flash.net.URLLoader;
        import flash.events.MouseEvent;
        import flash.net.URLRequest;
        import flash.display.Bitmap;
        public class ImageLoader extends EventDispatcher {
            public var imgloader:Loader;
            public var imgMc:MovieClip;
            public var imgObject:Object;
            public var loaded:Number;
            public function ImageLoader():void {
                imgMc = new MovieClip();
                imgObject = new Object();
                imgloader = new Loader();
            public function loadImage(imgHolder:MovieClip, imgObj:Object):void {
                imgMc = new MovieClip();
                imgObject = new Object();
                imgloader = new Loader();
                imgMc = imgHolder;
                imgObject = imgObj;
                imgloader.contentLoaderInfo.addEventListener(Event.COMPLETE,onImgLoad);
                imgloader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,onImgLoadProgress);
                imgloader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,onImageLoadFailed);
                imgloader.load(new URLRequest(imgObj.FilePath));
            private function onImgLoad(Evt:Event):void {
                var image:Bitmap = Bitmap(Evt.target.content);
                try {
                    imgMc.removeChildAt(0);
                } catch (error:Error) {
                imgMc.addChild(image);
                try {
                    if (imgObject.URL != undefined) {
                        imgMc.buttonMode = true;
                        imgMc.removeEventListener(MouseEvent.CLICK, onImageClicked);
                        imgMc.addEventListener(MouseEvent.CLICK, onImageClicked);
                } catch (err:Error) {
                dispatchEvent(new CustomEvent("CustomEvent.ON_IMGE_LOAD"));
            private function onImageClicked(evt:MouseEvent):void {
                trace("Image Attrs:"+imgObject.URL +" Target "+imgObject.Target);
            private function onImgLoadProgress(Evt:ProgressEvent):void {
                if (Evt.bytesLoaded>0) {
                    loaded = Math.floor((Evt.bytesLoaded*100)/Evt.bytesTotal);
                    dispatchEvent(new CustomEvent("CustomEvent.ON_IMGE_LOAD_PROC",loaded));
            private function onImageLoadFailed(Evt:IOErrorEvent):void {
                trace("Image Loading Failed");
                dispatchEvent(new CustomEvent("CustomEvent.ON_IMGE_LOAD_FAIL"));
    Here I am loading some images using the above class in a for loop, like
                for (var i=0; i < 3; i++) {
                    //imgLoader=new ImageLoader;
                    imgLoader.addEventListener("CustomEvent.ON_IMGE_LOAD",onImageLoad);
                    var target:MovieClip=videolist_mc["list" + mcCount + "_mc"];
                    target.list_mc.visible=false;
                    var imgObj:Object=new Object;
                    imgObj.FilePath=list[i].Thumbnail;
                    imgObj.Url=list[i].Url;
                    imgObj.Target=list[i].Target;
                    target.list_mc.urlObj=new Object  ;
                    target.list_mc.urlObj=imgObj;
                    imgLoader.loadImage(target.list_mc.imgholder_mc,imgObj);
                    target.list_mc.lable_txt.htmlText="<b>" + list[i].Label + "</b>";
                    target.list_mc.imgholder_mc.buttonMode=true;
                    target.list_mc.imgholder_mc.addEventListener(MouseEvent.CLICK,onItemPressed);
                    mcCount++;
    In this case, the ImageLoader.as works only on the last movie clip from the for loop. For example, if i am trying to load three image in three movie clips namely img_mc1,img_mc2 and img_mc3 using the for loop and ImageLoader.as, I am getting the image loaded in the third movie clip only img_mc.
    See at the same time, If i uncomment onething in the for loop that is
    //imgLoader=new ImageLoader;         
    its working like a charm. But I know creating class objects in a for loop is not a good idea and also its causes some other problems in my application.
    So, help to get rid out of this problem.
    Thanks
    -Varun

    package com.project.utils{
        import com.project.*;
        import com.project.utils.*;
        import flash.events.EventDispatcher;
        import flash.display.MovieClip;
        import flash.events.Event;
        import flash.events.ProgressEvent;
        import flash.display.Loader;
        import flash.events.IOErrorEvent;
        import flash.net.URLLoader;
        import flash.events.MouseEvent;
        import flash.net.URLRequest;
        import flash.display.Bitmap;
        public class ImageLoader extends EventDispatcher {
            public var imgloader:Loader;
            public var imgMc:MovieClip;
            public var imgObject:Object;
            public var loaded:Number;
            public function ImageLoader():void {
    // better add you movieclip to the stage if you want to view anything added to it.
                imgMc = new MovieClip();
                imgObject = new Object();
                imgloader = new Loader();
            public function loadImage(filepath:String):void {
                imgloader.contentLoaderInfo.addEventListener(Event.COMPLETE,onImgLoad);
                imgloader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,onImgLoadPr ogress);
                imgloader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,onImageLoadF ailed);
                imgloader.load(new URLRequest(filepath));
            private function onImgLoad(Evt:Event):void {
                var image:Bitmap = Bitmap(Evt.target.content);
                try {
                    imgMc.removeChildAt(0);
                } catch (error:Error) {
                imgMc.addChild(image);
                try {
                    if (imgObject.URL != undefined) {
                        imgMc.buttonMode = true;
                        imgMc.removeEventListener(MouseEvent.CLICK, onImageClicked);
                        imgMc.addEventListener(MouseEvent.CLICK, onImageClicked);
                } catch (err:Error) {
                dispatchEvent(new CustomEvent("CustomEvent.ON_IMGE_LOAD"));
            private function onImageClicked(evt:MouseEvent):void {
                trace("Image Attrs:"+imgObject.URL +" Target "+imgObject.Target);
            private function onImgLoadProgress(Evt:ProgressEvent):void {
                if (Evt.bytesLoaded>0) {
                    loaded = Math.floor((Evt.bytesLoaded*100)/Evt.bytesTotal);
                    dispatchEvent(new CustomEvent("CustomEvent.ON_IMGE_LOAD_PROC",loaded));
            private function onImageLoadFailed(Evt:IOErrorEvent):void {
                trace("Image Loading Failed");
                dispatchEvent(new CustomEvent("CustomEvent.ON_IMGE_LOAD_FAIL"));
    Here I am loading some images using the above class in a for loop, like
                for (var i=0; i < 3; i++) {
                    var imgLoader:ImageLoader=new ImageLoader();
                    imgLoader.addEventListener("CustomEvent.ON_IMGE_LOAD",onImageLoad);
                    var target:MovieClip=videolist_mc["list" + mcCount + "_mc"];
                    target.list_mc.visible=false;
                    var imgObj:Object=new Object;
                    imgObj.FilePath=list[i].Thumbnail;
                    imgObj.Url=list[i].Url;
                    imgObj.Target=list[i].Target;
                    target.list_mc.urlObj=new Object  ;
                    target.list_mc.urlObj=imgObj;
                    imgLoader.loadImage(pass the image file's path/name);
                    target.list_mc.lable_txt.htmlText="<b>" + list[i].Label + "</b>";
                    target.list_mc.imgholder_mc.buttonMode=true;
                    target.list_mc.imgholder_mc.addEventListener(MouseEvent.CLICK,onItemPressed);
                    mcCount++;

  • How to make a loop that changes two different movieclips from visible to invisible every second

    I am writing some code that puzzles me. It may be, because I have a cold or because I've never needed to do anything like this. I want to have two movieclips one is visible and one is not. then one second passes the one that was visible is invisible and the invisible one is visible. What would be the best approach to this, besides handcoding if statements. I know there has to be a faster way and less expensive way than handcoding if statements.
    I'd like to thank anyone who replies in advance .

    this is how i would do it
    package
              import flash.display.MovieClip;
              import flash.display.Sprite;
              import flash.events.TimerEvent;
              import flash.utils.Timer;
              public class Main extends Sprite
                        private var mc1:MovieClip;
                        private var mc2:MovieClip;
                        public function Main()
                                  // create your mc's here
                                  mc1 = new MovieClip();
                                  mc2 = new MovieClip();
                                  mc2.visible = false;
                                  var timer:Timer = new Timer(1000);
                                  timer.addEventListener(TimerEvent.TIMER, loop);
                                  timer.start();
                        private function loop(e:TimerEvent):void
                                  mc1.visible = !mc1.visible;
                                  mc2.visible = !mc2.visible;

  • Sprite collision

    im using two (transparent background) .png images as sprites. Both are of same width and height. And both have the same starting point.
    But one image is on lower half of one sprite, and the other image is on upper half. Non-transparent (visible) parts of the images collides only at one point. Even though sprites meets at only one point the method below always returns true.
    I used this method to check the collision.
    What's wrong with my code ?
    boolean checkCollision(){
        if(sprite_car.collidesWith(sprite_man,true)){
          return true;
        } else return false;
      }hope this info is enough .If anyone need more info pls let me know.
    Thanx in advance !

    hi,
    incase you have not yet found the answer, can you post the code here?

  • Can't figure out Sprites

    Okay so my partner and i have been working on this project for a while now and we are stuck with two thing. First we can't get the enemy sprite to go into the enemy picture box. Second we can't get the sprite sheet to shift down. We have tried multiple things
    and we are stuck if someone could help that would be awesome.
    Here is our code:
    Option Strict On
    Public Class frmMain
    Dim ctr As SByte = 1
    Dim playerSpeed As Byte = 5
    Dim enemyMove As Boolean = False
    Dim enemySpeed As Point = New Point(-10, 0)
    Dim characterMain As PictureBox = New PictureBox()
    Dim enemyMain As PictureBox = New PictureBox()
    Dim titleScreen As PictureBox = New PictureBox()
    Dim frames(8) As Bitmap
    Dim Archer As Bitmap = New Bitmap("./Resources/Images/Character_Models/Archer_2.bmp")
    Dim Warrior As Bitmap = New Bitmap("./Resources/Images/Character_Models/Warrior_2.bmp")
    Dim Mage As Bitmap = New Bitmap("./Resources/Images/Character_Models/Mage_2.bmp")
    Dim Boss As Bitmap = New Bitmap("./Resources/Images/Character_Models/Final_Boss.bmp")
    Const CHARACTER_WIDTH As Short = 37
    Const CHARACTER_HEIGHT As Short = 43
    Public Sub clearScreen()
    For Each screenControl As Control In Me.Controls
    screenControl.Visible = False
    screenControl.Enabled = False
    Next
    End Sub
    Private Sub btnNewGame_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNewGame.Click
    lblTitle.Text = "Character Selection"
    btnNewGame.Visible = False
    btnRules.Visible = False
    cboChar.Visible = True
    btnStartGame.Visible = True
    Me.Controls.Add(characterMain)
    Me.Controls.Add(titleScreen)
    Me.Controls.Add(enemyMain)
    btnBack.Visible = True
    End Sub
    Private Sub btnRules_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRules.Click
    MessageBox.Show("Click new game to start new game", "Instructions", MessageBoxButtons.OK)
    MessageBox.Show("Use WASD to move your character", "Instructions", MessageBoxButtons.OK)
    End Sub
    Private Sub btnStartGame_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnStartGame.Click
    clearScreen()
    PlayBackgroundSoundFile()
    titleScreen.Size = New Size(576, 720)
    enemyMain.Size = New Size(CHARACTER_WIDTH, CHARACTER_HEIGHT)
    enemyMain.Location = New Point(0, 500)
    characterMain.Size = New Size(CHARACTER_WIDTH, CHARACTER_HEIGHT)
    characterMain.Location = New Point(0, 500)
    titleScreen.Location = New Point(0, 0)
    titleScreen.Visible = True
    characterMain.Visible = True
    characterMain.Enabled = True
    enemyMain.Visible = True
    enemyMain.Enabled = True
    titleScreen.Image = Image.FromFile("./Resources/Images/Terrain/TitleBG.jpg")
    titleScreen.SizeMode = PictureBoxSizeMode.StretchImage
    Me.Size = titleScreen.Size
    For x As Integer = 0 To 8
    frames(x) = New Bitmap(CHARACTER_WIDTH, CHARACTER_HEIGHT)
    Dim gr As Graphics = Graphics.FromImage(frames(x))
    Dim leftPos As Integer
    Select Case x
    Case 1, 4, 7
    leftPos = 32
    Case 2, 5, 8
    leftPos = 64
    Case 3, 6, 9
    leftPos = 96
    End Select
    gr.DrawImage(Boss, 0, 0, New RectangleF(leftPos, CSng(Int(x / 2) * 0), CHARACTER_WIDTH, CHARACTER_HEIGHT), GraphicsUnit.Pixel)
    If cboChar.Text = "Archer" Then
    gr.DrawImage(Archer, 0, 0, New RectangleF(leftPos, CSng(Int(x / 2) * 0), CHARACTER_WIDTH, CHARACTER_HEIGHT), GraphicsUnit.Pixel)
    Else
    characterMain.Image = Nothing
    End If
    If cboChar.Text = "Warrior" Then
    gr.DrawImage(Warrior, 0, 0, New RectangleF(leftPos, CSng(Int(x / 2) * 0), CHARACTER_WIDTH, CHARACTER_HEIGHT), GraphicsUnit.Pixel)
    Else
    characterMain.Image = Nothing
    End If
    If cboChar.Text = "Mage" Then
    gr.DrawImage(Mage, 0, 0, New RectangleF(leftPos, CSng(Int(x / 2) * 0), CHARACTER_WIDTH, CHARACTER_HEIGHT), GraphicsUnit.Pixel)
    Else
    characterMain.Image = Nothing
    End If
    Next
    CenterToScreen()
    End Sub
    Private Sub frmMain_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
    enemyMove = True
    If tmrEnemyMove.Enabled = False Then
    tmrEnemyMove.Enabled = True
    End If
    Select Case e.KeyCode
    Case Keys.A
    If ctr < 8 Then
    characterMain.Location += New System.Drawing.Size(-1 * playerSpeed, 0)
    ctr = CSByte(ctr + 1)
    Else
    ctr = 0
    End If
    characterMain.Image = frames(ctr)
    Case Keys.S
    If ctr < 8 Then
    characterMain.Location += New System.Drawing.Size(0, playerSpeed)
    ctr = CSByte(ctr + 1)
    Else
    ctr = 0
    End If
    characterMain.Image = frames(ctr)
    Case Keys.D
    If ctr < 8 Then
    characterMain.Location += New System.Drawing.Size(playerSpeed, 0)
    ctr = CSByte(ctr + 1)
    'characterMain.Image.RotateFlip(RotateFlipType.RotateNoneFlipX)
    Else
    ctr = 0
    End If
    characterMain.Image = frames(ctr)
    Case Keys.W
    If ctr < 8 Then
    characterMain.Location += New System.Drawing.Size(0, -1 * playerSpeed)
    ctr = CSByte(ctr + 1)
    Else
    ctr = 0
    End If
    characterMain.Image = frames(ctr)
    Case Keys.Escape
    Me.Close()
    End Select
    Constrain(enemyMain, New Rectangle(New Point(0, 0), Me.Size))
    Constrain(characterMain, New Rectangle(New Point(0, 0), Me.Size))
    End Sub
    Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    CenterToScreen()
    End Sub
    Private Sub cboChar_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboChar.TextChanged
    btnStartGame.Enabled = True
    End Sub
    Private Sub btnBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBack.Click
    lblTitle.Visible = True
    btnNewGame.Visible = True
    btnRules.Visible = True
    btnBack.Visible = False
    lblTitle.Text = "Reign of Pixel"
    cboChar.Visible = False
    btnStartGame.Visible = False
    End Sub
    Private Function Constrain(ByRef box As PictureBox, ByVal boundingBox As Rectangle) As Boolean
    With box.Location
    If (.X < boundingBox.X) Then
    box.Location = New Point(boundingBox.X, .Y)
    ElseIf (.X > (boundingBox.X + boundingBox.Width) - box.Width) Then
    box.Location = New Point((boundingBox.X + boundingBox.Width) - box.Width, .Y)
    End If
    If (.Y < boundingBox.Y) Then
    box.Location = New Point(.X, boundingBox.Y)
    ElseIf (.Y > (boundingBox.Y + boundingBox.Height) - box.Height) Then
    box.Location = New Point(.X, (boundingBox.Y + boundingBox.Height) - box.Height)
    End If
    End With
    End Function
    Private Sub tmrAnimation_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmrAnimation.Tick
    While Keys.A = Keys.Down And ctr < 8
    ctr = CSByte(ctr + 1)
    If ctr <> 8 Then
    tmrAnimation.Enabled = True
    Else
    tmrAnimation.Enabled = False
    End If
    End While
    End Sub
    Private Sub tmrEnemyMove_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmrEnemyMove.Tick
    If (enemyMove = False) Then
    tmrEnemyMove.Enabled = False
    End If
    If (Constrain(enemyMain, New Rectangle(New Point(0, 0), Me.Size))) Then
    enemySpeed = New Point(enemySpeed.X * -1, enemySpeed.Y * -1)
    End If
    End Sub
    Private Sub PlayBackgroundSoundFile()
    My.Computer.Audio.Play("./Resources/Sound/ReignOfPixel.wav", AudioPlayMode.Background)
    End Sub
    End Class

    If you have a sprite, you should pre-crop each frame into a list of image, that way as each frame elapses, you simply set the pictureboxes image to one of the pre-cropped images.
    Don't forget to vote for Helpful Posts and
    Mark Answers!
    *This post does not reflect the opinion of Microsoft, or its employees.

  • Objects added to Sprite/MC not appearing

    Hello all, I've been working on building a game and encountered a strange problem this morning when instead of adding objects directly to the stage I needed to add them to a Sprite (I also tried this with a MovieClip) which was on the stage instead and they did not appear. If anyone can see why this is happening I will be eternally grateful, as it's got me stumped! And yes, before anyone says it, the MC/Sprite that I'm adding the objects to has definitely been added to the stage, I've made that mistake before and don't plan on making it again
    Essentially I have been building the game's levels using various different objects (rectangles, circles etc) built in the Box2D physics engine and with attached sprites to represent them to the user. When creating each of these object I supply a DisplayObjectContainer in which the sprite representing the object should be placed. Up until now I have been simply been supplying my core game class as the DisplayObjectContainer, with no problems whatsoever - everything is displaying fine. A new level design, however, will require me to apply a mask to the entire level (but not the GUI) so I decided to place all the level objects within a MovieClip or Sprite instead. I have created the new sprite as such:
    levelObjects = new Sprite();
    levelObjects.x = levelObjects.y = 0; //Just to make sure
    levelObjects.width = GameProperties.stageWidth;
    levelObjects.height = GameProperties.stageHeight;
    levelObjects.visible = true; //Just to make sure
    addChild(levelObjects)
    and have been supplying this sprite to the level objects as a DisplayObjectContainer instead of the core game class. Everything is getting added to the stage as I can click on things and the sounds associated with the game objects are playing correctly, but nothing is actually visible! As I mentioned above I tried this using a MovieClip instead but got the same result. Does anyone have any idea why this is happening and how I can fix it? Please post anything that might help, I've tried everything I can think of so now I'm going to rack your brains instead haha
    Thanks in advance,
    Dinkyfish

    Aha! Right, that's at least partially solved the problem, I'm now waiting until I have added the first object to the sprite before setting the width/height values. Thank you very much
    Unfortunately, things still aren't quite working the way they should as the entire sprite is now simply filled with a dark blue colour. Now quite a few of the objects I'm adding are dark blue in colour, but none should be big enough to obscure the entire sprite which is what I suspect is happening. Is there going to be some sort of conversion I'll have to do to the x/y/width/height values of the display objects I'm adding to the sprite? I thought it would simply be the same values I would need to supply if the sprite was the same size as the stage...

  • Rotating Sprite Center Axis

    Hi,
    I found an interesting tutorial (link) and created a working model, adapting it as needed.
    So far, when I center the container sprite and rotate it, it appears to first rotate from a 0,0 registration point, instead of from its center. I've tried to changet he sprite's registration point, but so far this hasn't worked/helped. Nothing else has worked to fix this rotation problem.
    I must be doing something wrong.
    Here's the AS3 (to view, add to first frame of new FLA, 1024X768 stage, color black). Rotation segments below are commented as       //ROTATION.:
    import flash.display.Sprite;
        import flash.events.MouseEvent;
        import flash.events.Event;
        import flash.text.TextField;
        //import flash.geom.ColorTransform;
    stop();
        //public class bejewelled extends Sprite {
            var gems_array:Array=new Array();
            var aGem:Sprite;
            var selectorBox:Sprite=new Sprite();
            var selectorRow:int=-10;
            var selectorColumn:int=-10;
            var red:uint = 0xFF0000;
            var green:uint = 0xFF00;
            var blue:uint = 0xFF;
            var yellow:uint = 0xFFFF00;
            var cyan:uint = 0xFFFF;
            var magenta:uint = 0xFF00FF;
            var white:uint = 0xFFFFFF;
            var colours_array:Array=new Array(red,green,blue,yellow,cyan,magenta,white);
            var clickPossible:Boolean=false;
            var score_txt:TextField=new TextField();
            var hint_txt:TextField=new TextField();
            var score:uint=0;
            var inaRow:uint=0;
            var match:Boolean = true;
            var gemSize:uint = 96;
            var format:TextFormat = new TextFormat();
            var rotate:Boolean=false;
            var container:Sprite = new Sprite(); // Create the container sprite
             //var newColorTransform:ColorTransform = exitBtn.transform.colorTransform;
            //newColorTransform.color = 0xff0000;
            //exitBtn.transform.colorTransform = newColorTransform;
            function bejewelled() {
                // Game initiation
                format.size = 40;
                format.font = 'Arial';
                // Create and style score text
                addChild(score_txt);
                score_txt.textColor=0xFFFFFF;
                score_txt.x=gemSize*9.6;
                score_txt.autoSize = TextFieldAutoSize.LEFT;
                score_txt.defaultTextFormat = format;           
                // Create and style hint text
                addChild(hint_txt);
                hint_txt.textColor=0xFFFFFF;
                hint_txt.x=gemSize*9.6;
                hint_txt.y=gemSize;
                hint_txt.autoSize = TextFieldAutoSize.LEFT;
                hint_txt.defaultTextFormat = format;
                // Create Gems in rows and columns
                addChild(container); // Add the container to the display list (stage)
                for (var i:uint=0; i<8; i++) {
                    gems_array[i]=new Array();
                    for (var j:uint=0; j<8; j++) {
                        do {
                            gems_array[i][j]=Math.floor(Math.random()*7);
                            while (rowLineLength(i,j)>2 || columnLineLength(i,j)>2);
                        aGem=new Sprite();
                        aGem.graphics.beginFill(colours_array[gems_array[i][j]]);
                        aGem.graphics.drawCircle(gemSize/2,gemSize/2,gemSize/2.07);
                        aGem.graphics.endFill();
                        aGem.name=i+"_"+j;
                        aGem.x=j*gemSize;
                        aGem.y=i*gemSize;
                        container.addChild(aGem);
                //Center the container sprite
                container.width = container.width - 10;
                container.height =  container.height - 10;           
                container.x = (stage.stageWidth-container.width)/2;
                container.y = (stage.stageHeight-container.height)/2;
                // Create and style selector box
                container.addChild(selectorBox);
                selectorBox.graphics.lineStyle(2,red,1);
                selectorBox.graphics.drawRect(0,0,gemSize,gemSize);
                selectorBox.visible=false;
                // Listen for user input
                container.addEventListener(MouseEvent.CLICK,onClick);
                addEventListener(Event.ENTER_FRAME,everyFrame);
            // Every frame...
            function everyFrame(e:Event):void {
                //Assume that gems are not falling
                var gemsAreFalling:Boolean=false;
                // Check each gem for space below it
                for (var i:int=6; i>=0; i--) {
                    for (var j:uint=0; j<8; j++) {
                        // If a spot contains a gem, and has an empty space below...
                        if (gems_array[i][j] != -1 && gems_array[i+1][j]==-1) {
                            // Set gems falling
                            gemsAreFalling=true;
                            gems_array[i+1][j]=gems_array[i][j];
                            gems_array[i][j]=-1;
                            trace("#");
                            trace(i+"_"+j);
                            container.getChildByName(i+"_"+j).y+=gemSize;
                            container.getChildByName(i+"_"+j).name=(i+1)+"_"+j;
                            break;
                    // If a gem is falling
                    if (gemsAreFalling) {
                        // don't allow any more to start falling
                        break;
                // If no gems are falling
                if (! gemsAreFalling) {
                    // Assume no new gems are needed
                    var needNewGem:Boolean=false;
                    // but check all spaces...
                    for (i=7; i>=0; i--) {
                        for (j=0; j<8; j++) {
                            // and if a spot is empty
                            if (gems_array[i][j]==-1) {
                                // now we know we need a new gem
                                needNewGem=true;
                                // pick a random color for the gem
                                gems_array[0][j]=Math.floor(Math.random()*7);
                                // create the gem
                                aGem=new Sprite();
                                aGem.graphics.beginFill(colours_array[gems_array[0][j]]);
                                aGem.graphics.drawCircle(gemSize/2,gemSize/2,gemSize/2.07);
                                aGem.graphics.endFill();
                                // ID it
                                aGem.name="0_"+j;
                                // position it
                                aGem.x=j*gemSize;
                                aGem.y=0;
                                // show it
                                container.addChild(aGem);
                                // stop creating new gems
                                break;
                        // if a new gem was created, stop checking
                        if (needNewGem) {
                            break;
                    // If no new gems were needed...
                    if (! needNewGem) {
                        // assume no more/new lines are on the board
                        var moreLinesAvailable:Boolean=false;
                        // check all gems
                        for (i=7; i>=0; i--) {
                            for (j=0; j<8; j++) {
                                // if a line is found
                                if (rowLineLength(i,j)>2 || columnLineLength(i,j)>2) {
                                    // then we know more lines are available
                                    moreLinesAvailable=true;
                                    // creat a new array, set the gem type of the line, and where it is
                                    var lineGems:Array=[i+"_"+j];
                                    var gemType:uint=gems_array[i][j];
                                    var linePosition:int;
                                    // check t's a horizontal line...
                                    if (rowLineLength(i,j)>2) {
                                        // if so, find our how long it is and put all the line's gems into the array
                                        linePosition=j;
                                        while (sameGemIsHere(gemType,i,linePosition-1)) {
                                            linePosition--;
                                            lineGems.push(i+"_"+linePosition);
                                        linePosition=j;
                                        while (sameGemIsHere(gemType,i,linePosition+1)) {
                                            linePosition++;
                                            lineGems.push(i+"_"+linePosition);
                                    // check t's a vertical line...
                                    if (columnLineLength(i,j)>2) {
                                        // if so, find our how long it is and put all the line's gems into the array
                                        linePosition=i;
                                        while (sameGemIsHere(gemType,linePosition-1,j)) {
                                            linePosition--;
                                            lineGems.push(linePosition+"_"+j);
                                        linePosition=i;
                                        while (sameGemIsHere(gemType,linePosition+1,j)) {
                                            linePosition++;
                                            lineGems.push(linePosition+"_"+j);
                                    // for all gems in the line...
                                    for (i=0; i<lineGems.length; i++) {
                                        // remove it from the program
                                        container.removeChild(container.getChildByName(lineGems[i]));
                                        // find where it was in the array
                                        var cd:Array=lineGems[i].split("_");
                                        // set it to an empty gem space
                                        gems_array[cd[0]][cd[1]]=-1;
                                        // set the new score
                                        score+=inaRow;
                                        // set the score setter up
                                        inaRow++;
                                    // if a row was made, stop the loop
                                    break;
                            // if a line was made, stop making more lines
                            if (moreLinesAvailable) {
                                break;
                        // if no more lines were available...
                        //ROTATION
                        if (! moreLinesAvailable) {
                            if(rotate){
                                container.rotation+=5;                           
                                if(container.rotation%90==0){
                                    rotate=false;
                                    container.rotation=0;
                                    rotateClockwise(gems_array);
                                    while(container.numChildren>0){
                                        container.removeChildAt(0);
                                    for (i=0; i<8; i++) {
                                        for (j=0; j<8; j++) {
                                            aGem=new Sprite();
                                            aGem.graphics.beginFill(colours_array[gems_array[i][j]]);
                                            aGem.graphics.drawCircle(gemSize/2,gemSize/2,gemSize/2.07);
                                            aGem.graphics.endFill();
                                            aGem.name=i+"_"+j;
                                            aGem.x=j*gemSize;
                                            aGem.y=i*gemSize;
                                            container.addChild(aGem);                                       
                                            container.addChild(selectorBox);
                                            selectorBox.graphics.lineStyle(2,red,1);
                                            selectorBox.graphics.drawRect(0,0,gemSize,gemSize);
                                            selectorBox.visible=false;
                            else{
                                // allow new moves to be made
                                clickPossible=true;
                                // remove score multiplier
                                inaRow=0;
                // display new score
                score_txt.text=score.toString();
            // When the user clicks
            function onClick(e:MouseEvent):void {
                // If a click is allowed
                if (clickPossible) {
                    // If the click is within the game area...
                    if (mouseX<container.x+gemSize*8 && mouseX>0 && mouseY<container.y+gemSize*8 && mouseY>0) {
                        // Find which row and column were clicked
                        var clickedRow:uint=Math.floor((mouseY-container.y)/gemSize);
                        //var clickedRow:uint=Math.floor(e.target.y/gemSize);
                        var clickedColumn:uint=Math.floor((mouseX-container.x)/gemSize);
                        //var clickedColumn:uint=Math.floor(e.target.x/gemSize);
                        // Check if the clicked gem is adjacent to the selector
                        // If not...
                        if (!(((clickedRow==selectorRow+1 || clickedRow==selectorRow-1)&&clickedColumn==selectorColumn)||((clickedColumn==selectorColumn+1 || clickedColumn==selectorColumn-1) && clickedRow==selectorRow))) {
                            // Find row and colum the selector should move to
                            selectorRow=clickedRow;
                            selectorColumn=clickedColumn;
                            // Move it to the chosen position
                            selectorBox.x=gemSize*selectorColumn;
                            selectorBox.y=gemSize*selectorRow;
                            // If hidden, show it.
                            selectorBox.visible=true;
                        // If it is not next to it...
                        else {
                            // Swap the gems;
                            swapGems(selectorRow,selectorColumn,clickedRow,clickedColumn);
                            // If they make a line...
                            if (rowLineLength(selectorRow,selectorColumn)>2 || columnLineLength(selectorRow,selectorColumn)>2||rowLineLength(clickedRow,clickedColumn)>2 || columnLineLength(clickedRow,clickedColumn)>2) {
                                // remove the hint text
                                hint_txt.text="";
                                // dis-allow a new move until cascade has ended (removes glitches)
                                clickPossible=false;
                                // move and rename the gems
                                container.getChildByName(selectorRow+"_"+selectorColumn).x=e.target.x;//clickedColumn*gemSize;
                                container.getChildByName(selectorRow+"_"+selectorColumn).y=e.target.y;//clickedRow*gemSize;
                                container.getChildByName(selectorRow+"_"+selectorColumn).name="t";
                                container.getChildByName(clickedRow+"_"+clickedColumn).x=selectorColumn*gemSize;
                                container.getChildByName(clickedRow+"_"+clickedColumn).y=selectorRow*gemSize;
                                container.getChildByName(clickedRow+"_"+clickedColumn).name=selectorRow+"_"+selectorColumn;
                                container.getChildByName("t").name=clickedRow+"_"+clickedColumn;
                                match = true;
                                rotate = true;
                            // If not...
                            else {
                                // Switch them back
                                swapGems(selectorRow,selectorColumn,clickedRow,clickedColumn);
                                match = false;
                            if (match) {
                                // Move the selector position to default
                                selectorRow=-10;
                                selectorColumn=-10;
                                // and hide it
                                selectorBox.visible=false;
                            else {
                                // Set the selector position
                                selectorRow=clickedRow;
                                selectorColumn=clickedColumn;
                                // Move the box into position
                                selectorBox.x=gemSize*selectorColumn;
                                selectorBox.y=gemSize*selectorRow;
                                match = false;
                                // If hidden, show it.
                                selectorBox.visible=true;
                    // If the click is outside the game area
                    else {
                        // For gems in all rows...
                        for (var i:uint=0; i<8; i++) {
                            // and columns...
                            for (var j:uint=0; j<8; j++) {
                                // if they're not too close to the side...
                                if (i<7) {
                                    // swap them horizontally
                                    swapGems(i,j,i+1,j);
                                    // check if they form a line
                                    if ((rowLineLength(i,j)>2||columnLineLength(i,j)>2||rowLineLength(i+1,j)>2||columnLineLength(i+1,j)>2)) {
                                        // if so, name the move made
                                        selectorBox.x = j*gemSize;
                                        selectorBox.y = i*gemSize;
                                        selectorBox.visible = true;
                                        hint_txt.text = (i+1).toString()+","+(j+1).toString()+"->"+(i+2).toString()+","+(j+1).toString();
                                    // swap the gems back
                                    swapGems(i,j,i+1,j);
                                // then if they're not to close to the bottom...
                                if (j<7) {
                                    // swap it vertically
                                    swapGems(i,j,i,j+1);
                                    // check if it forms a line
                                    if ((rowLineLength(i,j)>2||columnLineLength(i,j)>2||rowLineLength(i,j+1)>2||columnLineLength(i,j+1)>2) ) {
                                        // if so, name it
                                        selectorBox.x = j*gemSize;
                                        selectorBox.y = i*gemSize;
                                        selectorBox.visible = true;
                                        hint_txt.text = (i+1).toString()+","+(j+1).toString()+"->"+(i+1).toString()+","+(j+2).toString();
                                    // swap the gems back
                                    swapGems(i,j,i,j+1);
            //Swap given gems
            function swapGems(fromRow:uint,fromColumn:uint,toRow:uint,toColumn:uint):void {
                //Save the original position
                var originalPosition:uint=gems_array[fromRow][fromColumn];
                //Move original gem to new position
                gems_array[fromRow][fromColumn]=gems_array[toRow][toColumn];
                //move second gem to saved, original gem's position
                gems_array[toRow][toColumn]=originalPosition;
            //Find out if there us a horizontal line
            function rowLineLength(row:uint,column:uint):uint {
                var gemType:uint=gems_array[row][column];
                var lineLength:uint=1;
                var checkColumn:int=column;
                //check how far left it extends
                while (sameGemIsHere(gemType,row,checkColumn-1)) {
                    checkColumn--;
                    lineLength++;
                checkColumn=column;
                //check how far right it extends
                while (sameGemIsHere(gemType,row,checkColumn+1)) {
                    checkColumn++;
                    lineLength++;
                // return total line length
                return (lineLength);
            //Find out if there us a vertical line
            function columnLineLength(row:uint,column:uint):uint {
                var gemType:uint=gems_array[row][column];
                var lineLength:uint=1;
                var checkRow:int=row;
                //check how low it extends
                while (sameGemIsHere(gemType,checkRow-1,column)) {
                    checkRow--;
                    lineLength++;
                //check how high it extends
                checkRow=row;
                while (sameGemIsHere(gemType,checkRow+1,column)) {
                    checkRow++;
                    lineLength++;
                // return total line length
                return (lineLength);
            function sameGemIsHere(gemType:uint,row:int,column:int):Boolean {
                //Check there are gems in the chosen row
                if (gems_array[row]==null) {
                    return false;
                //If there are, check if there is a gem in the chosen slot
                if (gems_array[row][column]==null) {
                    return false;
                //If there is, check if it's the same as the chosen gem type
                return gemType==gems_array[row][column];
               //ROTATION
               function rotateClockwise(a:Array):void {
                var n:int=a.length;
                for (var i:int=0; i<n/2; i++) {
                    for (var j:int=i; j<n-i-1; j++) {
                        var tmp:String=a[i][j];
                        a[i][j]=a[n-j-1][i];
                        a[n-j-1][i]=a[n-i-1][n-j-1];
                        a[n-i-1][n-j-1]=a[j][n-i-1];
                        a[j][n-i-1]=tmp;
    bejewelled();  
    Any help appreciated.

    OK, way too much code. By default, everything will rotate from top left. If you want to change that you need to change the positions of the content within the container, not the container itself.
    For example if you do something like this:
    var a:Sprite = new Sprite(); //container
    addChild(a);
    a.x = 100; a.y = 100;
    var b:MovieClip = new car(); //clip from library
    a.addChild(b);
    addEventListener(Event.ENTER_FRAME, up);
    function up(e:Event):void
              a.rotation += 1;
    The car added to the container will rotate about it's top left point... because that's where the container rotates about. To fix, move the car so the containers top/left is at the car's center like so:
    var a:Sprite = new Sprite();
    addChild(a);
    a.x = 100; a.y = 100;
    var b:MovieClip = new car();
    a.addChild(b);
    b.x -= b.width / 2;
    b.y -= b.height / 2;
    addEventListener(Event.ENTER_FRAME, up);
    function up(e:Event):void
              a.rotation += 1;
    You'll notice all that changed is moving the car 1/2 it's width and height.
    HTH

  • Class display objects visible=false

    Hi there,
    I have an app that displays XML as items. I am taking the createLayout() and trying to create a class that i can call from my custom component rather than having tons of code in the same file. The issue i am having is that when i call it, and run/debug, the display objects (text,links,date..) all have their visible property set to false. This happens even though I set the property to true in my code. Please help!
    package com.ryancanulla.utils
         import flash.display.Sprite;
         import flash.events.MouseEvent;
         import flash.net.URLRequest;
         import flash.net.navigateToURL;
         import flash.text.TextFormat;
         import mx.collections.XMLListCollection;
         import mx.containers.Canvas;
         import mx.containers.HBox;
         import mx.containers.VBox;
         import mx.controls.CheckBox;
         import mx.controls.ComboBox;
         import mx.controls.LinkButton;
         import mx.controls.Text;
         public class CreateLayout extends Sprite {
         //     Display Vars
              private var vBox:VBox;
              private var hBox:HBox;
              private var titleText:LinkButton;
              private var itemInfo:Text;
              private var abstract:Text;
              private var archive:CheckBox;
              private var rateItem:ComboBox;
              private var category:ComboBox;
              private var container:VBox;
              private var clickURL:Text;
              private var canvas:Canvas;
              private var titleFormat:TextFormat;
              public function CreateLayout(listCollection:XMLListCollection)
                   listCollection = listCollection;
                   container = new VBox();
                   var categoryLabels:Array = new Array("Health","Industrial","Emerging Tech","Food & Ag");
                   var rateLabels:Array = new Array("Positive","Neutral","Negative");
                   for(var i:int=0; i<listCollection.length; i++) {
                        canvas = new Canvas();
                        hBox = new HBox();
                        titleText = new LinkButton();
                        titleFormat = new TextFormat();
                        itemInfo = new Text();
                        abstract = new Text();
                        archive = new CheckBox();
                        rateItem = new ComboBox();
                        category = new ComboBox();
                        clickURL = new Text();
                        titleText.label = listCollection.getItemAt(i).title;
                        titleText.addEventListener(MouseEvent.CLICK, getURL);
                        titleText.width = 400;
                        clickURL.text = listCollection.getItemAt(i).clickurl;
                        clickURL.visible = false;
                        clickURL.includeInLayout = false;
                        itemInfo.text = listCollection.getItemAt(i).source + " | " + listCollection.getItemAt(i).date;
                        itemInfo.y = 25;
                        abstract.text = listCollection.getItemAt(i).abstract;
                        abstract.y = 42;
                        abstract.visible = true;
                        abstract.includeInLayout = true;
                        abstract.width = 400;
                        abstract.height= 60;;
                        archive.label = "Archive";
                        category.prompt = "Category";
                        category.dataProvider = categoryLabels;
                        category.rowCount = categoryLabels.length;
                        category.visible = false;
                        category.includeInLayout = false;
                        category.width = 95;
                        category.height = 20;
                        rateItem.prompt = "Rate";
                        rateItem.dataProvider = rateLabels;
                        rateItem.visible = false;
                        rateItem.includeInLayout = false;
                        rateItem.width = 95;
                        rateItem.height = 20;
                        canvas.addChild(titleText);
                        canvas.addChild(clickURL);
                        canvas.addChild(itemInfo);
                        canvas.addChild(abstract);
                        canvas.addChild(hBox);
                        hBox.addChild(archive);    
                        hBox.addChild(category);
                        hBox.addChild(rateItem);
                        hBox.y = abstract.y + 60;
                        hBox.percentWidth = 80;
                        hBox.percentHeight = 80;
                        //archive.addEventListener(Event.CHANGE, toggleArchive);    
                        container.addChild(canvas);         
                   container.x = 10;
                   container.y = 10;
                   container.visible = true;
                   addChild(container);
            // Called when someone clicks on the titleLink. This function pulls the
            // origional website URL up in a seperate browser window
            private function getURL(e:MouseEvent):void {
                      var link:LinkButton = e.currentTarget as LinkButton;
                      var canvas:Canvas = link.parent as Canvas;
                      var clickURL:Text = canvas.getChildAt(1) as Text;
                      var url:URLRequest = new URLRequest(clickURL.text);
                      navigateToURL(url);
                   trace(clickURL.text);
    Where I instantiate the class. List collection is an XMLListCollection which contains XML data.
    private var createLayout:CreateLayout;
    createLayout = new CreateLayout(listCollection);

    container is from the Vbox class so I don't see that here and there might be something in there that is causing some problem.
    But I don't think that is the only problem. I think this seems like the same problem that you have going in your other post.
    I don't see anyplace that you addChild your CreateLayout instance. container has been added to your CreateLayout instance, but where is the CreateLayout instance added to some other display list.
    Also it looks like almost everything you add to canvas is set to be invisible. So without knowing what is in a Canvas instance it is hard to know what would show up anyways.

Maybe you are looking for

  • Flash video performance on Vista poor

    I have windows vista service pack 2 (32 bit) installed on a laptop with the following specs: Intel Celeron M 520 1.6Ghz with 1GB of Ram I am using Internet Explorer 9 and have Flash player version 11.7.700.169 installed. The youtube video's (which us

  • FM8 -- Acrobat7 Error: A number is out of range

    When PDFing a FM8 doc, I got an Acrobat error message: "A number is out of range." Acrobat produced a PDF, but the first page was page Zero! and the Properties of the Acrobat doc were not accessible. Not good. Searched and searched for answers, but d

  • How to Create USB boot for MBP81.0047.B27

    How to Create USB boot for MBP81.0047.B27

  • Regarding Manifest

    Hi I am having problem with Manifest file which contains list of jar's. I made a new manifest file and put it in the same folder as my java program/class. Now when i make a jar with 'jar- cvf myjar.jar manifest.mf mypgm.class' there are 2 manifest fi

  • Logic X Continually Unfreezes Tracks

    So this is never an issue in Logic 9 Pro. I would freeze a track and they would ALWAYS stay frozen, but with Logic X, sometimes Ill unfreeze a track and then later it will unfreeze ALL the frozen tracks! Its very time consuming cuz now I have to re-f