Flash events dont fire when the SWF is on a website

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Flash events dont fire when the SWF is on a website

slenkar
try this code:
[code]package ;

import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.events.Event;
import flash.Lib;
import flash.net.URLRequest;

/**
 * ...
 * @author keef
 */

class Main
{
       
        static function main()
        {
                var l:Loader = new Loader();
                var u:URLRequest = new URLRequest("http://www.blitzbasic.com/img/fairway_solitaire.jpg");
                l.load(u);
                Lib.current.addChild(l);
               
                l.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
               
        }
        public static function completeHandler(eve:Event)
        {
       
        Lib.current.addChild(eve.currentTarget.content);
        eve.currentTarget.content.x = 200;
        }
}[/code]


if the event fires the image moves over 200 pixels.

When I run this on my PC it works, but when i upload the SWF to a website the image stays at 0,0,

check out www.turnbased.in/event.swf for an uploaded version
Reply | Threaded
Open this post in threaded view
|

Re: Flash events dont fire when the SWF is on a website

Gamehaxe
Hi,
Just a guess, but try adding the listener before you call "load".

Hugh

>
> try this code:
> [code]package ;
>
> import flash.display.Loader;
> import flash.display.LoaderInfo;
> import flash.events.Event;
> import flash.Lib;
> import flash.net.URLRequest;
>
> /**
>  * ...
>  * @author keef
>  */
>
> class Main
> {
>
> static function main()
> {
> var l:Loader = new Loader();
> var u:URLRequest = new
> URLRequest("http://www.blitzbasic.com/img/fairway_solitaire.jpg");
> l.load(u);
> Lib.current.addChild(l);
>
> l.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
>
> }
> public static function completeHandler(eve:Event)
> {
>
> Lib.current.addChild(eve.currentTarget.content);
> eve.currentTarget.content.x = 200;
> }
> }[/code]
>
>
> if the event fires the image moves over 200 pixels.
>
> When I run this on my PC it works, but when i upload the SWF to a website
> the image stays at 0,0,
>
> check out www.turnbased.in/event.swf for an uploaded version

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Flash events dont fire when the SWF is on a website

slenkar
In reply to this post by slenkar
the 'progress' event does fire however, but 'complete' and 'init' do not
Reply | Threaded
Open this post in threaded view
|

Re: Flash events dont fire when the SWF is on a website

Gamehaxe
In reply to this post by slenkar
Hi,
Also, you may not be allowed to load a jgg from one website from a swf on  
a different website.
I think there is a "cross domiain policy" file you need to setup.

Hugh

>
> try this code:
> [code]package ;
>
> import flash.display.Loader;
> import flash.display.LoaderInfo;
> import flash.events.Event;
> import flash.Lib;
> import flash.net.URLRequest;
>
> /**
>  * ...
>  * @author keef
>  */
>
> class Main
> {
>
> static function main()
> {
> var l:Loader = new Loader();
> var u:URLRequest = new
> URLRequest("http://www.blitzbasic.com/img/fairway_solitaire.jpg");
> l.load(u);
> Lib.current.addChild(l);
>
> l.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
>
> }
> public static function completeHandler(eve:Event)
> {
>
> Lib.current.addChild(eve.currentTarget.content);
> eve.currentTarget.content.x = 200;
> }
> }[/code]
>
>
> if the event fires the image moves over 200 pixels.
>
> When I run this on my PC it works, but when i upload the SWF to a website
> the image stays at 0,0,
>
> check out www.turnbased.in/event.swf for an uploaded version

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Flash events dont fire when the SWF is on a website

slenkar
I tried to do that before and failed
and after your post I tried again and it worked! thanks.

The thing that threw me off is that it does load the image with progress events but never 'completes'
Reply | Threaded
Open this post in threaded view
|

Re: Flash events dont fire when the SWF is on a website

Baluta Cristian
This is what i get, but the image is loaded. You should listen for errors too anyway.

SecurityError: Error #2122: Security sandbox violation: LoaderInfo.content: http://www.turnbased.in/event.swf cannot access http://www.blitzbasic.com/img/fairway_solitaire.jpg. A policy file is required, but the checkPolicyFile flag was not set when this media was loaded.

at flash.display::LoaderInfo/get content()

at Main$/completeHandler()[C:\phpchess\My Dropbox\Public\eventcompletebug\src/Main.hx:30]



On Mon, Sep 6, 2010 at 6:37 AM, slenkar <[hidden email]> wrote:

I tried to do that before and failed
and after your post I tried again and it worked! thanks.

The thing that threw me off is that it does load the image with progress
events but never 'completes'
--
View this message in context: http://haxe.1354130.n2.nabble.com/Flash-events-dont-fire-when-the-SWF-is-on-a-website-tp5501880p5501910.html
Sent from the Haxe mailing list archive at Nabble.com.

--
haXe - an open source web programming language
http://haxe.org



--
Băluță Cristian
http://ralcr.com
http://imagin.ro

--
haXe - an open source web programming language
http://haxe.org