WEB Time to learn a new language v. Flex 3

Discussion in 'OT Technology' started by brds, Jan 8, 2010.

  1. brds

    brds OT Supporter

    Joined:
    Jun 26, 2006
    Messages:
    17,642
    Likes Received:
    13
    Location:
    Atlanta
    Anybody ever used it? I'm taking an "Advanced Web Applications" class which is mostly concentrated on Flex 3. Anybody know of any good tutorial sites for it? I tried to youtube it, but i found nothing.
     
  2. intrktevo

    intrktevo New Member

    Joined:
    Oct 18, 2004
    Messages:
    5,781
    Likes Received:
    0
    Location:
    UCF
  3. brds

    brds OT Supporter

    Joined:
    Jun 26, 2006
    Messages:
    17,642
    Likes Received:
    13
    Location:
    Atlanta
    I have two buttons ("button 1" & "button 2") and a mx:label object.

    I need to make sure the user clicks the first button first and then the second one. If the user does this, "goodjob.png" should show up in the label. If the user clicks button 2 before button 1, then "badjob.png" should show up in the label. For extra credit, we need to figure out how to play sound for each of the two possible outcomes. Here's what I got so far:

    It kinda works, but instead of showing the image, it puts out the actual text for the <img />.

    Any thoughts, hints, pointers?
     
  4. TrenT

    TrenT OT Supporter

    Joined:
    Aug 27, 2002
    Messages:
    10,538
    Likes Received:
    27
    Location:
    NYC

    Create an array called clickHistory. When button one is clicked push "button one" into the array, and when button two is clicked push "button two" into the array. Then in each of the button's functions call a testOrder() function that does this:

    private function testOrder():void
    {
    if(clickHistory.length > 2)
    {
    var tmpString:String = clickHistory.shift();
    tmpString = null
    }
    if(clickHistory.indexOf("button one") < clickHistory.indexOf("button two"))
    {
    //successful order
    clickHistory = [];
    } else
    {
    //unsuccessful order or only one button clicked, add another conditional here to separate the two possibilities
    }
    }

    The first conditional in that test function will make sure that there are only two values (the previous two clicks) being tested.

    :dunno:
     
  5. brds

    brds OT Supporter

    Joined:
    Jun 26, 2006
    Messages:
    17,642
    Likes Received:
    13
    Location:
    Atlanta
    The code that I have now works, it just outputs

    Code:
    <img src="...." />
    instead of the actual image. How do i get the actual image to show up instead of the html code?
     
  6. TrenT

    TrenT OT Supporter

    Joined:
    Aug 27, 2002
    Messages:
    10,538
    Likes Received:
    27
    Location:
    NYC
    :confused:

    Cant seem to get it to work either. From searching I've read that you can put an html image in a Label field because it isn't multiline. I can't get it to work in a text field either though.

    I've tried setting the initialize property to an actionscript function that defines the html text and that doesn't work either. Even tried several methods of canceling out the quotation marks in the img tag. I'm stumped..
     
  7. brds

    brds OT Supporter

    Joined:
    Jun 26, 2006
    Messages:
    17,642
    Likes Received:
    13
    Location:
    Atlanta
    Introductory assignment > us :wtc:
     
  8. TrenT

    TrenT OT Supporter

    Joined:
    Aug 27, 2002
    Messages:
    10,538
    Likes Received:
    27
    Location:
    NYC
    Truth.


    I know actionscript pretty well..just now getting into using flex components. Working on a form with validation right now
     
  9. TrenT

    TrenT OT Supporter

    Joined:
    Aug 27, 2002
    Messages:
    10,538
    Likes Received:
    27
    Location:
    NYC
    does it have to be an html loaded image or can you get by with embedding the images and toggling their visibility?
     
  10. brds

    brds OT Supporter

    Joined:
    Jun 26, 2006
    Messages:
    17,642
    Likes Received:
    13
    Location:
    Atlanta
    I was just about to post this... I'm not sure how to do it though. Any help?
     
  11. brds

    brds OT Supporter

    Joined:
    Jun 26, 2006
    Messages:
    17,642
    Likes Received:
    13
    Location:
    Atlanta
    O shit, i think i'm on to something

    Edit... fuck, it's kinda working. The logic is fucked up somewhere though.
     
  12. TrenT

    TrenT OT Supporter

    Joined:
    Aug 27, 2002
    Messages:
    10,538
    Likes Received:
    27
    Location:
    NYC
  13. brds

    brds OT Supporter

    Joined:
    Jun 26, 2006
    Messages:
    17,642
    Likes Received:
    13
    Location:
    Atlanta
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
        
        <mx:Script>
            <![CDATA[
                import mx.controls.Alert
                public var firstButtonClicked:Boolean = false;
                
                public function sayFirstGreeting(): void
                {
                    if (firstButtonClicked == false)
                    {
                        firstButtonClicked = true;
                        ox.visible = false;
                        tx.visible = false;
                        tc.visible = false;
                        oc.visible = true;
                        status.text = 'Now press the second button';
                    }
                    else
                    {
                        tx.visible = false;
                        tc.visible = false;
                        oc.visible = false;
                        ox.visible = true;
                        status.text = 'You already pressed this button.  Just press the second one!';
                    }
                }
                
                public function saySecondGreeting(): void
                {
                    if (firstButtonClicked == true)
                    {
                        oc.visible = false;
                        tx.visible = false;
                        ox.visible = false;
                        tc.visible = true;
                        status.text = 'Congratulations! (Your information has been reset)';
                    }
                    else
                    {
                        oc.visible = false;
                        tc.visible = false;
                        ox.visible = false;
                        tx.visible = true;
                        status.text = 'You didn\'t press the first button.';
                    }
                    firstButtonClicked = false;
                }
            ]]>
        </mx:Script>
    
        <mx:HBox>
            <mx:Button x="69.5" y="53" id="FirstButton" label="Press Me First" click="sayFirstGreeting()" />
            <mx:Button x="61.5" y="115" id="SecondButton" label="Press Me Second" click="saySecondGreeting()" />
            <mx:Label id="status" text="Press the first button."/>
            <mx:Image id="oc" source="http://2007.ispace.ci.fsu.edu/~ama04e/spring2010/lis5367/assgn1/img/1check.gif" visible="false" />
            <mx:Image id="ox" source="http://2007.ispace.ci.fsu.edu/~ama04e/spring2010/lis5367/assgn1/img/1x.gif" visible="false" />
            <mx:Image id="tc" source="http://2007.ispace.ci.fsu.edu/~ama04e/spring2010/lis5367/assgn1/img/2check.gif" visible="false" />
            <mx:Image id="tx" source="http://2007.ispace.ci.fsu.edu/~ama04e/spring2010/lis5367/assgn1/img/2x.gif" visible="false" />
        </mx:HBox>
    </mx:Application>
    
    
    I got this working, but i just dont like how the images show up in different spots. Is there a way i can make them all float left, or show in the center?
     
  14. TrenT

    TrenT OT Supporter

    Joined:
    Aug 27, 2002
    Messages:
    10,538
    Likes Received:
    27
    Location:
    NYC
    Just define the x and y position of the image files so they're all equal
     
  15. brds

    brds OT Supporter

    Joined:
    Jun 26, 2006
    Messages:
    17,642
    Likes Received:
    13
    Location:
    Atlanta
    i tried adding an x="100" and y="100" and the image is still in the same spot. :confused:
     
  16. brds

    brds OT Supporter

    Joined:
    Jun 26, 2006
    Messages:
    17,642
    Likes Received:
    13
    Location:
    Atlanta
    Tried working on the audio... i put this into the mx:script:

    Code:
    public var rightSound:Sound = new Sound(new URLRequest("http://2007.ispace.ci.fsu.edu/~ama04e/spring2010/lis5367/assgn1/media/right.wav"));
    public var wrongSound:Sound = new Sound(new URLRequest("http://2007.ispace.ci.fsu.edu/~ama04e/spring2010/lis5367/assgn1/media/wrong.wav"));
    and called wrongSound.play(); in one of the functions... didn't work :wtc:
     

Share This Page