A Flash Developer Resource Site

+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Senior Member
    Join Date
    Dec 2007
    Posts
    121

    [AS3]using buttons to load external swf

    Hi, just started using AS3 and i would like some help.

    I have four button on my main movie, which basically will load an external swf when pressed. Right now, i'm able to load the first movie directly using this code

    Code:
    prBut.addEventListener(MouseEvent.CLICK, onClick);
    srBut.addEventListener(MouseEvent.CLICK, onClick);
    tm.addEventListener(MouseEvent.CLICK, onClick);
    conBut.addEventListener(MouseEvent.CLICK, onClick);
    
    
    function onClick(e:MouseEvent):void
    {
    	trace(e.target.name + "has been pressed");
    }
    
    var holder:MovieClip;
    var loader:Loader = new Loader();
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
    loader.load(new URLRequest("home.swf"));
    
    function onComplete(e:Event):void
    {	
    	holder = MovieClip(e.target.content);
    	holder.x = 2;
    	holder.y = 176;
    	addChild(holder);
    }
    Now, how do i use buttons to load the movies?

    Can someone help me plz

  2. #2
    Member
    Join Date
    Mar 2009
    Location
    Pune
    Posts
    62
    What do you mean by load movies? If you want the images to be loaded on clicking the button call loader.load in onClick. Also for 4 buttons you can right 4 onClicks and load diff images accordingly.

  3. #3
    Senior Member
    Join Date
    Dec 2007
    Posts
    121
    Do you have any working example i can refer to? AS2 was easy with the MovieClipLoader. But i must AS3 is very different

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