PDA

View Full Version : Flex Event.INIT & Event.COMPLETE not registering/triggering



jm8thew
April 11th, 2009, 11:56 PM
A little background first:

I run ubuntu hardy with flash 10 and im using flex 3 sdk to compile my projects. I'm new to actionscript but not programming.

Here's the issue. I'm working on a proggy that simply displays a picture. For some reason when i register an event handler for a loader like COMPLETE or INIT, i find that the handler is either not registered or not being triggered. Thus, I cannot add it to the display list through that method. The code is fine (see below) because I took it directly out of an Oreily book. Oddly ProgressEvents seem to work fine and i can essentially derive a "COMPLETE" event handler from that, but that is an ugly workaround.

Code:



package {
import flash.display.*;
import flash.net.URLRequest;
import flash.events.*;

public class Main extends Sprite {
private var loader:Loader;

public function Main() {
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.IN IT, initListener);
var urlRequest:URLRequest = new URLRequest("sunset.jpg");
loader.load(urlRequest);
}

private function initListener (e:Event):void {
addChild(loader.content); // Add Bitmap object to SunsetViewer
}
}
}
Any help would be appreciated. I'm guessing it's something wrong with my configuration/setup, but any idea as to what?


On a side note: because of some odd dependency issues i cannot run the official standalone flashplayer/debugger for linux. Are there any other replacements that can run flash 10 files? I'm currently testing using firefox and the flash 10 plugin (ugh).

Thanks again.

wvxvw
April 12th, 2009, 05:30 AM
Init event should be fired when the contents of the Loader file is read, and complete event should be fired when Loader internally adds the loaded content to it's display list.
Considering your example - adding loader's content to another container is in general a bad idea because if you do so, later you won't be able to unload such content (you'll get an error saying that the content isn't a child of the loader or something like that)...
But if you say you tried both complete and init then... well, this just sounds odd...
Considering the standalone debug player - I haven't tried it on XX, but I think I've read about this problem, you should install and run the player as administrator on your machine (does it make sense?). Because Flash Player has no dependencies on other software...
Can you just try a different SDK or a different playerglobal.swc (there're maybe 5 or so versions of playerglobal.swc each one for corresponding player version: 9.0.054, 9.0.115, 9.0.124 etc, mind it, for Linux the version numbers may be a bit different).
If you cannot still figure out the problem - try searching bug database for your issue:
http://bugs.adobe.com/
Also see if this isn't your case:
http://bugs.adobe.com/jira/browse/FP-513
(Though it shouldn't be, but, well, maybe the actual code and your example are different).

jm8thew
April 12th, 2009, 01:36 PM
Alright update time.

Thank you wvxvw (is your nick a text angel?) for getting me to give flash player install a go again. The problem was I run a 64bit system so i had no 32bit libraries that flash was looking for (there is no 64bit flash standalone player). I thought I did because the libraries have the same exact name. Anyway for the benefit of others I'll list the libraries I needed below to run flash 10 on a 64bit ubuntu linux system.

note: probably not a complete dependency list seeing as I have several other programs installed on my compy, but flash spit out what libraries it needed everytime I tried to run it (with the exception of libcurl which just threw a "segmentation fault" error and I had to look online for that).


Shared libraries:
libcurl.so.3
libcurl.so.4
libcurl.so.4.1.0

libnspr4.so.0d
libplc4.so.0d
libplds4.so.0d

libnss3.so.1d
libnssutil3.so.1d
libsmime3.so.1d
libssl3.so.1dI got those from the following 32bit debs (from packages.ubuntu.com):


libcurl3_7.18.2-1ubuntu4.3_i386.deb
libnspr4-0d_4.7.1~beta2-0ubuntu1_i386.deb
libnss3-1d_3.12.0~beta3-0ubuntu1_i386.debI put them all int /usr/lib32 and had the older versions of each act as symbolic links to the newer versions.


Okay, now that I can run the official flash debugger. Which gave me: "SecurityError: Error #2148... Only local-with-filesystem and trusted local SWF files may access local resources." I did a google search and people said that changing the flex config option "<use-network>" to false would solve the problem. It didn't. So, any ideas how to allow total permissions to swf files I create?

EDIT: Nevermind. I'm an idiot. Must, remember to recompile the proggy after changing the flex config. :S Problem solved!


Thanks for your help man.

wvxvw
April 12th, 2009, 03:16 PM
Oh, well, I wasn't really helpful :) Glad you solved it anyway :)
(BTW. it's a bat!)