Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 05-16-2012, 06:57 PM   #1
Registered User
 
Join Date: Mar 2012
Posts: 21
Default is this making sense? I created two dispatchEvent s

I created two dispatchEvent. I'm trying to have a double safety on data retrieval. i have a dispatchEvent in contentLoaded and the last dispatchEvent in loadedContent. If i had loadedContent by itself it will still work. It this unnecessary? does it make sense to listen for a complete event and then launch another? THanks.................

package com.class.php
{
import flash.events.*;
import flash.net.*;

public class Grabber extends EventDispatcher
{
public var phpFile:String;
public var remoteFile:String;
public var req:URLRequest;
private var vars:URLVariables = new URLVariables();
private var loader:URLLoader = new URLLoader();
public var data:String;

public function Grabber()
{

}

public function load(php:String, remote:String):void
{
phpFile = php;
remoteFile = remote;
req = new URLRequest(phpFile);
vars.fileName = remoteFile;
req.data = vars;
req.method = URLRequestMethod.POST;
loader.load(req);
loader.addEventListener(Event.COMPLETE, contentLoaded, false, 0, true);
addEventListener("checkEvent", loadedContent, false, 0, true);
}

//I guess i want to have a double safety to make sure I'm getting data
private function contentLoaded(event:Event):void
{

dispatchEvent(new Event("checkEvent"));
}

//data is passes to the fla file. it works fine
private function loadedContent(event:Event):void
{
data = loader.data;
dispatchEvent(new Event(Event.COMPLETE));
}

}//END CLASS GRABBER
}//END PACKAGE
infinitaspi@yahoo.com is offline   Reply With Quote
Old 05-16-2012, 07:11 PM   #2
abeall
Senior Member
 
Join Date: Feb 2006
Location: Washington, DC
Posts: 2,796
Send a message via AIM to abeall
Default

Hi, please post your code inside [as][/as] so it's formatted properly on the forum...

What you have does seem a bit redundant, why not just use the loader's complete event handler?
__________________
Aaron Beall | Flash portfolio | Fireworks extensions | Twitter
abeall is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:12 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.