A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: How can I fill movieclip with bitmap/texture using actionscript 2 code?

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

    How can I fill movieclip with bitmap/texture using actionscript 2 code?

    Hello,

    I am trying to create small flash application which would allow me to fill movieclip with different texures/bitmaps using actionscript. It should work something like this:

    Click here

    but instead of fill with different colors movieclip should be filled with different bitmaps/textures. I have find tutorial for changing colors but not sure how to realize this to change textures.

    Perhaps there is some other solution beside using actionscript for which I don't know so all suggestios are welcome!

    Hope I explained it correctly and that someone can help me with this because I need to solve it as soon as possible.


    Thank you.

  2. #2
    Senior Member
    Join Date
    Jan 2010
    Location
    England
    Posts
    268
    going off that example you provided me i can say one of two things,

    you can have a large container movieclip, and have it fit the stage and then insert a few keyframes, write a stop(); command on each frame, and just change the colour of the movieclip to what you want it for each frame, so have green on one frame and blue on another and so on then use gotoAndPlay(1) and just change the number depending on which button you press.

    another way you could do this is to attach a movieclip from the library using the attachMovie command, have each symbol in your library and give them a linkage name, such as "object1" then like before have a large container movieclip, dont fill it with anything just have it fit the whole stage. then write something like

    containerMC.attachMovie("linkageID","newName",_roo t.getNextHighestDepth());

    make sure to right click the object in the library and give it a linkageID.
    might be addicted to flash...
    _______________________________________

  3. #3
    Junior Member
    Join Date
    Aug 2010
    Posts
    3
    Thnx Steve for quick reply and helpful post!

    I followed your instructions and it works partialy because code you suggested doesnt create any errors and it looks ok but problem is that bitmap/texture that I attached isn't inside of containerMC, it is placed in top left part of flash workspace and my goal is to fill containerMC with that texture.

    This is how my file looks like

  4. #4
    Junior Member
    Join Date
    Sep 2012
    Posts
    1
    Hello Adi2010;

    I am trying to do a small flash application just as the one you wanted to make!
    I am trying to find a solution for this and after 3 days of searching I couldn't find any.!!!!

    What I want to do is to have multiple textures (buttons) on the stage, and a large rectangle to
    apply that texture, and when I click on one of that buttons it directly applies to that rectangle!
    I thought its very simple to do it but I was mistaken!!
    hmm
    Did you find a solution for what you were looking for?
    or do you have an answer for my question ?

    Thank you so much

  5. #5
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    It's actually pretty simple. Say your rectangle Movieclip has an instance name of, rectangle_mc, and you have different Bitmap textures in your Library, given that each one has their own linkage ID (right-click a bitmap at a time, choose Properties, expand show Advanced, tick/check Export for Actionscript, and in the Identifier field, type something unique, for instance, texture1, then repeat this for the other Bitmaps in your Library, but give each one a unique linkage ID, texture2, texture3, etc.). Finally, in your button click-code (on(relelase) or onRelease or something), type this:

    Code:
    bitmap = flash.display.BitmapData.loadBitmap("texture1"); // change texture1 for other textures
    b = rectangle_mc.getBounds(rectangle_mc);
    rectangle_mc.createEmptyMovieClip("mc", 0);
    with(rectangle_mc.mc){
    	lineStyle(0, 0x000000, 0);
    	moveTo(b.xMin, b.yMin);
    	beginBitmapFill(bitmap);
    	lineTo(b.xMax, b.yMin);
    	lineTo(b.xMax, b.yMax);
    	lineTo(b.xMin, b.yMax);
    	lineTo(b.xMin, b.yMin);
    	endFill();
    }
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

Tags for this Thread

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