Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: 1 2 [3] 4
Print
Author Topic: Loadup - A PureMVC AS3 Utility  (Read 38543 times)
philipSe
Sr. Member
****
Posts: 139


View Profile Email
« Reply #30 on: November 18, 2009, 04:46:14 »

Since my previous post, it has occurred to me that...
- the intermittent, ad hoc product loads could also be done with a single instance of LoadMonitorProxy, where keepResourceListOpen() is invoked
- then, as required, a product resource can be added to the monitor; it will be loaded as usual
- there will not be a loading complete notification until closeResourceList() is invoked and all outstanding resources have been loaded.

Just thought I'd mention it.
----Philip
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #31 on: November 18, 2009, 09:35:13 »

Although it seems like you might, in reality, you don't really want to query the StateMachine for the current State and take branching actions based on State. That would lead to a brittle app where it is difficult to refactor the FSM.

Instead, you kick off actions when you arrive in a given State, and you wait until those actions have completed before sending off an ACTION notification to kick the StateMachine into another State.

-=Cliff>
Logged
pirol
Newbie
*
Posts: 7


View Profile Email
« Reply #32 on: November 30, 2009, 03:27:35 »

Hi,
Because I just started to programm with pureMVC, I have a question about loading images after I loaded a xml.
I use the Startup Manager from this site to load a xml and a css file. Now i have a ImageVO class which contents the urls of the images.
My problem is where I should put the loading Code and the ImageData.
On one hand it is a Data so it should be in a VO but on the other hand it is easier to load it in the view.

What way is the best:
Should I put the loading code and the data in the ImageVO
Should I create a new VO and a new Proxy
Should I load it in a Mediator at put the data into the viewComponent
Should I load it directly in the view

I hope u can understand my problem.


Logged
Ross
Newbie
*
Posts: 2


View Profile Email
« Reply #33 on: February 10, 2010, 01:42:44 »

Hi Philip,
Thanks for this great utility. I just started a big project with a lot of asset-loading stuff and it's really amazing, how easily and clearly I can manage these loading operations with your Loadup utility. Thanks to Tek (http://www.tekool.net), I use it in a pure actionscript project.
But now I came to a problem. I would like to use this utility to load sound assets (.mp3). In fact, your utility does load such assets. At least I think it does. But I don't know how to cast this asset properly to a sound object.
I wrote an AssetOfTypeFlashAudio class, extending the AssetBase class and implementing IAsset with a getter method, that returns a Sound object. Finally I added a AUDIO_ASSET_TYPE const to the Loadup class.

When the asset is loaded now, it's returned by the AssetOfTypeFlashAudio class. Then I try to cast it with var sound:Sound = audioAssetClass.sound . This works, too. But as soon as I try to play it (sound.play) it throws an error #1009: Cannot access a property or method of a null object reference.

Has anyone already used this utility to load sound assets?

Thank you for your time.
Logged
philipSe
Sr. Member
****
Posts: 139


View Profile Email
« Reply #34 on: February 11, 2010, 04:35:20 »

I presume the key factor here is the loader class.  You don't mention the AssetFactory /IAssetFactory class and interface.

By default, a file with extension .mp3 will get treated the same as a text file, since there is no specific recognition of the mp3 file type.  Hence, by default, the file will get loaded by a loader of type URLLoader (see AssetFactory and AssetTypeMap).

I note that the Sound class itself has the facility to load mp3 files, so maybe the Sound class must be used as the loader.  This would require a new loader class in Loadup, using Sound, and implementing the IAssetLoader interface.

No doubt there are others out there that can comment more knowledgeably on this requirement.
----Philip
Logged
Ross
Newbie
*
Posts: 2


View Profile Email
« Reply #35 on: February 11, 2010, 09:56:01 »

Thanks for this tip. I actually thought about this loader issue. But I didn't find the right place to change it... Now I found it and it's working.
I added a new loader AssetLoadBySoundLoader.as, which organizes the sound load. The only problem is, that the loaderContext should be of type SoundLoaderContext. If I change it, it cannot implement IAssetLoader... So I just set this parameter to null (loader.load( url, null)).
I'll send the files to you, so you can add them to the package, if you want.
Logged
philipSe
Sr. Member
****
Posts: 139


View Profile Email
« Reply #36 on: February 12, 2010, 05:33:53 »

@Ross
Thanks for this work.  It should be a great addition to the utility.  I will incorporate it into a new release as soon as I can.  I expect the release to also include support for flv type files, based on work contributed by another forum member, and it should also address the flash-only requirement as dealt with previously on this forum.
----Philip
Logged
Tekool
Sr. Member
****
Posts: 192


View Profile WWW Email
« Reply #37 on: February 12, 2010, 05:56:02 »

Excellent news Philip. If you want to find the latest version of the source code for the Flash Loadup dependencies, you can find it here or through my blog post.
Logged
svleeuwen
Newbie
*
Posts: 6


View Profile Email
« Reply #38 on: June 09, 2010, 04:26:19 »

Hi Phillip,

Is there a way to cancel an active loading sequence?

Thnx in advance,
Sander
Logged
philipSe
Sr. Member
****
Posts: 139


View Profile Email
« Reply #39 on: June 10, 2010, 10:18:17 »

@Sander

The answer is No, I suppose.  But let me contribute the following thoughts
  • the difficulty is that the resource loads are typically requested as asynchronous services to be executed on a remote server, so once requested, it is hard to influence them
  • if you have dependencies within the set of resources to be loaded, then if a load fails, the dependent loads will not commence
  • if, after starting the load via the loadResources() call, you decide that you no longer want the resources, you could simply discard the response messages as they return to you, and send a 'load failed' notification for each such response, including a 'do not retry' instruction; the objective of such failed notifications is to move loadup to the 'finished incomplete' state as soon as possible.

Hope this helps.
----Philip
Logged
svleeuwen
Newbie
*
Posts: 6


View Profile Email
« Reply #40 on: June 14, 2010, 02:27:41 »

Hi Philip,

Thanks, the 3rd suggestion should be the way to go in my case.
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #41 on: July 29, 2010, 03:01:16 »

Philip has updated the Loadup utility to Version 2.1 with some new asset types, separate flex and flash swcs and a new build script to create them. Note the Flex specific classes have been renamed to reflect it.

See the Release Notes: http://trac.puremvc.org/Utility_AS3_Loadup/wiki/ReleaseNotes

-=Cliff>
Logged
svleeuwen
Newbie
*
Posts: 6


View Profile Email
« Reply #42 on: July 06, 2011, 04:57:01 »

Hi Philip,

It has been a while since i worked with this utility. But i want to come back to my previous question.

You pointed out the following:
* if, after starting the load via the loadResources() call, you decide that you no longer want the resources, you could simply discard the response messages as they return to you, and send a 'load failed' notification for each such response, including a 'do not retry' instruction; the objective of such failed notifications is to move loadup to the 'finished incomplete' state as soon as possible.

How would that fit in the new Loadup situation?

Can you give me an example of how to discard the response messages and send a load failed notification?
This happends in the mediator who initiated the loading right?

Thanks in advance, Sander
Logged
philipSe
Sr. Member
****
Posts: 139


View Profile Email
« Reply #43 on: July 07, 2011, 09:01:29 »

Here is an approach. There may be other and better approaches. It does not involve the mediator.

Let there be a Loadup instance called lux, with name luxName.  Let there be a new proxy, of type Proxy, with name luxHelper, where luxHelper is easily derived from luxName.  luxName and luxHelper are Strings or course.  For example, luxHelper = luxName + "Helper".

If the event occurs that means we would like to abort the loadup process
- create and register the luxHelper proxy:  = new Proxy( luxHelper, new Boolean(true) );
- so, the data property of the proxy is a Boolean.

For each ILoadupProxy proxy that is interacting with lux, assume there is a 'loaded' method and a 'failed' method, invoked within the app. In the loaded method, we have
if ( facade.hasProxy( luxHelper ) {
    retrieve the helper proxy
    if the helper proxy data is true, invoke the 'failed' method and quit the loaded method
    else carry on with the loaded method
}

I have avoided making a new class for the helper proxy, but it could be better to have one. Also, the helper proxy could be created and registered at the outset, witrh data set to false.

I hope this makes sense and that it helps.
----Philip
Logged
svleeuwen
Newbie
*
Posts: 6


View Profile Email
« Reply #44 on: July 13, 2011, 03:11:19 »

Hi Philip,

Thanks, it works. But i'm not sure if i interpreted everything ok.
I expanded the AssetProxy's loadingComplete function as following:

:
public function loadingComplete( loadedData :Object ) :void {
    loaded = true;
    assetData = loadedData;
    loadingErrorMessage = "";

    if(facade.hasProxy(assetGroupProxy.getLUMonitorProxyName() + "_HELPER"))
    {
var helperProxy:IProxy = facade.retrieveProxy(assetGroupProxy.getLUMonitorProxyName() + "_HELPER") as IProxy
if(helperProxy.getData())
{
    doSendNotification( Loadup.ASSET_LOAD_FAILED, getProxyName() );
}
    }
    else
    {
doSendNotification( Loadup.NEW_ASSET_AVAILABLE, asset );
assetGroupProxy.loadingProgress( this, /* force report */ true );
doSendNotification( Loadup.ASSET_LOADED, getProxyName() );
    }
}

Is this the way to go?

And maybe if I explain the situation in my application more clearly you could give some more suggestions.

I have a mediator wich starts loading 2 swf's. The load is initiated by a click on a chapterbutton.
There are multiple chapters and the user is able to switch between them.
If the user clicks chapter 1, two swf's start loading.
If the user clicks chapter 2 while the two swf's have not yet finished loading, it should cancel the first two and start loading those of chapter 2.

I hope this is understandable :)

Thnx, Sander


Logged
Pages: 1 2 [3] 4
Print