Advanced Search

Results 1 to 2 of 2

Thread: SWF file relative link in page

  1. #1
    Join Date
    Jun 2011
    Location
    So Cal
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default SWF file relative link in page

    I'm new to Flash. We were taught how to do load swf files using AS2.0 - but things are different using AS3.0. I have a flash "movie" that I made. I published as a SWF file and want to play that on a page on my flash site. How do I do this easily in Flash cs5?? The swf file will be stored in my folder with my main site files - not on the internet. Thanks in advance.

  2. #2
    Join Date
    Oct 2006
    Location
    New York, NY, USA
    Posts
    231
    Thanks
    32
    Thanked 24 Times in 24 Posts

    Default Use Loader() class & URLRequest(), etc. for ActionScript 3.0

    The swf file will be stored in my folder with my main site files - not on the internet.
    ??? I assume you are only working offline, locally. If you were to go online, your SWFs would have to be on your server along with your main SWF, preferably in the same folder/location. The Loader() class and the UILoader Component can be used to load JPG, GIF, PNG images and SWF files. Data and text files use URLLoader() class. (1) create instance of Loader() class; (2) create instance of URLRequest() class (with path to file); (3) use loader instance load method to load URLRequest path to file; (4) addChild() to display list.

    The named button instances trigger and are the target of .addEventListener(Event.TYPE, function); The argument of that specified function(evt:Event) references kind of event used as argument in Listener.

    The following is not my code. I snitched it from a professor's cache. See screen shot. The opening file background is target_mc. The frame labels are prefixed with $; the buttons have same name without $ prefix. Then function loadWeb(evt:MouseEvent) concatenates string ("$" + evt.currentTarget.name); target of event (button name) -- to create full frame label.


    Code:
    Actions for Frame 1
      var myURL:URLRequest = new URLRequest("swfs/intro.swf");
      var myLoader:Loader = new Loader();
      myLoader.load(myURL);
      target_mc.addChild(myLoader);
    
    Actions for Frame 2
      stop();
      home_btn.addEventListener(MouseEvent.CLICK, goHome);
      
    function goHome(evt:MouseEvent):void
      {
        gotoAndStop("$home");
        myURL = new URLRequest("swfs/intro.swf");
        myLoader.load(myURL);
      }
    
      web_btn.addEventListener(MouseEvent.CLICK, goWeb);
    
      function goWeb(evt:MouseEvent):void
      {
        gotoAndStop("$w1");
        myURL = new URLRequest("swfs/w1.swf");
        myLoader.load(myURL);
      }
    
      print_btn.addEventListener(MouseEvent.CLICK, goPrint);
    
      function goPrint(evt:MouseEvent):void
      {
        gotoAndStop("$p1");
        myURL = new URLRequest("swfs/p1.swf");
        myLoader.load(myURL);
      }
    
    Actions for Frame 5
      
      w1.addEventListener(MouseEvent.CLICK, loadWeb);
      w2.addEventListener(MouseEvent.CLICK, loadWeb);
      w3.addEventListener(MouseEvent.CLICK, loadWeb);
     
    function loadWeb(evt:MouseEvent):void
      {
        gotoAndStop("$" + evt.currentTarget.name);
        myURL = new URLRequest("swfs/" + evt.currentTarget.name + ".swf");
        myLoader.load(myURL);
      }
    
    Actions for Frame 20
    
      p1.addEventListener(MouseEvent.CLICK, loadPrint);
      p2.addEventListener(MouseEvent.CLICK, loadPrint);
    
      function loadPrint(evt:MouseEvent):void
      {
        gotoAndStop("$" + evt.currentTarget.name);
        myURL = new URLRequest("swfs/" + evt.currentTarget.name+".swf");
        myLoader.load(myURL);
      }
    
    Assets/Buttons
    
      painting, ‹web_btn›
      home, ‹home_btn›
      design, ‹print_btn›
    
      1, ‹w1›
      2, ‹w2›
      3, ‹w3›
    
      1, ‹p1›
      2, ‹p2›
    
      inv, ‹target_mc>
    Last edited by auntnini; 06-12-2011 at 12:16 AM. Reason: e. = evt.

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
  •