Flash Gallery | Flash Templates | Flash Menu | Flash Design | Flash Audio & Video

flash page flip

Actionscript 3.0 video tutorials

+ Reply to Thread
Page 3 of 4
FirstFirst 1 2 3 4 LastLast
Results 21 to 30 of 34

Thread: Loading external swf with no use of AS files

  1. #21
    Administrator Living At The FlepStudio! Flep is on a distinguished road
    Join Date
    Jul 2007
    Posts
    5,457
    Rep Power
    8

    Re: Loading external swf with no use of AS files

    amazing Flash templates
    Quote Originally Posted by AYDIN View Post
    Hi Flep,

    removing the 2 llines of code fix it.
    Code:
    if(loader!=null)
            loader.unload();
    But this one doesn't work.
    Code:
        if(loader!=null)
        {
            loader.unload();
            loader=null;
        }
    I don't understand why?
    Seems to be correctly. Any idea?

    Ciao Aydin
    The problem is this line:
    Code:
    loader=new Loader();
    It must be declared once. So it must be out of the function:
    Code:
    var my_videos:Array=new Array("movies/one.swf","movies/two.swf","movies/three.swf","movies/four.swf","movies/five.swf");
    var my_buttons:Array=new Array(button_1,button_2,button_3,button_4,button_5);
    var request:URLRequest;
    var loader:Loader=new Loader();
    var holder_mc:MovieClip=new MovieClip();
    addChild(holder_mc);
    
    for(var i:int=0;i < my_videos.length;i++)
    {
    	my_buttons[i].id=i;
    	my_buttons[i].mouseChildren=false;
    	my_buttons[i].buttonMode=true;
    	
    	my_buttons[i].addEventListener(MouseEvent.MOUSE_DOWN,onButtonDown);
    }
    
    function onButtonDown(evt:MouseEvent):void
    {
    	if(loader!=null)
    		loader.unload();
    	request=new URLRequest(my_videos[evt.target.id]);
    	loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onImageLoaded);
    	loader.load(request);
    }
    
    function onImageLoaded(evt:Event):void
    {
    	if(holder_mc.numChildren>0)
    		holder_mc.removeChildAt(0);
    	var swf:MovieClip=evt.target.loader.content as MovieClip;
    	holder_mc.addChild(swf);
    }
    I've re-uploaded the attachment.

  2. #22
    Administrator Living At The FlepStudio! Flep is on a distinguished road
    Join Date
    Jul 2007
    Posts
    5,457
    Rep Power
    8

    Re: Loading external swf with no use of AS files

    Hi Susanne,
    if you download the sample files of this thread, you'll see the code of main.fla .
    You could create one array ( like my_buttons in the sample ) for each main button and populate the array with sub buttons.

  3. #23
    junior master blaster Settled In thrice is on a distinguished road
    Join Date
    Jul 2008
    Posts
    1
    Rep Power
    0

    Re: Loading external swf with no use of AS files

    i just downloaded and
    still the same error!

    no i didnt do anything

  4. #24
    Junior Member Settled In bhatushai is on a distinguished road
    Join Date
    Feb 2008
    Posts
    7
    Rep Power
    0

    Re: Loading external swf with no use of AS files

    for those who got error, here the fix
    Attached Files

  5. #25
    Junior Member Settled In pulse is on a distinguished road
    Join Date
    May 2008
    Posts
    5
    Rep Power
    0

    Re: Loading external swf with no use of AS files

    Hello There,

    Really Appreciate your tutorials... its great to see people finding the time to help others :)

    I just have a couple of questions... as I have been racking my head over this for a while.

    (1) In this tutorial the buttons are set as movies... what do I do to your as3 to make a normal (non movie) button work?

    (2) If I want to add a non swf movie page, i.e. Home page = swf movie, Contact = swf movie, news = normal page (not swf)? what needs to be added in action script land for this to work?

    Thanks in advance and I really appreciate any help.

    Take care,

    Anthony

  6. #26
    Administrator Living At The FlepStudio! Flep is on a distinguished road
    Join Date
    Jul 2007
    Posts
    5,457
    Rep Power
    8

    Re: Loading external swf with no use of AS files

    Hi pulse,
    1. If you want use buttons, you have to embed them into a MovieClip because otherwise you can't add id property to button cos Button class is not dynamic.
    2. Just do not add the "normal" button into the array. Interact with it as a stand alone button. So use navigateToURL:
    Code:
    my_button.addEventListener(MouseEvent.MOUSE_DOWN,onButtonDown);
    
    function onButtonDown(evt:MouseEvent):void
    {
    	var request:URLRequest=new URLRequest("http://flepstudio.org/");
    	navigateToURL(request,"_blank");
    }

  7. #27
    Junior Member Settled In pulse is on a distinguished road
    Join Date
    May 2008
    Posts
    5
    Rep Power
    0

    Re: Loading external swf with no use of AS files

    Thanks for the reply... its wonderful that your able to provide a wee bit of advice for a struggling novice like myself :)

    I'm still having a bit of trouble implementing this into my site. I've tried using some as3 code I found a while ago (out of interest)... everything seems to work, except I can't remove the movie when I transition between pages.

    If you get a change it would be great if you can check out the script and see what I'm doing wrong or not adding... ps I'm sorry if what I'm doing is a bit messy.

    Just to note there is a preloader on frame 1, and swf's are being loaded into a movie container.

    stop();

    var mcContainer:Loader = new Loader();
    addChild(mcContainer);
    var url:URLRequest = new URLRequest("swfs/homepage.swf");
    mcContainer.load(url);


    button_1.addEventListener(MouseEvent.CLICK, goHome);
    function goHome (e:MouseEvent):void

    {


    var mcContainer:Loader = new Loader();
    addChild(mcContainer);
    var url:URLRequest = new URLRequest("swfs/homepage.swf");
    mcContainer.load(url);
    }

    button_2.addEventListener(MouseEvent.CLICK, goNews);
    function goNews (e:MouseEvent):void

    {


    var mcContainer:Loader = new Loader();
    addChild(mcContainer);
    var url:URLRequest = new URLRequest("swfs/news.swf");
    mcContainer.load(url);
    }

    button_3.addEventListener(MouseEvent.CLICK, goBio);
    function goBio (e:MouseEvent):void

    {


    var mcContainer:Loader = new Loader();
    addChild(mcContainer);
    var url:URLRequest = new URLRequest("swfs/Bio.swf");
    mcContainer.load(url);
    }

    button_4.addEventListener(MouseEvent.CLICK, goDiscography);
    function goDiscography (e:MouseEvent):void

    {


    var mcContainer:Loader = new Loader();
    addChild(mcContainer);
    var url:URLRequest = new URLRequest("swfs/discography.swf");
    mcContainer.load(url);
    }

    button_5.addEventListener(MouseEvent.CLICK, goMedia);
    function goMedia (e:MouseEvent):void

    {


    var mcContainer:Loader = new Loader();
    addChild(mcContainer);
    var url:URLRequest = new URLRequest("swfs/media.swf");
    mcContainer.load(url);
    }

    forum_btn.addEventListener(MouseEvent.CLICK,goForu m);

    function goForum(e:MouseEvent)
    {
    var request:URLRequest = new URLRequest("http://pulsecreation.yuku.com/");
    navigateToURL(request);
    }

    button_7.addEventListener(MouseEvent.CLICK, goContact);
    function goContact (e:MouseEvent):void

    {


    var mcContainer:Loader = new Loader();
    addChild(mcContainer);
    var url:URLRequest = new URLRequest("swfs/contact.swf");
    mcContainer.load(url);
    }

    Many Thanks,

    Anthony

  8. #28
    Junior Member Settled In xoxo is on a distinguished road xoxo's Avatar
    Join Date
    Jan 2008
    Posts
    12
    Rep Power
    0

    Question Re: Loading external swf with no use of AS files

    Thank you Flep for this nice and useful tutorial.

    Will be nice to know if it is possible combine this solution with an intro and outro animation in the loaded movies (one, two, three, etc).

    Something like this:

    When I click in mc, will be nice to play the intro animation, and when click on another mc, play the outro of the loaded movie, and then load the new movie and play the intro.

    This will be really nice, and I'm shure can be done only adding some lines of code. I have tested lots of things and I haven't achieved anything, as I'm a starter in AS3.

    Any suggestiones for achieving this?

    Thank you,

    XOXO

  9. #29
    Junior Member Settled In meyezor is on a distinguished road
    Join Date
    Jun 2008
    Posts
    1
    Rep Power
    0

    Re: Loading external swf with no use of AS files

    I get the same error but only after pressing a button for a second time once the new swf has loaded. This happens with every button if I click it a second time.

    ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
    at flash.display::Loader/unload()
    at main_fla::MainTimeline/onButtonDown()

  10. #30
    Junior Member Settled In Kridian is on a distinguished road
    Join Date
    Jul 2008
    Posts
    3
    Rep Power
    0

    Re: Loading external swf with no use of AS files

    So how would the code change for something like this? The "homepage.swf" will have to load into the "main.swf", then the buttons within homepage navigate to the other pages. Every tutorial I've seen always has these nav. buttons stay on the stage while the swf pages swap out, but I'd like to know how to treat something like this.

+ Reply to Thread
Page 3 of 4
FirstFirst 1 2 3 4 LastLast

Similar Threads

  1. preLoader with external files!!!
    By losbenos in forum advanced Actionscript 3.0
    Replies: 10
    Last Post: 01-11-09, 09:21
  2. load External swf files with AS3
    By tuanDuy in forum advanced Actionscript 3.0
    Replies: 2
    Last Post: 12-03-09, 01:08
  3. Loading mulitple external .swf files
    By mrentschler in forum Actionscript 3.0 newbies
    Replies: 1
    Last Post: 09-10-08, 22:24
  4. load External swf files with AS3
    By tuanDuy in forum HELP free utilities
    Replies: 0
    Last Post: 27-05-08, 10:44
  5. Loading external XML files with Flash CS3
    By Flep in forum Tutorials
    Replies: 14
    Last Post: 19-11-07, 15:23

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Optimization by vBSEO