AS3 button

I want to change my website background image when I click my button.Who can tell me how to realize it?
Thanks a lot!

My background just an image.what I want is just like some website can change the whole background with a little button.i just start learning flash ,thanks a lot for your time.
Sent from my iPhone

Similar Messages

  • Confused about AS3 buttons (did read David Stiller's blog)

    I'm trying to convert an AS2 file over to AS3 and I can't get
    the buttons to work. They do not want to gotoAndStop at certain
    frames in specific scenes. In the following code, if you click on a
    button it works fine, but when you attemp to change to a new Scene,
    it breaks and both buttons won't work thereafter. I've tried
    everything for almost a day now and cannot get this to work and
    cannot find any reference to the problem. Is AS3 buttons not able
    to go to a new scene as it suggests in the Help files?:

    Laura,
    > Old patterns, old habits...time to change.
    Well, not necessarily! The old ways still work. :) Just
    configure
    your publish settings for AS2 or AS1, and bingo. It all
    depends on what
    you're trying to accomplish. If your aim is to output to TV,
    then by all
    means, use scenes! If you're not using code -- or using very
    little code --
    then it basically doesn't matter what version of ActionScript
    you use.
    > Now the flash animation drawing tools are so lame it's
    just
    > embarrassing. It's all about interactivity and coding is
    essential.
    I can hear that you're frustrated, and it probably helps to
    vent (it
    often helps me), but for the sake of others who might be
    reading this
    thread, I'm respectfully asking you for specifics. What new
    animation
    and/or drawing tools do you mean? How are they embarrasingly
    bad?
    The 3D and inverse kinematics (IK) tools, new to CS4, are
    hardly
    something I'd call embarrassing. On the contrary, they're
    cool all hell!
    True, the 3D tools require the FLA to be configured for AS3,
    but no
    scripting is required to use 3D or IK (though you *can*
    script them if you
    want to).
    The blend modes and filter effects introduced in Flash 8
    were a welcome
    edition. They didn't hinder anyone's workflow, as far as I
    know. If you
    wanted to use them, great! If not, great! Improved text
    rendering has been
    a joy ... and again, use it or not -- the choice has always
    been up to the
    designer's whim.
    > Ok, scenes are kinda old school. I can see why.
    They're only problematic (speaking historically) in cahoots
    with
    ActionScript. Unlike some, I actually do endorse the use of
    scenes ;) --
    just not in the context of programming. Keep using old school
    if that's
    what works for you. If you like, experiment with the new
    stuff as your
    schedule allows.
    > Why do anything in the timeline if you can do it in the
    code?
    I can't tell if you're being sarcastic in this line, but
    either which
    way, the answer (at least, from my perspective) is a
    pragmatic one. Use the
    timeline when doing so takes the least amount of work; the
    reverse holds
    true for code. There are plenty of animations --
    specifically, character
    animations, including lipsynch -- that, for me, are easier to
    do by hand, by
    direct manipulation of the symbols with my mouse and/or
    graphics tablet.
    I find it easier to design complex gradients using the
    drawing tools. I
    often find it easier to design complex tween eases by hand.
    When I'm
    working on animation, I tend not to code as often; when I'm
    building a
    Flash-based website, it's likely to be a combination of
    timeline techniques
    and code; when I'm writing applications, it's obviously a
    case of
    mostly-code.
    > [code gives you] more control. It can be more dynamic
    and
    > flexable. It is easier to edit. Next I need to do more
    external
    > .as doc scripting.
    Writing custom classes is another layer of technique.
    Depending on your
    workflow, it may or may not be useful. For what it's worth, I
    wrote a
    tutorial series for Community MX not so very long ago that
    might help
    illustrate this point ...
    http://www.communitymx.com/abstract.cfm?cid=ECBF0
    ... the first article is free, and demonstrates a technique
    (using code) for
    causing letters to wiggle into place. Over the course of
    several
    installments, this series works toward moving the code from
    the timeline to
    a class file, which shows how custom classes can provide a
    workflow boost,
    even for a movie that doesn't necessarily need to be
    übercoded in other
    respects. I hasten to add, I'm not one who relishes the role
    of a "Here,
    the first one is free" salesman, so be aware that you can
    also read the
    remaining articles free if you sign up for a trial
    membership, which you can
    cancel without obligation in a week's time.
    > My working file is now all on a single timeline with no
    scenes.
    > Who needs scenes. Yipee!
    Under the hood (meaning, in the SWF) all those scenes are
    ultimately
    converted to one big timeline anyway. Granted, the use of
    scenes is a
    convenient organizational tool during authoring, and I don't
    deny that
    scenes-with-ActionScript would be equally convenient, but
    again ... scenes
    have been "broken" in ActionScript for a long time. It looked
    like Flash
    CS3's AS3 finally resurrected the workflow, and -- for the
    time being -- it
    looks like CS4 might somehow be missing the mark. If so, as
    kglad proposes,
    the AS3 gotoAndPlay() issue is a bug in CS4, and we can hope
    for a fix from
    Adobe.
    David Stiller
    Adobe Community Expert
    Dev blog,
    http://www.quip.net/blog/
    "Luck is the residue of good design."

  • My AS3 buttons only work the first time

    I have set up my buttons so that are each a movieclip with 'over' and 'out' states/frame labels. They exist on the main timeline. The actionscript controlling them is situated in a frame on the main timeline and the frame holding that actionscript is on the same point within the main timeline where the buttons are introduced. I am using actionscript 3.
    The buttons have been set up so that they navigate to another frame on the same main timeline and on that frame is a movie. The movie dimensions are smaller than the main stage so the buttons are still accessible when each movie is played.
    The problem is my buttons are only working once - by that I mean they go to the correct place when clicked the first time, but when they are clicked again they navigate elsewhere.
    Totally doing my head in trying find a solution and if anyone can help and show me what I'm doing wrong that would be really really helpful. Here's the code I used for the buttons...
    stop();
    function mainBtnOver(event:MouseEvent):void {
    event.target.gotoAndPlay("over");
    function mainBtnOut(event:MouseEvent):void {
    event.target.gotoAndPlay("out");
    ///////// INDIVIDUAL BUTTON CLICK FUNCTIONS
    function mainBtn1Down(event:MouseEvent):void {
    gotoAndPlay("01Movie");
    function mainBtn2Down(event:MouseEvent):void {
    gotoAndPlay("02Movie");
    function mainBtn3Down(event:MouseEvent):void {
    gotoAndPlay("03Movie");
    function mainBtn4Down(event:MouseEvent):void {
    gotoAndPlay("04Movie");
    function mainBtn5Down(event:MouseEvent):void {
    gotoAndPlay("05Movie");
    ////////// Button 1 Listeners
    mainBtn1.addEventListener(MouseEvent.ROLL_OVER, mainBtnOver);
    mainBtn1.addEventListener(MouseEvent.ROLL_OUT, mainBtnOut);
    mainBtn1.addEventListener(MouseEvent.CLICK, mainBtn1Down);
    ////////// Button 2 Listeners
    mainBtn2.addEventListener(MouseEvent.ROLL_OVER, mainBtnOver);
    mainBtn2.addEventListener(MouseEvent.ROLL_OUT, mainBtnOut);
    mainBtn2.addEventListener(MouseEvent.CLICK, mainBtn2Down);
    ////////// Button 3 Listeners
    mainBtn3.addEventListener(MouseEvent.ROLL_OVER, mainBtnOver);
    mainBtn3.addEventListener(MouseEvent.ROLL_OUT, mainBtnOut);
    mainBtn3.addEventListener(MouseEvent.CLICK, mainBtn3Down);
    ////////// Button 4 Listeners
    mainBtn4.addEventListener(MouseEvent.ROLL_OVER, mainBtnOver);
    mainBtn4.addEventListener(MouseEvent.ROLL_OUT, mainBtnOut);
    mainBtn4.addEventListener(MouseEvent.CLICK, mainBtn4Down);
    ////////// Button 5 Listeners
    mainBtn5.addEventListener(MouseEvent.ROLL_OVER, mainBtnOver);
    mainBtn5.addEventListener(MouseEvent.ROLL_OUT, mainBtnOut);
    mainBtn5.addEventListener(MouseEvent.CLICK, mainBtn5Down);
    I'm sure it's me doing something very stupid - I'm very new to AS3. Any help much appreciated.
    Thanks :-)

    If the frame labels you are going to have movie clips that have your presentation content, you should use gotoAndStop("frameLabel") instead of gotoAndPlay("frameLabel"). There's no need to play the main timeline when you go to and show any of these movie clips. I'm not sure if this is your issue, though... Using your code, I had no problems.
    Also, you can set up your animated buttons in a way that eliminates the need to have your ROLL_OVER and ROLL_OUT events. This isn't necessarily better, but just another method. Although I might use other ways to animate a button, I do like to reduce the code it takes to use the buttons in an interface, and only use CLICK in most cases.

  • AS2 vs. AS3 Button

    So in AS2 to add button functionality to a movie clip, you'd
    type:
    myButton_mc.onPress=function(){
    gotoAndPlay("something");
    How is this accomplished in AS3 WITHOUT using external .as
    files, classes, etc?
    It seems like all the tutorials/books I read, they want to
    create the bible before anything can be done.
    If this is the case, why is AS3 better? I understand it
    appeals more to hard core programmers of Java, but what about
    therun-o-the-mill types who actually like Director's Lingo and can
    cope with AS2?
    Thanks!

    Well, one of the big advantages AS3 has is that it`s 10 times
    faster than AS2. Then, it`s easyer to learn for beginners, because
    everyting is done similarly( you decalre any variable the same way,
    every listener etc...) etc...

  • AS3 button state

    How to make a button stay down state after been clicked?
    stop();
    var ldr:Loader = new Loader();
    ldr.x = 300;
    ldr.y = 0;
    addChild(ldr);
    ldr.load(new URLRequest("myclip.swf"));
    projects_btn.addEventListener(MouseEvent.CLICK, clickFunction1);
    function clickFunction1(evt:MouseEvent):void {
    gotoAndPlay(2);

    If you create the button as a movieclip you can control of which frame/state it is in.  Otherwise, if it is a SimpleButton symbol, in AS3 you can change the upState property to equal the downState property, but then you would need to retain some reference of the upState if you plan to return there sometime later.  The movieclip approach gives more reliable control.

  • AS3 Button action

    I am producing a project for my employer and a button is
    giving me fits. It does work in all tested browsers/platforms, but
    the primary distribution will be via email and this is where the
    trouble appears. It is a simple button that should only open a URL
    in a browser window.
    Here's the AS3 action I'm using on a button:
    function gotoURL2(event:MouseEvent) {
    var url = new URLRequest('
    http://www.domain.com/');
    navigateToURL(url, '_blank');
    signup_btn.addEventListener(MouseEvent.CLICK, gotoURL2);
    Is there anything that would prohibit this from working when
    viewed in an email client? Is it possible that a publishing setting
    is wrong? I've run this 100 different ways and I can't find it.
    Thanks

    Playing SWFs in an email inline is dicey. Not only does the
    client email application need to allow for inline viewing of
    Javascript content (to display the flash SWF), but the email client
    has to have the Flash 9 player installed for its inline viewing.
    Guarantee 99.99% of corporations won't allow this, if the email
    gets past their firewall at all, and most personal email clients
    don't have this capability. So chances are it's not that your code
    is wrong, it's just that an email client is not a fully-featured
    browser. In most cases you're going to have to stick with GIF and
    HTML content, which can be viewed only
    if the user allows for "rich email" HTML content to be
    viewed.

  • AS3 button to link to AS2 page

    I'm trying to figure out how to get the home button on an Action Script 3 page to the homepage, which is in Action Script 2. There is no AS3 on the homepage, and all of the content is different. Sooo, how do you do this? The .swf file is called homepage.swf and it seems simple, but I can't for the life of me figure it out since I'm so new to AS3. Can anyone help?
    thanks!
    Sg

    Thanks for your help thus far. I have a button on the bottom of architecture.swf that I would like to go to homepage.swf. That's all, just trying to get back to the homepage.swf content. The content is completely different, so I would like it to load the homepage.swf on the same layer. In action script 2 I used what is below, but this is the only actionscript3 page on the site (it's a portfolio my client liked):
    on (release) {
    //load Movie Behavior
    if(this == Number(this)){
    loadMovieNum("architecture.swf",this);
    } else {
    this.loadMovie("architecture.swf");
    //End Behavior
    thanks so much!
    Steve

  • How to _root in as3 (buttons in movie clip referencing to main timeline)

    Hi, I created buttons within a movie clip that i placed in the main timeline.I am  a novice to as3. I just wanted the button to go to the frame label of the main timeline. i used to do this with _root in the old flash. how do i do this?
    thumb02_btn.addEventListener(MouseEvent.CLICK, buttonClicked);
    function buttonClicked(event:MouseEvent):void
        gotoAndPlay("slide2");

    Thanks for the quick reply!
    somehow i must be doing something wrong though. It's not working...
    I added a stop to the "slide02" labeled section of the main timeline.
    and I also added a stop to the beginning and end of the movieclip. Am I doing something wrong? attached is my file....thanks!!
    stop();
    thumb02_btn.addEventListener(MouseEvent.CLICK, buttonClicked);
    function buttonClicked(event:MouseEvent):void
        MovieClip(this.root).gotoAndPlay("slide2");
    stop();

  • Adobe Flash as3 Button question...

    Hi,
    I just wonder that how can i write this code  that means if the "specific" button is clicked(i mean if the homebutton is clicked=true) like this..
    and how can i refer a button that in main stage while in an another clip's substage..
    ty all

    Please don't crosspost in these forums.  A response is offered in the AS3 forum.

  • AS3 Buttons and URL

    Button code  for AS3
    on frame 1
    function clickFunction(evt:MouseEvent):void
    gotoAndPlay(5);
    myButton.addEventListener(MouseEvent.CLICK, clickFunction);
    stop()
    on frame 5
    function clickFunction1(evt:MouseEvent):void
    gotoAndPlay(1);
    myButton1.addEventListener(MouseEvent.CLICK, clickFunction1);
    stop()
    Button URL on AS3
    function onButtonClick(event:MouseEvent)
    var url:URLRequest = new URLRequest("http://adobe.com");
    navigateToURL(url, "_blank");
    my_button.addEventListener(MouseEvent.CLICK, onButtonClick);

    Not a question
    simply i gave a code those who need, everything is fine in that

  • AS3 Buttons and textfields

    Hi,
    I coming from an AS2 environment and trying to get my head around AS3.
    I have a dynamic Textfield on stage (instance name tfval)
    a movieclip named mcPlan, this contains a btn called s4
    but I cannot get the following to work:
    import flash.text.TextField;
    var tfval:String="Start";
    root.mcPlan.s4.addEventListener(MouseEvent.MOUSE_OVER,onOver);
    root.mcPlan.s4.addEventListener(MouseEvent.MOUSE_OUT,onOut);
    function onHover(event:MouseEvent):void{
    trace("dsds");
    root.tfval.text="Test From onOver";
    function onOut(event:MouseEvent):void{
    root.tfval.text="Test From onOut";
    Any help is apreciated!
    Thanks!

    aren't you seeing an error message about the lack of an onOver() function?  are you seeing any other error messages?

  • As3 button inside imported swf

    Hi all,
    I have a site where an .swf is loaded into frame 11 of the main timeline using newLoader().
    In this .swf there is an titlebuttons_mc with seven buttons in, images_mc etc.
    How do i navigate back to, background_mc, frame 40, which is on frame 1 of the main timeline.
    Thanks for any help
    s1976h

    if the code for the buttons is on the external swf's main timeline, you would use:
    titlebuttons_mc.buttonwhatever.addEventListener(MouseEvent.CLICK,f):
    function f(e:MouseEvent){
    MovieClip(e.currentTarget.parent.parent).background_mc.gotoAndStop(40);
    if the code for the buttons is on the timeline of titlebuttons_mc's timeline, you would use:
    buttonwhatever.addEventListener(MouseEvent.CLICK,f);
    function f(e:MouseEvent){
    MovieClip(parent.parent.parent).background_mc.gotoAndStop(40);

  • AS3 Button Issue

    Hi,
    I am having a issue with my main menu buttons. My buttons are controlled by AS. Here is the code I am using for the buttons.
    //handle events for buttons...
    home.addEventListener(MouseEvent.CLICK, clickSection);
    design.addEventListener(MouseEvent.CLICK, clickSection);
    photography.addEventListener(MouseEvent.CLICK, clickSection);
    about.addEventListener(MouseEvent.CLICK, clickSection);
    contact.addEventListener(MouseEvent.CLICK, clickSection);
    company.addEventListener(MouseEvent.CLICK, clickSection);
    function clickSection (evtObj:MouseEvent) {
    //trace shows what's happening.. in the output window
    trace ("The "+evtObj.target.name+" button was clicked!")
    // go to the section clicked on...
    gotoAndStop(evtObj.target.name);
    The issue I am having is that say the user clicks on the Design button on the home page, the design button goes in to a page of company logos, the user then clicks on a companies logo to view the work that we have done for that company, a slide show of photographs opens when the user clicks on the company logo. The user click thru the photos. Here is the issue I am having. I want the user to be able to click on the main Design button to get back to the logos section, which is the start of the design section. If you are in my design section, the design button does not work, or reload the section. You have to, say, click on the contact button, then click on the design section again in order to start it over. I hope this makes sense, and that someone can help. My email is [email protected] if anyone thinks they can help.
    Thank you.

    One of the approaches can be holding references to the clicked button and frame in wich the click occured. here may be bugs in the code - this is just a concept:
    //handle events for buttons...
    home.addEventListener(MouseEvent.CLICK, clickSection);
    design.addEventListener(MouseEvent.CLICK, clickSection);
    photography.addEventListener(MouseEvent.CLICK, clickSection);
    about.addEventListener(MouseEvent.CLICK, clickSection);
    contact.addEventListener(MouseEvent.CLICK, clickSection);
    company.addEventListener(MouseEvent.CLICK, clickSection);
    // currently clicked button
    var currentClick:DisplayObject;
    // return frame
    var returnFrame:int = 0;
    function clickSection (evtObj:MouseEvent) {
         //trace shows what's happening.. in the output window
         trace ("The "+evtObj.target.name+" button was clicked!")
         // go to the section clicked on...
         if (currentClick && evtObj.currentTarget == currentClick) {
              currentClick = null;
              gotoAndStop(returnFrame);
         else {
              gotoAndStop(evtObj.currentTarget.name);
              currentClick = evtObj.currentTarget;
              returnFrame = MovieClip(this).currentFrame;

  • AS3 button = 2 functions a bit complicated

    I have swing_mc on the main timeline of an .swf
    I need to have swing _mc do two things
    1. on rollover to play
    2. on click to gotoAndStop ("framename") main timeline
    I have an invisible button INSIDE swing_mc on the top layer, this is because the mc is supposed to swing back and forth so the inv btn must be on top of the mc to follow the motion path.
    if there is a solution this way that would be fine, if not I was just thinking:
    the mc is a picture swinging from side to side, if I put an invisible button on the main timeline over most of the area the button swings over and covers I think that would work, but then I would have to target the swing_mc timeline for it to play correct?
    How and which way do I code this?
    Thx!

    For the first function you should only need...
    function swingBtnRoll(event:MouseEvent):void{
        swing_mc.play ;
    The parent reference could be a problem since there is none except maybe the Stage.
    And for the second function, you need to place the frame argument in parentheses
    function swingBtnClick(event:MouseEvent):void{
        gotoAndStop("swing") ;
    You mention something about a button, so I don't know if you want to assign the event listteners to the swing_mc or the button you mention.

  • My AS3 Buttons in Flash do not work in HTML.

    Hey there,
    I created an SWF with 5 Buttons. I used the following code:.
    mybutton1.addEventListener(MouseEvent.CLICK,f);
    function f(e:Event){
    navigateToURL(new URLRequest("http://www.myurl1.com"));
    mybutton2.addEventListener(MouseEvent.CLICK,f2);
    function f2(e:Event){
    navigateToURL(new URLRequest("http://www.myurl2.com"));
    mybutton3.addEventListener(MouseEvent.CLICK,f3);
    function f3(e:Event){
    navigateToURL(new URLRequest("http://www.myurl3.com"));
    mybutton4.addEventListener(MouseEvent.CLICK,f4);
    function f4(e:Event){
    navigateToURL(new URLRequest("http://www.myurl4.com"));
    mybutton5.addEventListener(MouseEvent.CLICK,f5);
    function f5(e:Event){
    navigateToURL(new URLRequest("http://www.myurl5.com"));
    It works perfectly fine when I export the SWF from Flash.
    When embedding the SWF in an HTML file nothing happens. The buttons don't work, no error message, nothing.
    Help anyone?
    Thanks!

    Yo Ned,
    I directly exported an HTML file from Flash and it worked perfectly.
    Thanks a lot!
    Benni

Maybe you are looking for

  • Start Routine to populate the Logical Source System

    Hi Friends please help me with the below 1. <b>Requirement</b> : to Populate The system Date , Source System in BI for Each load request. <b> 1 Solution:</b> I thought of writing the Start Routine for this but it is giving me error syntax Error: END

  • Business content 3.30: Datasources not available for installation

    Hello, we have recently upgraded our business content from 3.10 to 3.30 in order to get new business content (e.g. datasource 2LIS_13_VDKON - billing item pricing conditions). Although the upgrade was successful, the new datasources cannot be found i

  • IPhone trying to sync with second iTunes

    My iPhone and iPad sync with my home computer, called "Colin's MacBook". My work computer, called "Colin's Work MacBook", has the same iTunes library, copied over from a Time Machine backup. I sync my iPhone and iPad over wifi. Every time I open iTun

  • Error in Page SFSY-PAGE of SFSY-FORMPAGES

    Hi; When i enumerate the smartform pages with this in a textbox Page &SFSY-PAGE& of &SFSY-FORMPAGES&, and the number of pages is more than 10 it displays: Page 1 of  *, Page 2 of  *.....Page 1 of 10.. Page 1 of 11..... the first 9 pages the SFSY-FORM

  • Another CS4 bug?

    Hey, I'm wondering if anyone else is having this issue... I will be in design workspace adding some components to a form, then I switch to developer workspace to add the code. Then when I need to go back to design, all the workspace options are graye