Highlight current Index label in list component

Hi,
I'm writhing http xml video playlist. i was took 'List' component for playlist.
if i click on label, that is working (i mean playing video & highlighting label).
but after video ending, video automatically playing but label not highlighting, How can i highlight current playing video label?
Code:
var videoURL:String = "playlist_http.xml";
var bolLoaded:Boolean;;
var intActiveVid:int;
var urlLoader:URLLoader;
var urlRequest:URLRequest;
var xmlPlaylist:XML;
var nConnection:NetConnection;
var ns:NetStream;
var video:Video = new Video();
nConnection = new NetConnection();
nConnection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
nConnection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
nConnection.connect(null);
function connectStream():void
          ns = new NetStream(nConnection);
          ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
          ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, ayncErrorHandler);
          ns.checkPolicyFile = true;
          ns.client = this;
          vidDisplay.attachNetStream(ns);
          ns.play(videoURL);
          vidDisplay.smoothing = true;
          urlRequest = new URLRequest(videoURL);
          urlLoader = new URLLoader();
          urlLoader.addEventListener(Event.COMPLETE, playlistLoaded);
          urlLoader.load(urlRequest);
function netStatusHandler(event:NetStatusEvent):void
          trace(event.info.code);
          switch (event.info.code)
                    case "NetConnection.Connect.Success" :
                              connectStream();
                              break;
                    case "NetConnection.Connect.Closed" :
                              break;
                    case "NetStream.Play.Stop" :
                              playNext();
                              break;
                    default :
function securityErrorHandler(event:SecurityErrorEvent):void
          trace("securityErrorHandler: " + event);
function ayncErrorHandler(event: AsyncErrorEvent):void
          //Nothing
//PlayList SetUp
//=====================
var listBox:List = new List();
addChild(listBox);
listBox.setSize(194, 339);
listBox.move(484,0);
function playlistLoaded(e:Event):void {
          xmlPlaylist = new XML(urlLoader.data);
          //trace(xmlPlaylist.vid[0].@src);
    for (var i:int=0;i<xmlPlaylist.vid.length();i++) {
                              listBox.addItem({label:xmlPlaylist.vid[i].attribute("desc"), data:xmlPlaylist.vid[i].@src});
                              listBox.addEventListener(Event.CHANGE, playVidlist);
                              listBox.selectedIndex = 0;
// set source of the first video but don't play it
          playVid(0, false);
          if(!bolLoaded) {
                    ns.play(videoURL);
                    bolLoaded = true;
          else{
                    ns.resume();
function playVidlist(e:Event):void
          //intActiveVid=int(String(e.currentTarget.selectedItem.data));
          ns.play(String(e.currentTarget.selectedItem.data));
          lblDescription.text = e.currentTarget.selectedItem.label;
          if(!bolLoaded) {
                    ns.play(videoURL);
                    bolLoaded = true;
          else{
                    ns.resume();
function playVid(intVid:int = 0, bolPlay = true):void {
          if(bolPlay) {
                    // play requested video
                    ns.play(String(xmlPlaylist..vid[intVid].@src));
          } else {
                    videoURL = xmlPlaylist..vid[intVid].@src;
          lblDescription.text = String(xmlPlaylist..vid[intVid].@desc);
          // update active video number
          intActiveVid = intVid;
function playNext(e:MouseEvent = null):void {
          if(intActiveVid + 1 < xmlPlaylist..vid.length()){
                              playVid(intActiveVid + 1);
function playPrevious(e:MouseEvent = null):void {
          // check if we're not and the beginning of the playlist and go back
          if(intActiveVid - 1 >= 0)
                    playVid(intActiveVid - 1);

Thankyou.... working good, but after adding next previous buttons that selection not working currectly.
if i click some label, selection is working after if i click next not working selection.
function playNext(e:MouseEvent = null):void {
           if(intActiveVid + 1 < xmlPlaylist..vid.length()){
                              playVid(intActiveVid + 1);
  listBox.selectedIndex = intActiveVid + 1;
function playPrevious(e:MouseEvent = null):void {
          if(intActiveVid - 1 >= 0)
playVid(intActiveVid - 1);
listBox.selectedIndex = intActiveVid - 1;

Similar Messages

  • Highlighted default item in list component???

    I can't seem to find how to have an item in a list component
    highlighted by default. I'm sure its right there in the docs
    staring me down, but I dont see it.
    I've found scrollToIndex method, but that doesnt seem to
    actually highlight the index item. How do I highlight an index item
    in a list in as3?
    Thanks,
    Matt

    Oh, I forgot to mention that I am using ActionScript 3.

  • Highlight color in list component

    Hi there
    Can anybody tell me how to change the color from the default blue that the list component uses for the currently selected item.
    myList.highlightColor = something; ??
    Many thanks

    - Doubleclick your list.  -> goto frame 2
    - Doubleclick the 3. (Cell Renderer Skins)  -> goto frame 2
    and you will see
    there you can doubleclick preferred over, down states...

  • List component row manipulation

    I have two questions regarding as3 list component:
    - I'd like to highlight and keep selected the item a user last selected from my list component. I've combed the live reference as well as google and must be typing the wrong search words. I can tell what label and index an item was that was selected but am not finding a way to highlight and keep highlighted the user's choice in the list component.
    - Also, I'm exploring the notion of inline buttons within a list's rows. If a user hovers their mouse over a row, a set of small buttons come up the user can click on for further functionality. This may be more of a make your own component answer but I'm exploring it nonetheless. Any thoughts or comments on this?
    Thanks!

    no something else is going on. Or perhaps you didn't explain your problem clearly.
    After servlet b calls getList() you have two servlets each having a reference to the same list
    A------\
    List
    B------/

  • Creating search field for a list component

    i have created a glossary of terms using the list component and populating it via an XML file.
    what i would like to do is create a search field that as the user types in the search bar if there are any matching entries in the list, the focus/selection jumps to that particular item in list. i don't want to clear the list just go to the item that matches.
    i would like it to be predictive so if i have these entries:
    samson
    seek
    seether
    south
    and the user types "s" in the search box to the first "s" entry in the list (samson) is selected, if they type "se" the selection jumps to the first entry with "se" in it (seek) if they type "seet" the selection jumps to "seether" and so on.
    i have absolutely no idea how to do it, but more importantly...is this possible?
    i have attached the sample files that i have been working on.
    thanks in advance

    You need the lowercase. the keyCode of the keybpardevent returns the key's uppercase charcode. So the A-key allways returns 65. Therefore convert keycode to char and to lowercase before appending after what's allready there in the field.
    To have the user not have to type the words with proper casing, convert the label to lowercase before doing the indexOf search.
    import fl.data.DataProvider;
    //-------declare vars----------------
    var firstClick:Boolean=true;
    var loader:URLLoader = new URLLoader();
    var dp:DataProvider = new DataProvider();
    var xml:XML;
    //-------add listeners---------------
    loader.addEventListener(Event.COMPLETE,onLoaded);
    glossary.lb.addEventListener(Event.CHANGE, itemChange);
    glossary.search_bar.addEventListener( FocusEvent.FOCUS_IN, clearbox );
    glossary.search_bar.addEventListener( KeyboardEvent.KEY_DOWN, onSearch );
    //-------functions--------------------
    //clears the input field when the user clicks into it for the first time
    //eliminates the need for them to highlight and delete the "type search here" text
    function clearbox( e:FocusEvent ):void {
        if (firstClick==true) {
            glossary.search_bar.text="";
            firstClick=false;
    //populate description box with definition when item is selected
    function itemChange(e:Event):void {
        glossary.ta.text=glossary.lb.selectedItem.data;
    //creates the data provider for the list based off external XML file
    //arranges the items in alphabetical order
    //populates the list
    function onLoaded(e:Event):void {
        xml=new XML(e.target.data);
        var il:XMLList=xml.channel.item;
        for (var i:uint=0; i<il.length(); i++) {
            dp.addItem({data:il.description.text()[i],label:il.title.text()[i]});
        dp.sortOn("label");
        glossary.lb.dataProvider=dp;
        glossary.ta.text="Please make a selection below";
    //dynamic search engine to locate items in the list
    function onSearch( e:KeyboardEvent ):void {
        trace( e.keyCode );
        var input:String = ( glossary.search_bar.text + String.fromCharCode( e.keyCode ).toLowerCase() );
        trace( input )
        for (var i:uint = 0; i < dp.length; i++) {
            if (dp.getItemAt(i).label.toLowerCase().indexOf(input)==0) {
                glossary.lb.selectedIndex=i;
                glossary.ta.text=glossary.lb.selectedItem.data;
                break;
            } else {
                glossary.ta.text="no matching searches";
    //-------load the xml--------------
    loader.load(new URLRequest("xml/movie1.xml"));

  • The row key or row index of a UIXCollection component is being changed outside of the components context ????

    Hello Guys,
    I'm working at this moment on implementing GANTT functionality via the <dvt:projectGantt> in my Web App :
    Rather than using data binding technology, I use a managed bean in this way :
    @ManagedBean(name="myBeanController")
    @ViewScope
    public class MyBeanController implements Serializable{
    private List<InternalTask> internalTasks;
    @EJB
    private InternalTaskDao internalTaskDao;
    //Root for tree component
    private List<TreeNode> root;
    private transient TreeModel model;
    public MyBeanController(){
         this.internalTasks = new ArrayList<InternalTask>();
    @PostConstruct
    public void init(){
         //Here I construct my TreeModel
         this.model = new ChildPropertyTreeModel(root,"collection");
    //getters and setters
    And my Component in my JSF page would be :
    <dvt:gantt value="#{myBeanController.model}></...>
    In my Browser the component seems to work properly without any problems but if I expand each node then I can see in my log :
    "<org.apache.myfaces.trinidad.component.UIXCollection> <BEA-000000> <The row key or row index of a UIXCollection component is being changed
    outside of the components context. Changing the key or index of a collection when the collection
    is not currently being visited, invoked on, broadcasting an event or processing a lifecycle method, is not valid.
    Data corruption and errors may result from this call...>"
    What's going on here ? Something with rowKeySet ?
    Thanks,
    Remy

    Hi,
    I made my tree model variable non transient and the warning message appears again.
    I implement the gantt in the same way as you did in the demo
    1st) populate ArrayList (As far as I'm concerned, it's populated via @EJB)
    2nd) create TreeModel with a helper class as in the demo which extends ChildPropertyTreeModel and implements TaskKey
    In my browser all the stuff is running fine except this warning message.
    I use for info JDev 12c
    Thanks,

  • Cannot get more than 8 item in list component

    Hi,
    I can't get more than 8 items in list component using getItemAt(), it returns null. I will search more for this but no result.
    Please Help me here to move to next step.
    Thanks
    Sureshkumar G

    If you're asking if you can overall, yes you can:
    http://help.adobe.com/en_US/as3/components/WS5b3ccc516d4fbf351e63e3d118a9c65b32-7f41.html
    If you're asking if you can do this in the same context, off-screen, no you still get the same error as the .enabled property.
    I hate to throw a hunch but I feel as though Adobe is employing something I'm used to in native iOS programming (Apple Devices). In lists they have something called "dequeue". It's the reason an extremely long list scrolls smoothly. What it does is render ONLY the rows that are in view. When a row is about to scroll off view it deallocates it from memory and then recreates the next row. They do this so you only ever have the current amount of viewable rows in memory and it speeds up scrolling. Although, I can make property changes to items in an iOS list that's off-screen so they don't have this issue ;(.  Just food for thought.
    I'd submit it to the bugbase and see what Adobe states. They may say they intend you to get the item in view, alter it and then go back to your previous position. That would be silly but at most I can tell you I definitely get errors trying to access an element outside my view. They're probably not used to items needing visual toggles when you can't even see them.
    edit:
    On a further note I tried the scrollToIndex() method, tried to disable, that much worked fine. The second I then scrolled back to the previously selected index the list screwed up.
    I even daisy chained functions a second apart (30 frames worth of wait). I scrolled down and that worked so I waited 1 second. I disabled the visible item I wanted to and that worked so I waited another second. I scrollToIndex(0) to get back to the top of the list, the list blew up. Random items (several items) were disabled and the one that I explicitly disabled was enabled.

  • Selecting multiple rows from List-component

    Hi
    Could someone give me an example how to programmatically select multiple rows from List-component?
    I know that this selects one row: lst_example.selectedIndex = 1;
    But how about selectin indexes 1,2 and 4 for example?

    selectedIndices
    A Vector of ints representing the indices of the currently selected item or
    items...
    var si:Vector.<int> = new Vector.<int>;
    si.push(1);
    si.push(2);
    si.push(4);
    list.selectedIndices = si;

  • CS4 List component strange behavior

    On a List component I am using the bottom 'scroll down' button's hotspot is only the very top of the button. This is when the y scale of the component is set to 293. When I set the y scale to 280 the hotspot is the entire button. The top 'scroll up' button works fine and so does the scroll bar. Any ideas?

    For some reason, for all nodes beyond the first, when the anonymous new instance of BankingStatementTransaction is added to the list, the data in the new instance is identical to the first node, even though the transNode passed to the BankingStatementTransaction
    Constructor has a new set of data.
    The iterator variable in a For/Each is the Current property of the IEnumerator object that implements the iteration.  It is a local copy of the collection item.  Therefore your BankingTransactionStatement object is being created from the one
    local copy, so they will be all the same.  Which item in the collection is undefined, but you seem to have proved it is the first. See:
    http://msdn.microsoft.com/en-us/library/5ebk1751.aspx
    You should either clone the transnode (if you want to use a new object) or use a For/Next instead of For/Each and access the collection item directly, using the index.

  • How to update a large (over 4 million item) List(Of Byte) quickly by altering indexes contained in a Dictionary(Of Integer, Byte) where the Dictionaries keys are the indexes in the List(Of Byte) that need to be changed to the values for those indexes?

       I'm having some difficulty with transferring images from a UDP Client to a UDP Server. The issue is receiving the bytes necessary to update an original image sent from the Client to the Server and updating the Servers List(Of Byte) with the
    new bytes replacing bytes in that list. This is a simplex connection where the Sever receives and the Client sends to utilize the least amount of bandwidth for a "Remote Desktop" style application where the Server side needs image updates of whatever
    occurs on the Client desktop.
       So far I can tranfer images with no issue. The images can be be any image type (.Bmp, .Gif, .JPeg, .Png, etc). I was working with sending .JPeg's as they appear to be the smallest size image when a Bitmap is saved to a memory stream as type
    .JPeg. And then I am using GZip to compress that byte array again so it is much smaller. However on a loopback on my NIC the speed for sending a full size screen capture is not very fast as the Server updates fairly slowly unless the Clients screen capture
    Bitmap is reduced in size to about 1/3'd of the original size. Then about 12000 bytes or less are sent for each update.
       Due to .JPeg compression I suppose there is no way to get the difference in bytes between two .JPegs and only send those when something occurs on the desktop that alters the desktop screen capture image. Therefore I went to using .Bmp's as each
    .Bmp contains the same number of bytes in its array regardless of the image alterations on the desktop. So I suppose the difference in bytes from a second screen capture and an inital screen capture are what is different in the second image from the initial
    image.
       What I have done so far is save an initial Bitmap of a screen capture using a memory stream and saving as type .Bmp which takes less than 93 milliseconds for 4196406 bytes. Compressing that takes less than 118 milliseconds to 197325 bytes for
    the current windows on the desktop. When that is done PictureBox1 is updated from nothing to the captured image as the PictureBox's background image with image layout zoom and the PictureBox sized at 1/2 my screens width and 1/2 my screens height.
       Then I save a new Bitmap the same way which now contains different image information as the PictureBox is now displaying an image so its back color is no longer displayed (solid color Aqua) and the cursor has moved to a different location. The
    second Bitmap is also 4196406 in bytes and compressed it was 315473 bytes in size.
       I also just found code from this link Converting a Bitmap to a Byte Array (and Byte Array to Bitmap) which gets a byte array
    directly from a Bitmap and the size of that is 3148800 for whatever is full screen captured on my laptop. So I should be able to work with smaller byte arrays at some point.
       The issue I'm having is that once the Client sends an image of the desktop to the Server I only want to update the server with any differences occuring on the Clients desktop. So what I have done is compare the first screen captures bytes (stored
    in a List(Of Byte)) to the second screen captures bytes (stored in a List(Of Byte)) by using a For/Next for 0 to 4196405 where if a byte in the first screen captures List is not equal to a byte in the second screen captures List I add the index and byte of
    the second screen captures list to a Dictionary(Of Integer, Byte). The Dictionary then only contains the indexes and bytes that are different between the first screen capture and second screen capture. This takes about 125 milliseconds which I think is pretty
    fast for 4196406 byte comparison using a For/Next and adding all the different bytes and indexes for each byte to a Dictionary.
        The difference in Bytes between the inital screen capture and the second screen capture is 242587 as an example which changes of course. For that amount of bytes the Dictionary contains 242587 integers as indexes and 242587 bytes as different
    bytes totaling 485174 bytes for both arrays (keys, values).  Compressed the indexes go from 242587 to 43489 bytes and the values go from 242587 to 34982 bytes. Which means I will have to send 78, 481 bytes from the Client to the Server to update the display
    on the server. Quite smaller than the original 4196406 bytes of the second Bitmap saved to type .Bmp or the compressed size of that array which was 315473 bytes. Plus a few bytes I add as overhead so the server knows when an image array ends and how many packets
    were sent for the array so it can discard complete arrays if necessary since UDP is lossfull although probably not so much in current networks like it may originally have been when the internet started.
        In reality the data from the Client to the Server will mostly be the cursor as it moves and updating the Server image with only a few hundred bytes I would imagine at a time. Or when the cursor selects a Button for example and the Buttons
    color changes causing those differences in the original screen capture.
       But the problem is if I send the Dictionaries Indexes and Bytes to the Server then I need to update the original Bitmap List(Of Byte) on the server by removing the Bytes in the received informations Index locations array from the Servers Bitmap
    List(Of Byte) and replacing those Bytes with the Bytes in the received informations Byte array. This takes so long using a For/Next for however many indexes are in the received informations Index array to update the Bitmap List(Of Byte) on the server using
    "Bmp1Bytes.RemoveAt(Index As Integer)" followed by "Bmp1Bytes.Insert(Index As Integer, Item As Byte)" in the For/Next.
        I've tried various For/Next statements including using a new List(Of Byte) with If statements so If the the integer for the For/Next ='s the Key in a Dictionary(Of Integer, Byte) using a Counter to provide the Dictionaries Key value then
    the Dictionaries byte value will be added to the List(Of Byte) and the counter will increas by one Else the List(Of Byte) adds the original "Bmp1Bytes" byte at that index to the new List(Of Byte). This takes forever also.
       I also tried the same For/Next adding to a new Dictionary(Of Integer, Byte) but that takes forever too.
       I think I could use RemoveRange and AddRange to speed things up. But I don't know how to retrieve a contiguous range of indexes in the received indexes that need to be updated in the servers "Bmp1Bytes" List(Of Byte) from the received
    array of indexes and bytes which are in a Dictionary(Of Integer, Byte).  But I believe this would even be slower than some realistic method for replacing all Bytes in a List(Of Byte) when I have the indexes that need to be replaced and the bytes to replace
    them with.
       Even if I just used AddRange on a new List(Of Byte) to add ranges of bytes from the original "Bmp1Bytes" and the changes from the Dictionary(Of Integer, Byte) I think this would be rather slow. Although I don't know how to do that
    by getting contiguous ranges of indexes from the Dictionaries keys.
       So I was wondering if there is some method perhaps using Linq or IEnumerable which I've been unable to figure anything out which could do this.
       I do have some copy and pasted code which I don't understand how it works that I am using which I would guess could be altered for doing something like this but I can't find information that provides how the code works.  Or even if I did
    maybe I can't understand it. Like the code below which is extremely fast.
       Dim strArray() As String = Array.ConvertAll(Of Integer, String)(BmpComparisonDict.Keys.ToArray, Function(x) x.ToString())
    La vida loca

    Monkeyboy,
    That was quite a bit to read, but still a bit unclear. Could you put a specific list of goals/questions, asked in the smallest possible form?
    It seems like either you're making a program that monitors activity on your computer, or you're writing some kind of remote pc app.
    When you do get your bytes from using lockbits, keep in mind all the files header info would be lost. I think retaining the header info is worth the extra bytes.
    The other, thing: I'm not sure if you're taking 32bpp screen shots, but also keep in mind that the "whole desktop" is the final destination for blended graphics, if that makes sense. What I mean is that there is no need to capture an "alpha"
    channel for a desktop screenshot, as alpha would always be 255, this could save you 1 byte per pixel captured... Theres nothing "behind" the desktop, therefore no alpha, and every window shown above the desktop is already blended. I suggest using
    24Bpp for a full screen capture.
    Your X,Y information for the mouse could be stored as UINT16, this would save you a measly 2 bytes per location update/save.
    When you update your byte arrays, maybe you can turn the array into a stream and write to whatever index, however many bytes, that should prevent a "Shift" of bytes, and instead overwrite any bytes that "get in the way".
    ex
    Dim example As String = "This is an example."
    Dim insertString As String = "was"
    Dim insertBytes As Byte() = System.Text.Encoding.ASCII.GetBytes(insertString)
    Dim bytes As Byte() = System.Text.Encoding.ASCII.GetBytes(example)
    Dim modifiedBytes As Byte() = {}
    Using ms As New System.IO.MemoryStream(bytes)
    ms.Position = 5
    ms.Write(insertBytes, 0, 3)
    modifiedBytes = ms.ToArray
    End Using
    Dim newString As String = System.Text.Encoding.ASCII.GetString(modifiedBytes)
    'Notice how below there isn't the word "is" anymore, and that there isn't a
    'space.
    'This demonstrates that you overwrite existing data, versus shifting everything to
    'the right.
    'Returns: This wasan example.
    MsgBox(newString)
    “If you want something you've never had, you need to do something you've never done.”
    Don't forget to mark
    helpful posts and answers
    ! Answer an interesting question? Write a
    new article
    about it! My Articles
    *This post does not reflect the opinion of Microsoft, or its employees.
    Well it's too much to read. I was really tired when I wrote it. Even the below is too much to read but perhaps gets the point across of what I would like to do which I think
    Joel Engineer may have answered but I'm not sure. As I'm still too tired to understand that yet and research what he said in order to figure it out yet.
    But maybe the code below can provide the concept of the operation with the comments in it. But seeing as how I'm still tired it may be confused.
    Option Strict On
    Imports System.Windows.Forms
    Imports System.IO
    Imports System.IO.Compression
    Imports System.Drawing.Imaging
    Imports System.Runtime.InteropServices
    Public Class Form1
    Dim Bmp1Bytes As New List(Of Byte)
    Dim Bmp1BytesCompressed As New List(Of Byte)
    Dim Bmp2Bytes As New List(Of Byte)
    Dim BmpComparisonDict As New Dictionary(Of Integer, Byte)
    Dim BmpDifferenceIndexesCompressed As New List(Of Byte)
    Dim BmpDifferenceBytesCompressed As New List(Of Byte)
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    SomeSub()
    End Sub
    Private Sub SomeSub()
    ' Pretend this code is in UDP Client app. A screen capture is performed of the desktop. Takes about 90 milliseconds.
    Bmp1Bytes.Clear()
    Using BMP1 As New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)
    Using g1 As Graphics = Graphics.FromImage(BMP1)
    g1.CopyFromScreen(0, 0, 0, 0, BMP1.Size)
    Cursor.Draw(g1, New Rectangle(Cursor.Position.X, Cursor.Position.Y, Cursor.Size.Width, Cursor.Size.Height))
    Using MS As New MemoryStream
    BMP1.Save(MS, System.Drawing.Imaging.ImageFormat.Bmp)
    Bmp1Bytes.AddRange(MS.ToArray)
    End Using
    End Using
    End Using
    Bmp1BytesCompressed.AddRange(Compress(Bmp1Bytes.ToArray))
    ' UDP Client app sends Bmp1BytesCompressed.ToArray to UDP Server which is the entire image of the desktop that the UDP
    ' Client is on. This image takes awhile to send since compressed it is about 177000 bytes from over 4000000 bytes.
    ' I will be using different code just to get the bytes from the actual Bitmap in the future. That is not important for now.
    ' Pretend the UDP Server has received the bytes, decompressed the array received into a List(Of Byte) and is displaying
    ' the image of the UDP Clients desktop in a PictureBox.
    ' Now the image on the UDP Clients desktop changes due to the mouse cursor moving as an example. Therefore a new Bitmap
    ' is created from a screen capture. This takes about 90 milliseconds.
    Bmp2Bytes.Clear()
    Using BMP2 As New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)
    Using g1 As Graphics = Graphics.FromImage(BMP2)
    g1.CopyFromScreen(0, 0, 0, 0, BMP2.Size)
    Cursor.Draw(g1, New Rectangle(Cursor.Position.X, Cursor.Position.Y, Cursor.Size.Width, Cursor.Size.Height))
    Using MS As New MemoryStream
    BMP2.Save(MS, System.Drawing.Imaging.ImageFormat.Bmp)
    Bmp2Bytes.AddRange(MS.ToArray)
    End Using
    End Using
    End Using
    ' Now I have the original images bytes in Bmp1Bytes and the new images bytes in Bmp2Bytes on the UDP Client. But I don't
    ' want to send all of the bytes in Bmp2Bytes to the UDP Server. Just the indexes of and the bytes that are different in
    ' Bmp2Bytes from Bmp1Bytes.
    ' This takes less than 100 milliseconds for what I've tested so far where over 500000 bytes in Bmp2Bytes are different
    ' than the bytes in Bmp1Bytes. Usually that amount would be much less. But during testing I was displaying the image
    ' from Bmp1 bytes in a PictureBox so a large amount of data would change between the first screen shot, the PictureBox
    ' then displaying an image on the same PC and then the second screen shot.
    BmpComparisonDict.Clear()
    For i = 0 To Bmp1Bytes.Count - 1
    If Bmp1Bytes(i) <> Bmp2Bytes(i) Then
    BmpComparisonDict.Add(i, Bmp2Bytes(i))
    End If
    Next
    ' So now I have all the difference bytes and their indexes from Bmp2Bytes in the BmpComparisonDict. So I compress
    ' the indexes into on List and the Bytes into another List.
    BmpDifferenceIndexesCompressed.Clear()
    BmpDifferenceBytesCompressed.Clear()
    BmpDifferenceIndexesCompressed.AddRange(Compress(BmpComparisonDict.Keys.SelectMany(Function(d) BitConverter.GetBytes(d)).ToArray()))
    BmpDifferenceBytesCompressed.AddRange(Compress(BmpComparisonDict.Values.ToArray))
    ' Now pretend the UDP Client has sent both those arrays to the UDP Server which has added both decompressed arrays
    ' to a Dictionary(Of Integer, Byte). And the server has the original image decompressed bytes received in a List
    ' called Bmp1Bytes also.
    ' This is where I am stuck. The UDP Server has the Dictionary. That part was fast. However there is no
    ' fast method I have found for creating a new List(Of Byte) where bytes in the originally received List(Of Byte) that
    ' do not have to be altered are placed into a new List(Of Byte) except for the indexes listed in the
    ' Dictionary(Of Integer, Byte) that need to be placed into the appropriate index locations of the new List(Of Byte).
    ' The below example for doing so is exceptionally slow. Pretend UpdateDictionary has all of the decompressed indexes
    ' and bytes received by the UDP Server for the update contained within it.
    Dim UpdateDictionary As New Dictionary(Of Integer, Byte)
    Dim UpdatedBytes As New List(Of Byte)
    Dim Counter As Integer = 0
    For i = 0 To Bmp1Bytes.Count - 1
    If i = UpdateDictionary.Keys(Counter) Then ' Provides the index contained in the Keys for the Dictionary
    UpdatedBytes.Add(UpdateDictionary.Values(Counter))
    Counter += 1
    If Counter > UpdateDictionary.Count - 1 Then Counter = 0
    Else
    UpdatedBytes.Add(Bmp1Bytes(i))
    End If
    Next
    ' So what I'm trying to do is find an extremely fast method for performing something similar to what the
    ' above operation performs.
    End Sub
    Private Function Compress(BytesToCompress() As Byte) As List(Of Byte)
    Dim BytesCompressed As New List(Of Byte)
    Using compressedStream = New MemoryStream()
    Using zipStream = New GZipStream(compressedStream, CompressionMode.Compress)
    zipStream.Write(BytesToCompress, 0, BytesToCompress.Count)
    zipStream.Close()
    BytesCompressed.AddRange(compressedStream.ToArray)
    End Using
    End Using
    Return BytesCompressed
    End Function
    Private Function Decompress(BytesToDecompress() As Byte) As List(Of Byte)
    Dim BytesDecompressed As New List(Of Byte)
    Using DecompressedStream = New MemoryStream()
    Using zipStream = New GZipStream(DecompressedStream, CompressionMode.Decompress)
    zipStream.Write(BytesToDecompress, 0, BytesToDecompress.Count)
    zipStream.Close()
    BytesDecompressed.AddRange(DecompressedStream.ToArray)
    End Using
    End Using
    Return BytesDecompressed
    End Function
    End Class
    La vida loca

  • How can I select an item from a list component with a seperate button

    This is a repost, I decided it'd probably be better here than
    in the general discussion board. I will try to delete the other
    one.
    Hello Everyone,
    This is my first post here. I am trying to figure out how to
    select an item within a list component with a button. This button
    is calling a function. I have searched for the past 3 hours online
    and I can't find anything about it. I thought perhaps I could set
    the selectedItem parameter, but that is read only, and I believe it
    returns an object reference rather than something like a number so
    even if i could set it, it would be pointless. I also found a get
    focus button, thought that may lead me somewhere, but I think that
    is for setting which component has focus currently as far as typing
    in and things like that. I am lost.
    Basically I am looking for a way to type this
    myList.setSelected(5); where 5 is the 5th item in the list.
    Any help would be much appreciated.

    Never mind found it. It is the property called selectedIndex
    and it is writable

  • How to populate list component via xml file?

    There is a TextArea component that should show the name and
    the description of the item selected in the list component. But I
    dont know how to populate list with external XML and what should be
    the coding in flash as well as what should be written in the XML.
    Please help.

    Here's an xml file listing a couple of brother comedy teams:
    <?xml version="1.0" encoding="UTF-8"?>
    <team>
    <brothers>
    <Marx>
    <name>Groucho</name>
    <name>Chico</name>
    <name>Harpo</name>
    <name>Zeppo</name>
    <name>Gummo</name>
    </Marx>
    <Howard>
    <name>Moe</name>
    <name>Curly</name>
    <name>Shemp</name>
    </Howard>
    </brothers>
    </team>
    Open a new .fla and save it in the same folder as the .xml
    file. Place a List Component on the Stage and name it (in this
    case, "comicTeams_list"). In the first frame write the following
    ActionScript:
    //create XML object and load external xml file
    var broList:XML = new XML();
    broList.ignoreWhite = true;
    broList.onLoad = processList; // this is a function that will
    be written below
    broList.load("populateList.xml");
    function processList(success:Boolean):Void{
    if(success){
    loadList();
    }else{
    trace("Load failure");
    function loadList():Void{
    var broName:String;
    var listEntries =
    broList.firstChild.childNodes[0].childNodes[0].childNodes.length;
    for(var i:Number = 0;i<listEntries;i++){
    broName =
    broList.firstChild.childNodes[0].childNodes[0].childNodes
    .childNodes[0].nodeValue;
    trace(broName);
    comicTeams_list.addItem(broName);
    //to make something happen when you click on a name in the
    List, create a Listener and function
    var broListListener:Object = new Object();
    broListListener.change = someAction; //"someAction" is a
    function to be written shortly
    //add the Listener to the List
    comicTeams_list.addEventListener("change", broListListener);
    function someAction(evtObj:Object):Void{
    var pickedBrother:String = evtObj.target.selectedItem.label;
    //write actions here, referencing pickedBrother variable
    The names of the Marx Brothers will appear in the box.
    This is written in AS2. When you post a question, it's a good
    idea include which version of ActionScript you're using.

  • How do you determine the index of a List Iterator?

    I understand where the indices of a List Iterator in relation to the elements.
    Element(0) Element(1) Element(2) ... Element(n)
    ^ ^ ^ ^ ^
    Index: 0 1 2 3 n+1
    But I don't know how to return an index of a List Iterator.
    I'm trying to build a nextIndex and previousIndex method, which would return the index of the particular List Iterator of either the next() or previous() functions had been performed.
    Here is the rest of the code:
    public class List<E>
          Constructs an empty linked list.
       public List()
          first = null;
          last = null;
          size = 0;
          Returns the first element in the linked list.
          @return the first element in the linked list
       public E getFirst()
          if (first == null)
             throw new ListException("getFirst() called on empty list");
          return first.data;
          Removes the first element in the linked list.
          @return the removed element
       public E removeFirst()
          if (first == null)
             throw new ListException("removeFirst called on an empty list");
          E element = first.data;
          Node tmp = first;
          if (last == first)
              last = null;
          first = first.next;
          if (first != null)
              tmp.next = null;
              first.previous = null;
          size--;     
          return element;
          Adds an element to the front of the linked list.
          @param element the element to add
       public void addFirst(E element)
          Node newNode = new Node();
          newNode.data = element;
          newNode.next = first;
          if (first != null)
              first.previous = newNode;
          else
              last = newNode;
          first = newNode;
          size++;
          Returns an iterator for iterating through this list.
          @return an iterator for iterating through this list
       public ListIterator listIterator()
          return new ListIterator();
       public int size()
           return size;
       private Node first;
       private Node last;
       private int size;
       private class Node
          public E data;
          public Node next;
          public Node previous;
       private class ListIterator implements ListIteratorAPI<E>
             Constructs an iterator that points to the front
             of the linked list.
          public ListIterator()
             position = null;
             previous = null;
             Moves the iterator past the next element.
             @return the traversed element
          public E next()
             if (!hasNext())
                throw new ListException("Next() called at the end of the list");
             previous = position; // Remember for remove
             if (position == null)
                position = first;
             else
                position = position.next;
             return position.data;
             Moves the iterator before the element.
             @return the traversed element
          public E previous()
             if (!hasPrevious())
                throw new ListException("previous() called at the beginning of the list");
             previous = position; // Remember for remove
             if (position == null)
                position = last;
             else
                position = position.previous;
             return position.data;
             Tests if there is an element after the iterator
             position.
             @return true if there is an element after the iterator
             position
          public boolean hasNext()
             if (position == null)
                return first != null;
             else
                return position.next != null;
             Tests if there is an element before the iterator
             position.
             @return true if there is an element before the iterator
             position
          public boolean hasPrevious()
             if (position == null)
                return last != null;
             else
                return position.previous != null;
             Adds an element before the iterator position
             and moves the iterator past the inserted element.
             @param element the element to add
          public void add(E element)
             if (position == null)
                addFirst(element);
                position = first;
             else
                Node newNode = new Node();
                newNode.data = element;
                newNode.next = position.next;
                newNode.next.previous = newNode;
                position.next = newNode;
                newNode.previous = position;
                position = newNode;
                size++;
             previous = position;        
             Removes the last traversed element. This method may
             only be called after a call to the next() method.
          public void remove()
             if (previous == position)
                throw new IllegalStateException();
             if (position == first)
                removeFirst();
             else
                Node tmp = position;
                previous.next = position.next;
                if (position.next != null)
                    position.next.previous = previous;
                tmp.next = tmp.previous = null;
                position.previous = previous;
                size--;
             position = previous;
             Sets the last traversed element to a different
             value.
             @param element the element to set
          public void set(E element)
             if (position == null)
                throw new ListException("set calls on a null node");
             position.data = element;
          private Node position;
          private Node previous;
    }All I have for nextIndex() is this:
    public int nextIndex(){
          if (this.hasNext() == false)
               return size;
               else
                  this.next();
                  //what goes after this?
          }What am I missing? How do I return an index of a List Iterator?

    I wouldn't have a clue how to get the array-index from the current element of an iterator... and I don't think it is possible simply because not all implementations of list have a useful index... and certainly an index would be meaningless when iteratring a hashmap... so iterator doesn't support indexes.
    Isn't nextIndex an optional operation? ... And one which makes frag all sense for a linked list?[java.util.ListIterator|http://java.sun.com/javase/6/docs/api/java/util/ListIterator.html]
    ~

  • Help with a vertical scroll bar issue with a List component

    hi. i have a basic <s:list> that uses an XMLListCollection as it's data provider and a very basic itemrenderer. when a row in the list is clicked a function gets the list.selectedIndex then populates some text fields with more xml data. that all works fine.. the problem i have is that the vertical scroll bar on the list seems to be "clickable" - just like a row in the list. the scroll bar scrolls normally but when it's clicked the selectedIndex becomes -1 which is not helpful b/c the value -1 is passed to the XMLListCollection.
    any ideas? cheers.

    thanks but still problematic...surely the <s:List> component shouldn't return a value when the scrollbar thumb is clicked? i created a very basic list (see below) and made the list dimensions short enough so that there is a vertical scrollbar and found that when the scrollbar thumb is clicked the trace(event.currentTarget.selectedIndex) returns a number. that's annoying b/c i just want a selectedIndex value for a row that is clicked not the scrollbar.
    any ideas to get around? cheers
    <fx:Script>
    <![CDATA[
    protected function list1_clickHandler(event:MouseEvent):void
    trace(event.currentTarget.selectedIndex);
    ]]>
    </fx:Script>
    <s:List x="162" click="list1_clickHandler(event)" y="276" labelField="@label" width="144" height="153">
    <s:dataProvider>
    <s:XMLListCollection>
    <fx:XMLList xmlns="">
    <node label="one"/>
    <node label="two"/>
    <node label="three"/>
    <node label="four"/>
    <node label="five"/>
    <node label="six"/>
    <node label="seven"/>
    <node label="eight"/>
    <node label="nine"/>
    <node label="ten"/>
    <node label="eleven"/>
    </fx:XMLList>
    </s:XMLListCollection>
    </s:dataProvider>
    </s:List>

  • Need help displaying images with List component for Flash CS4 (ActionScript 3.0)

    Hi folks:
    I am an inexperienced user of Flash CS4 Pro (v10.0.2). I am attempting to use the List component with ActionScript 3.0 to make a different image display when a user clicks each item in a list.
    I did find a tutorial that showed me how to make different text display using a dynamic text box and the following ActionScript:
    MyList.addEventListener(Event.CHANGE, ShowSelectedItem);
    function ShowSelectedItem(event:Event):void {
        ListText.text=MyList.selectedItem.data;
    ...where My List is the instance of the List component and ListText is the dynamix text box. In this case, the user clicks an item in the list, defined by the label value in the dataProvider parameter of the List component, and text displays as defined in the data value in the dataProvider parameter.
    However, as I mentioned to start, what I really want to do is make images display instead of text. Can anyone provide me the steps to do this?
    I appreciate your help (in advance)!!
    Cindy

    Hi...thanks for responding! I was planning on using images from the Library, but if there is a better way to do it, I'm open. So far, I just have text in the data property. This is part of my problem. I don't know what I need to put in the data value for an image to display. Do I just put the image file name and Flash will know to pull it from the Library? Do I need to place the images on the stage on different frames? I apologize for the "stupid user" questions, but as you can tell, I'm a newbie.
    Appreciate your patience and any help you can offer!
    Cindy

Maybe you are looking for