dcsimg
A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: [RESOLVED] Semi-Transparent Textfield Background

  1. #1
    LukewarmSteak - Jordan Embury
    Join Date
    Jul 2009
    Location
    Toronto Ontario Canada
    Posts
    24

    resolved [RESOLVED] Semi-Transparent Textfield Background

    i've created a textfield dynamically and i have filled the background with a colour - however its not good enough! i want it to be semi transparent

    i've used

    PHP Code:
    my_mc.background true;
    my_mc.backgroundColor 0x675F2E

  2. #2
    lemon juice hurts your eyes florianvanthuyn's Avatar
    Join Date
    Jul 2005
    Location
    Merelbeke, Belgium
    Posts
    546
    try using:
    PHP Code:
    my_mc.graphics.beginFill(0x675F2E0.5); // second param controls alpha
    my_mc.graphics.drawRect(0,0,aWidth,aHeight); // change aWidth & aHeight!
    my_mc.graphics.endFill(); 
    Florian Vanthuyne

    WAR AGAINST SOLVED THREADS
    mark yours as Resolved under Thread Tools!

  3. #3
    LukewarmSteak - Jordan Embury
    Join Date
    Jul 2009
    Location
    Toronto Ontario Canada
    Posts
    24
    great thinking however i receive an error 1119

    1119: Access of possibly undefined property graphics through a reference with static type flash.text:TextField.

  4. #4
    lemon juice hurts your eyes florianvanthuyn's Avatar
    Join Date
    Jul 2005
    Location
    Merelbeke, Belgium
    Posts
    546
    Ow, right. I thought my_mc was as MovieClip, with that mc extension
    A simple function should take care of this:
    PHP Code:
    function makeBackground(target:Textfield):void
    {
       var 
    temp:Sprite = new Sprite();
       
    temp.graphics.beginFill(0x675F2E0.5); // second param controls alpha
       
    temp.graphics.drawRect(0,0,target.width,target.height); // making rect the size of the tf
       
    temp.graphics.endFill();
       
    temp.target.x// positioning it
       
    temp.target.y;

       
    addChild(temp); // adding it
       
    swapChildren(temptarget); // swapping places with tf so it doesn't cover it

    Now I'm not sure how you should then call that background, since it's made in the scope of a function, and won't have a name you can call out for (saying this.temp will give an error).
    One way could be:
    PHP Code:
    this.removeChild(getChildAt(getChildIndex(my_mc) - 1)); 
    which removes the child directly below the specified child (here my_mc)

    Please post back I'f you're having errors, because this is written out ot the top of my head
    Florian Vanthuyne

    WAR AGAINST SOLVED THREADS
    mark yours as Resolved under Thread Tools!

  5. #5
    LukewarmSteak - Jordan Embury
    Join Date
    Jul 2009
    Location
    Toronto Ontario Canada
    Posts
    24
    yes sir
    Ata ha'eesh

    but i'm not sure i understand how to use the reference...

    PHP Code:
    this.removeChild(getChildAt(getChildIndex(my_mc) - 1)); 
    using this how can i say after an event... 'textfieldbackground.height = 200;' ?

  6. #6
    lemon juice hurts your eyes florianvanthuyn's Avatar
    Join Date
    Jul 2005
    Location
    Merelbeke, Belgium
    Posts
    546
    Just use this:
    PHP Code:
    Sprite(getChildAt(getChildIndex(my_mc) - 1)).height 200
    In which my_mc is the name of the textfield who's background you want to change.
    Florian Vanthuyne

    WAR AGAINST SOLVED THREADS
    mark yours as Resolved under Thread Tools!

  7. #7
    LukewarmSteak - Jordan Embury
    Join Date
    Jul 2009
    Location
    Toronto Ontario Canada
    Posts
    24
    i was unable to use this method of reference... however i found a solution -
    because i was creating multiple textfields in a loop i created an array and saved them as a member of the array

    temparray[i] = temp;

    thanks florian

  8. #8
    lemon juice hurts your eyes florianvanthuyn's Avatar
    Join Date
    Jul 2005
    Location
    Merelbeke, Belgium
    Posts
    546
    No problem I would have suggested that if you hadn't found it yourself, but it's always a good thing to have people find their own ways
    Florian Vanthuyne

    WAR AGAINST SOLVED THREADS
    mark yours as Resolved under Thread Tools!

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