dcsimg
A Flash Developer Resource Site

Page 2 of 2 FirstFirst 12
Results 21 to 29 of 29

Thread: SWF Studio Commands for Opening External File

  1. #21
    Junior Member
    Join Date
    Sep 2008
    Posts
    4

    its not working... yet

    Not sure where to put that package and how to reference it from my primary fla. AS 3.0 says to use "import.packageName.*" or "import.packageName.className".

    DO I need to put a name in the package like
    "package ssURLLoader
    {"

    and then save it as an .as in the same folder?-

    would I need to also import some SWF Studio classes from somewhere or designate a class path to the named package?

  2. #22
    Junior Member
    Join Date
    Sep 2008
    Posts
    4
    Just to clarify how I implemented that code snippet:

    on the 1st frame of my FLa I put: import myURLLoader.ssURLLoader.*;
    myUrlLoader is the folder I put the ssURLLoaderTest.as into - (I named the package: ssURLLoaderTest).

    on the 2nd frame of my Fla I put a function to trigger the "ssURLLoaderTest() function in the ssURLLoaderTest.as as follows:

    this.addEventListener(Event.ENTER_FRAME, getSwf);
    function getSwf(event){
    ssURLLoaderTest.ssURLLoaderTest();
    this.removeEventListener(Event.ENTER_FRAME, getSwf);
    trace ("ssURLLoaderTest called");
    }

    I keep getting the same error message: "ssURLLoaderTest() is not defined."

    I also designated a class path to the package and set it to export on frame 1.

    I'm not getting any feedback as to whether or not the package is even loading. I even tried to put a trace at the top and all I get is the not defined error.

    This is what the package name/trace/class/function looks like:

    package myURLLoader.ssURLLoader
    {
    import flash.display.Sprite;
    import flash.net.URLRequest;
    import flash.display.Loader;
    import flash.events.Event;
    import flash.net.URLLoaderDataFormat;
    import flash.net.URLLoader;

    trace ("myUrLLOader.ssURLLoader has loaded");

    public class ssURLLoaderTest extends Sprite
    {public var req:URLRequest;
    public var ldr:Loader;
    public var uldr:*;
    public var sam:*;
    public var sammy:*;
    public function ssURLLoaderTest()

  3. #23
    Tim (Super Moderator) Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    The package waits fro the stage to be loaded and automatically triggers the load of the SWF. Instead of a package, here's a simple function that does the same job, you can just add the function to your FLA and call loadSWFFromLayout("loadme.swf") to load the SWF when you want. Just make sure to add the SWF to the Files Tab and call it with the right name

    Code:
    function loadSWFFromLayout(filename:String)
    {
    	var req:URLRequest;
    	var ldr:Loader;
    	var uldr:*;
    	
    	ldr = new Loader();
    	req = new URLRequest();
    	
    	if (ssCore.isEXE) 
    		uldr = new ssURLLoader();
    	else 
    		uldr = new URLLoader();
    	
    	uldr.addEventListener(Event.COMPLETE, onComplete);
    	uldr.addEventListener(ProgressEvent.PROGRESS, onProgress);
    	uldr.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
    	
    	req.url = filename;
    	
    	if (ssCore.isEXE) 
    		uldr.bufferSize = '8192';
    	
    	uldr.dataFormat = URLLoaderDataFormat.BINARY;
    	uldr.load(req);
    	
    	function onProgress(e:ProgressEvent):void
    	{
    		ssDebug.trace('onProgress: '+e.bytesLoaded+' of '+e.bytesTotal);
    	}
    	
    	function onIOError(e:IOErrorEvent):void
    	{
    		ssDebug.trace('onIOError: '+e.text);
    	}
    	
    	function onComplete(e:Event):void
    	{
    		ssDebug.trace('onComplete');
    		ldr.loadBytes(uldr.data);
    		addChild(ldr);
    	}	
    	
    }

  4. #24
    Junior Member
    Join Date
    Sep 2008
    Posts
    4

    Worked Great!

    Thanks! This worked fine.

    How/where would I otherwise have found this kind of info at the support site (or elsewhere)? Tutorials or a user-guide? I ended up here through a google search and had visited a lot of threads before finding this one.

    BTW still wondering what I was doing wrong re the package.

  5. #25
    Tim (Super Moderator) Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    All you needed to do was create a new instance of ssURLLoaderTest and the constructor would have added the event listener (for the stage to be ready) and everything would have been automatic.

    The example was designed to show how to securely load a SWF from the layout at startup. The class could have been modified, but the function I gave you is more useful in the general case.

    How/where would I otherwise have found this kind of info at the support site
    We definitely need to beef up the FAQs and add tutorials but it's hard to find a solution when you don't know what you're looking for.

    That's definitely not your fault though. Our solution is related to Flash but we add our own stuff on top of Flash and it's not always obvious that something like ssURLLoader is what you're looking for unless you read all the help and release notes, and nobody ever does

    The fastest way to get help is to post your question in the northcode support forum (www.northcode.com/forums), send us an email (support@northcode.com) or give us a quick phone call (we answer the phone). We've seen a LOT of issues over the 8 years we've been doing this and can poinpoint common problems and solutions pretty quickly.

    Tim

  6. #26
    Junior Member
    Join Date
    Nov 2009
    Posts
    2

    Unhappy PPS file open 2 to 3 times

    Hi

    I'm using ssCore.Shell.open to open external files bundled in my application and it works like a charm for all file types except for PowerPoint fullscreen presentations (PPS) where it opens the file 2 to 3 times and the user has to close them everytime.. Does anyone know why that happens or how to deal with it?? here is my code:

    on (release){
    ssCore.Layout.extractFile({resource:"\\Presentatio ns\\myprez.pps", destination:"tempdir://Presentations\\myprez.pps"})
    ssCore.Shell.open({path:"tempdir://Presentations\\myprez.pps", verb:"open"});
    }


    Thank you in advance

  7. #27
    Tim (Super Moderator) Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    The code looks fine. If I had to guess without seeing your whole app, I'd say you have some duplicated code OR that this code is somehow being called more than once. Can you add a call to ssDebug.trace to make sure that Shell.open is only being called once? If that isn't the problem can you send me a copy of the EXE or a link to somewhere I can grab it from to test this? You can use support@northcode.com to send me stuff.

  8. #28
    Junior Member
    Join Date
    Nov 2009
    Posts
    2

    Unhappy

    Hi Tim,

    Thank you for your prompt response, you are the best

    Actually you are right; when i tried ssDebug.trace it showed that the code is somehow being called twice!!!! Here is the code i tried in my button:

    on (release){

    ssDebug.trace("error");

    ssCore.Layout.extractFile({resource:"\\Presentatio ns\\myprez.pps", destination:"tempdir://Presentations\\myprez.pps"});
    ssCore.Shell.open({path:"startdir://Presentations\\myprez.pps", verb:"open"});

    }

    In the Trace tab, i get the word "error" displayed twice. I don't know why is it being called twice!! any ideas?? i would love to send you my exe but it is of a size of 80MB!!! not so easy to upload for my case.

    when i searched the forum i found a thread that might be the answer to this, here it is: http://www.northcode.com/v3/kbitem.php?link=7

    Do you think i have the same problem??

    Thank you Tim for the help

  9. #29
    Tim (Super Moderator) Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    If anyone else gets stuck on this problem, the solution was in our FAQ and we modified it slightly for CYBERSKI's situation. The conversation continued in our support forums at northcode.com

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