dcsimg
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Flash CS3 - Problems with buttons

  1. #1
    Junior Member
    Join Date
    Aug 2007
    Posts
    11

    Flash CS3 - Problems with buttons

    It's official: Flash CS3 has serious problems with buttons.

    I'm trying to create something very simple which really doesn't sound like something that would give me an hour (if not more) of headaches. I've googled all over for this, I can't find anything even remotely helpful for my problem.

    All I'm trying to do is a simple ****ing button which a label on it. Sounds weird? Let me explain some more: I want to make a button which is my own "artistic creation" (in this case it's a friend's creation, but that's not the problem) which has a label that I can set through ActionScript. Since this is somewhat of a... skinned button, the text needs to have a special font, and special color.

    The problem? It's impossible, or at least it seems so. The logical way of doing this would be to create a new Button (which is in actionscript the SimpleButton class), draw something in it and add an empty dynamic text field in it, and give it an instance name. Assuming the button's textfield instance name is "myLabel" and a button with the name "myButton", one would change that label using the simple action
    myButton.myLabel.text = 'Click here!!';
    But, surprise surprise, flash tells me that I'm trying to access a null or non-existing object! Oh joy! After trying various ways to access that label, i find it's just impossible because the SimpleButton class does not inherit from the DisplayObjectContainer class.

    On to eventual solution 2: turn the button into a movieclip, and use the buttonMode property to have this movieclip behave like a button. NO DICE EITHER! Why? Oh, simply because buttonMode does not register events in its child objects. What does that mean? The button does not work (well) because the Textfield, which is a child object, does not register as a hit area for the button. This causes the button to be clickable only in small parts of the button where the textfield is not overlapping the button graphic.

    And now, solution 3, which again proves ****ty: seeing the problems that arose with buttonMode, I tried making my own button with a movie clip and event listeners for the ROLL_OVER, ROLL_OUT and CLICK events. That technically works, except for one ****ing thing which pisses me off to no avail: the hand cursor does not ****ing show, because it seems the hit area is again ****ed by the label!

    Did I mention there's a failed attempt number 4? I tried skinning the Button component provided by our friends at Adobe. Unfortunately this does not allow you to change the font/color of the label.

    My friends, please, help me with this ****! I've wasted so much time on this simple manner, that I feel like tearing my hair out. I need help, or at least someone to confirm to me that this is "regular" Flash CS3 behavior! I'm going insane!

  2. #2
    Junior Member
    Join Date
    Aug 2007
    Posts
    1

    for real

    i'm just trying to make a simple website header, and suddenly i have to know how to code sh*t to make a button pull an url? I've gotten some hinky code that kind of works, but how to open in same page ?

    what the hell, Adobe - way to really screw the users.

  3. #3
    Junior Member
    Join Date
    Aug 2007
    Posts
    1

    A possible solution

    Have you tried using object.useHandCursor?

  4. #4
    Amazed and Amused Mazoonist's Avatar
    Join Date
    Mar 2006
    Location
    Northern California
    Posts
    201
    Hmmm.... doesn't seem very difficult to me. You just gotta learn the new ropes.

    For one thing, you never could address a nested dynamic textfield (or a nested MovieClip, or a nested ANYTHING) inside a button symbol, not even in AS2. That has nothing to do with Adobe. So, the best thing to do is to use a MovieClip as a button, the same way you would in AS2. That is, if you really must communicate with a nested textfield.

    There is only one thing different: If you nest a dynamic textfield, you have to make that textfield NOT react to the mouse, because there's a whole new display object system, and it works a bit differently. So how do you do that? By setting it's mouseEnabled property to false:

    Code:
    myButtonClip.myLabel.mouseEnabled = false;
    --- or ----
    Code:
    myButton.mouseChildren = false;
    Either one of those will fix it, no problem, just include it in there somewhere.

    And anyway, the only reason for nesting a DYNAMIC textfield is so that you can change the label at runtime. If you don't need to do that (you already know what the label on the button should be ahead of time), use a static textfield, and you won't even have to use either of the above lines.

    The complete thing might read something like this:
    Code:
    myButton.buttonMode = true;
    myButton.myLabel.mouseEnabled = false;
    //set a different label:
    myButton.myLabel.text = "Click Here";
    myButton.addEventListener(MouseEvent.CLICK, clickHandler);
    function clickHandler(event:MouseEvent):void {
    	trace("you clicked " + event.target.name);
    }
    All this hysteria about adobe this and that, and adobe "screwing the users" will get you nowhere. The new version of flash was well under way for several years before adobe bought it, I understand. Either you want to learn the new AS3 or you don't. If you don't, stick with 2.0. But I can tell you that from everything I've seen so far, if you do that, you'll pretty much miss out, because 3.0 rocks. It does have a bit of a learning curve, though.
    Last edited by Mazoonist; 09-01-2007 at 01:32 AM.

  5. #5
    Junior Member
    Join Date
    Dec 2004
    Posts
    5
    This solved all my problems!

    Thanks for your knowledge.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center