ActionScript 3.0 - Change Url import from a Class - arrays

I want to import an XML file and add it to a grid. That part I have done, but I want to use the class to change the XML file. Now, the file is stuck at the original file.
Example class:
package {
import fl.controls.dataGridClasses.DataGridColumn;
import fl.data.DataProvider;
import flash.net.*;
import flash.events.*;
import fl.controls.DataGrid;
import fl.data.DataProvider;
import flash.display.Stage;
import flash.display.MovieClip
public class Tabellkamp extends MovieClip {
public var link1: String = new String("_blank");
public var request: URLRequest;
public var loader: URLLoader;
public var gridd: DataGrid = new DataGrid();
public function Tabellkamp() {
loader.load(request);
loader.addEventListener(Event.COMPLETE, loaderCompleteHandler);
var loader: URLLoader = new URLLoader();
loader.load(new URLRequest(link1));
}
function loaderCompleteHandler(event: Event): void {
var teamXML: XML = new XML(loader.data);
var firstCol: DataGridColumn = new DataGridColumn("somthing on the xml");
firstCol.headerText = "first";
gridd.columns = [firstCol];
addChild(gridd);
}
}
}
Main timeline/ other class:
public class Lagegridd extends MovieClip {
public function Lagegridd() {
btn_1.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);
function fl_MouseClickHandler(event: MouseEvent) {
var newXML: Tabellkamp = new Tabellkamp();
newXML.link1="newxmlfile.xml";
addChild(newXML);
}
Maybe some other problems with the code, but the main question is how to change the url, and then addChild(). Never mind the grid, it is just an example.
I appreciate some help, on how to use the class several times.

Pretty simple. Destroy the existing instance and create a new one. Also, don't declare functions inside other functions.
public class Lagegridd extends MovieClip
{
public function Lagegridd()
{
btn_1.addEventListener(MouseEvent.CLICK, onClick);
}
private var currentGrid:Tabellkamp;
private var gridSource:Array = ["file1.xml", "file2.xml", "file3.xml"];
private function onClick(e:MouseEvent):void
{
// Obtain the first element from the list.
var anUrl:String = gridSource.shift();
changeGrid(anUrl);
}
private function changeGrid(url:String):void
{
if (currentGrid)
{
removeChild(currentGrid);
// Another cleanup routines here, if necessary.
}
currentGrid = new Tabellkamp;
// You need to define this function instead of loading
// data from "link1" inside the object constructor.
currentGrid.loadData(url);
addChild(currentGrid);
}
}
UPD: OOP example.
package
{
import flash.display.Sprite;
import flash.system.System;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.SecurityErrorEvent;
import flash.net.URLRequest;
import flash.net.URLLoader;
// Don't use MovieClip if you don't have frames and timelines.
public class LasteinnXML extends Sprite
{
public var url:String;
public var loader:URLLoader;
public var dataProvider:XML;
public function load(path:String):void
{
url = path;
loader = new URLLoader;
loader.addEventListener(Event.COMPLETE, onData);
// Always handle erroneous cases. Last three arguments are there
// because it is wise to not unsubscribe from these events but
// let the garbage collector decide when to destroy them.
loader.addEventListener(IOErrorEvent.IO_ERROR, onError, false, 0, true);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onError, false, 0, true);
// You don't need to store the request object.
loader.load(new URLRequest(url));
}
private function onData(e:Event):void
{
try
{
dataProvider = new XML(loader.data);
finishLoading();
}
catch (fail:Error)
{
// There's another erroneous case even if loading is fine:
// Invalid XML data. Always chack for it as well.
onError(null);
}
// Handle the SUCCESSFUL case here.
}
private function finishLoading():void
{
// Cleanup routines. Dispose of your objects once you don't need them.
if (!loader) return;
loader.removeEventListener(Event.COMPLETE, onData);
loader = null;
}
private function onError(e:Event):void
{
// In case the object was already destroyed
if (!loader) return;
finishLoading();
// Handle the ERRONEOUS case here.
}
public function destroy():void
{
finishLoading();
// The recommended way of cleaning XML data up.
if (dataProvider)
{
System.disposeXML(dataProvider);
dataProvider = null;
}
}
}
}
Usage:
var A:LasteinnXML = new LasteinnXML;
var B:LasteinnXML = new LasteinnXML;
var C:LasteinnXML = new LasteinnXML;
addChild(A);
addChild(B);
addChild(C);
A.load("filea.xml");
B.load("fileb.xml");
C.load("filec.xml");
C.destroy();
removeChild(C);

Related

Missing properties in TypeScript

class RolloutStoreClass {
import { observable, action, makeAutoObservable } from "mobx";
public queue = observable<IDeploymentProject>([]);
public inProcess = observable<IDeploymentProject>([]);
public successfull = observable<IDeploymentProject>([]);
public failed = observable<IDeploymentProject>([]);
constructor() {
makeAutoObservable(this);
}
#action
private clearQueue(): void {
this.queue = [] ;
this.inProcess = [];
this.failed = [];
this.successfull = [];
}
}
export const RolloutStore = new RolloutStoreClass();
I get the issue on the clearQueue Function exactlly on this. queue
Error is:
In the "never []" type, the following properties of the "Observable Array " type are missing: "spliceWithArray, clear, replace, remove, toJSON".
You either need to make your queue (and other fields) regular array, all observability will still work.
Or use .clear() method inside clearQueue:
private clearQueue(): void {
this.queue.clear();
// ...
}
One more thing: when you use makeAutoObservable you don't need to explicitly mark action's observable's and so on, you can just drop all the decorators:
class Foo {
// Don't need explicit observable decorator
public queue: IDeploymentProject[] = [];
// ...
constructor() {
makeAutoObservable(this);
}
// You can remove action decorator
private clearQueue(): void {
this.queue = [] ;
this.inProcess = [];
this.failed = [];
this.successfull = [];
}
}

actionscript 3 - using array in multiple classes

So I have 2 files, where I want to be able to access an array from 1 file in the other.
package code {
import flash.display.DisplayObjectContainer;
import flash.display.MovieClip;
import flash.ui.Keyboard;
import code.*;
public class Init extends MovieClip {
public var _solidObjects: Array;
public function Init() {
_solidObjects = [wall01, wall02, wall03, wall04];
}
}
}
How would I be able to access the _solidObjects array from another class in a seperate file?
Any help would be appreciated as I have been trying for a while with no success, thanks.
Constructors can be passed variables. For example:
First class:
package code {
public class Init extends MovieClip {
public var solidObjects: Array;
public function Init() {
solidObjects = [wall01, wall02, wall03, wall04];
}
}
Second class:
package code {
public class SomeClass extends MovieClip {
public var solidObjects: Array;
public function SomeClass(param:Array) {
this.solidObjects = param;
}
}
}
Usage context:
var initObj:Init = new Init();
var secondObject:SomeClass = new SomeClass(initObj.solidObjects);

actionscript 3 load URL from array

I'm making a mp3/steaming radio with MVC, where I'm trying to load an URL from a array.
I have a radio class:
public class Radio
{
private var titel:String;
private var url:URLRequest;
private var cover:Bitmap;
public function Radio(titel:String, url:URLRequest, cover:Bitmap)
{
this.titel = titel;
this.url = url;
this.cover = cover;
}
public function getTitel():String {
return titel;
}
public function getURL():URLRequest {
return url;
}
public function getCover():Bitmap {
return cover
}
}
In the controller i have this:
public function selectRadio(radio:Radio):void{
model.selectRadio(radio);
}
In view I have the button with the eventlistner:
radio.addEventListener(MouseEvent.CLICK, function():void {
controller.selectRadio(model.getRadio(0));
});
And finally in the model i have:
private var radio:Radio = new Radio("P3", new URLRequest("http://live-icy.gss.dr.dk:80/A/A05L.mp3"), drp3);
private var radioArray:Array = new Array(radio);
private var r:Number;
public function selectRadio(radio:Radio):void {
var s:Sound = new Sound();
var chan:SoundChannel = s.play();
s.load();
trace("radio");
}
public function getRadios():Array {
return radioArray;
trace("All radio channels collected");
}
public function getRadio(radioNumber:int):Radio {
r = radioNumber;
return radioArray[radioNumber];
trace("Actual radio collected");
}
The problem is in the selectRadio function. I don't know how to load the URL in the arrays. It should be s.load(--something in here--); The reason why I'm doing this, is because I want to have multiple radio stations.
Hope you can help :)
var s:Sound = new Sound(radio.getURL());
var chan:SoundChannel = s.play();
load function will be called automatically by the constructor, also don't forget to stop previous SoundChannel.
and here: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Sound.html you will find everything about Sound

Saving data from DDBB into AS class

i am trying to make a "game" in Flex similar to Shake&Fidget. I'm saving all the user data in a mysql database and I retrieve the data using ZendFramework (PHP).
I thought of saving all the user and character info I'm going to need into am AS class so I can use that data in every view.
The data recived from the database is correct. I was able to load it in my app labbels but everytime i changed views it had to ask it again, so i thought of making this classes in order to just ask once for the information.
I'll post here the files so it's all more clear.
ViewNavigatorAplication.mxml
<s:ViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
firstView="views.RotrHomeView"
persistNavigatorState="true">
<fx:Script>
<![CDATA[
import flash.net.registerClassAlias;
import valueObjects.Character;
registerClassAlias("Character", valueObjects.Character);
]]>
</fx:Script>
The first View goes to the login screen, it works OK. So i'll go to the view that loads and "tries" to show the character data.
char_panel.mxml
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:usersservice1="services.usersservice1.*"
title="Character Sheet"
viewActivate="char_panel_viewActivateHandler()">
<fx:Script>
<![CDATA[
import mx.binding.utils.*;
import mx.events.FlexEvent;
import mx.rpc.events.ResultEvent;
import valueObjects.Character;
//[Bindable]protected var character:Character = new Character();
public function updateStats():void{
var str:int = parseInt(getGlobalStatsResult.lastResult.globalSTR) + parseInt(getCharacterStatsResult.lastResult.str);
var dex:int = parseInt(getGlobalStatsResult.lastResult.globalDEX) + parseInt(getCharacterStatsResult.lastResult.dex);
var intel:int = parseInt(getGlobalStatsResult.lastResult.globalINT) + parseInt(getCharacterStatsResult.lastResult.intel);
var cha:int = parseInt(getGlobalStatsResult.lastResult.globalCHA) + parseInt(getCharacterStatsResult.lastResult.cha);
var sta:int = parseInt(getGlobalStatsResult.lastResult.global_VIT) + parseInt(getCharacterStatsResult.lastResult.vit);
data.modStats(str,intel,cha,sta,dex)
data.showStats(lb_show_str,lb_show_dex,lb_show_int,lb_show_cha,lb_show_vit);
//character.showStats(lb_show_str,lb_show_dex,lb_show_int,lb_show_cha,lb_show_vit);
}
public function char_panel_viewActivateHandler():void{
if(!data){
data = new Character();
}
getCharacterStatsResult.token = usersService1.getCharacterStats("user01");
getGearListResult.addEventListener(ResultEvent.RESULT,onResult);
getGearListResult.token = usersService1.getGearList();
}
public function onStatsResult(event:ResultEvent):void{
if(getGlobalStatsResult.lastResult.globalSTR != null){
updateStats();
}
}
public function onResult(event:ResultEvent):void{
if(getGearListResult.lastResult[0].itemName != null){
getGlobalStatsResult.addEventListener(ResultEvent.RESULT, onStatsResult);
getGlobalStatsResult.token = usersService1.getGlobalStats("user01");
currentState = "Character";
}
}
]]>
</fx:Script>
<s:states>
<s:State name="Loading"/>
<s:State name="Character"/>
</s:states>
<fx:Declarations>
<s:CallResponder id="getCharacterStatsResult"/>
<s:CallResponder id="getGearListResult"/>
<s:CallResponder id="getGlobalStatsResult"/>
<usersservice1:UsersService1 id="usersService1"/>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Label id="lb_show_str" includeIn="Character" x="119" y="46" text=""/>
<s:BusyIndicator includeIn="Loading" left="172" right="171" top="148" bottom="424"
horizontalCenter="0" verticalCenter="-138"/>
<s:Label id="lb_show_int" includeIn="Character" x="119" y="90"/>
<s:Label id="lb_show_cha" includeIn="Character" x="119" y="139"/>
<s:Label id="lb_show_vit" includeIn="Character" x="119" y="191"/>
<s:Label id="lb_show_dex" includeIn="Character" x="119" y="243"/>
As for the AS classes:
Character.as
package valueObjects{
import mx.data.ChangedItems;
import mx.messaging.channels.StreamingAMFChannel;
import spark.components.Label;
import spark.skins.spark.StackedFormHeadingSkin;
[Bindable]
public class Character
{
private var _name:String;
private var _stats:FinalStats;
private var _gear:GearList;
public function Character()
{
this._stats = new FinalStats();
this._gear = new GearList();
}
public function modStats(str:int,intel:int,cha:int,sta:int,dex:int):void{
this._stats.modStr(str);
this._stats.modInt(intel);
this._stats.modCha(cha);
this._stats.modVit(sta);
this._stats.modDex(dex);
}
public function getStats():Array{
var aStats:Array;
aStats["str"]=this._stats.getStr();
aStats["int"]=this._stats.getInt();
aStats["cha"]=this._stats.getCha();
aStats["sta"]=this._stats.getVit();
aStats["dex"]=this._stats.getDex();
return aStats;
}
public function setName(charName:String):void{
this._name = charName;
}
public function getName():String{
return this._name;
}
public function showStats(lbSTR:Label, lbDEX:Label, lbINT:Label, lbCHA:Label, lbVIT:Label):void{
lbSTR.text = "" + this._stats.getStr();
lbDEX.text = "" + this._stats.getDex();
lbINT.text = "" + this._stats.getInt();
lbCHA.text = "" + this._stats.getCha();
lbVIT.text = "" + this._stats.getVit();
}
}}
FinalStats.as
package valueObjects{
public class FinalStats
{
private var str:int = 0;
private var intel:int = 0;
private var cha:int = 0;
private var sta:int = 0;
private var dex:int = 0;
public function FinalStats()
{
}
public function getStr():int{
return this.str;
}
public function modStr(x:int):void{
this.str+=x;
}
public function getDex():int{
return this.dex;
}
public function modDex(x:int):void{
this.dex+=x;
}
public function getInt():int{
return this.intel;
}
public function modInt(x:int):void{
this.intel+=x;
}
public function getCha():int{
return this.cha;
}
public function modCha(x:int):void{
this.cha+=x;
}
public function getVit():int{
return this.sta;
}
public function modVit(x:int):void{
this.sta+=x;
}
}
}
And the last one GearList.as
package valueObjects{
import mx.data.ChangedItems;
import mx.messaging.channels.StreamingAMFChannel;
import spark.components.Label;
import spark.skins.spark.StackedFormHeadingSkin;
public class GearList
{
private var _headID:String;
private var _shoulderID:String;
private var _chestID:String;
private var _bracersID:String;
private var _glovesID:String;
private var _pantsID:String;
private var _bootsID:String;
private var _main_handID:String;
private var _off_handID:String;
public function GearList()
{
}
public function showStats(lbHead:Label, lbShoulder:Label, lbChest:Label, lbBracer:Label, lbGlove:Label, lbPants:Label, lbBoots:Label, lbMainHand:Label, lbOffHand:Label):void{
lbHead.text = ""+this._headID;
lbShoulder.text = ""+this._shoulderID;
lbChest.text = ""+this._chestID;
lbBracer.text = ""+this._bracersID;
lbGlove.text = ""+this._glovesID;
lbPants.text = ""+this._pantsID;
lbBoots.text = ""+this._bootsID;
lbMainHand.text = ""+this._main_handID;
lbOffHand.text = ""+this._off_handID;
}
public function getOff_handID():String
{
return _off_handID;
}
public function setOff_handID(value:String):void
{
_off_handID = value;
}
public function getMain_handID():String
{
return _main_handID;
}
public function setMain_handID(value:String):void
{
_main_handID = value;
}
public function getBootsID():String
{
return _bootsID;
}
public function setBootsID(value:String):void
{
_bootsID = value;
}
public function getPantsID():String
{
return _pantsID;
}
public function setPantsID(value:String):void
{
_pantsID = value;
}
public function getGlovesID():String
{
return _glovesID;
}
public function setGlovesID(value:String):void
{
_glovesID = value;
}
public function getBracersID():String
{
return _bracersID;
}
public function setBracersID(value:String):void
{
_bracersID = value;
}
public function getChestID():String
{
return _chestID;
}
public function setChestID(value:String):void
{
_chestID = value;
}
public function getShoulderID():String
{
return _shoulderID;
}
public function setShoulderID(value:String):void
{
_shoulderID = value;
}
public function getHeadID():String
{
return _headID;
}
public function setHeadID(value:String):void
{
_headID = value;
}
}}
If you are still here you have all my respect :D
When i try it out, i get the following error. I've tried in char_panel.mxml using Character::modStats(...) instead of data.modStats i'll put the error log under this one.
Error log when using data.modStats(...)
TypeError: Error #1006: modStats is not a function.
at views::char_panel/updateStats()[C:\Users\Zebrah\Rotr\Rotr\src\views\char_panel.mxml:23]
at views::char_panel/onStatsResult()[C:\Users\Zebrah\Rotr\Rotr\src\views\char_panel.mxml:39]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.rpc::CallResponder/result()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\CallResponder.as:122]
at mx.rpc::AsyncToken/http://www.adobe.com/2006/flex/mx/internal::applyResult()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\AsyncToken.as:239]
at mx.rpc.events::ResultEvent/http://www.adobe.com/2006/flex/mx/internal::callTokenResponders()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\events\ResultEvent.as:207]
at mx.rpc::AbstractOperation/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\AbstractOperation.as:244]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:318]
at mx.rpc::Responder/result()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\Responder.as:56]
at mx.rpc::AsyncRequest/acknowledge()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:84]
at NetConnectionMessageResponder/resultHandler()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\messaging\channels\NetConnectionChannel.as:552]
at mx.messaging::MessageResponder/result()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\messaging\MessageResponder.as:235]
Error Log using Character::modStats(...)
Error: Error #1034: Type Coercion failed: cannot convert valueObjects::Character$ to Namespace.
at views::char_panel/updateStats()[C:\Users\Zebrah\Rotr\Rotr\src\views\char_panel.mxml:23]
at views::char_panel/onStatsResult()[C:\Users\Zebrah\Rotr\Rotr\src\views\char_panel.mxml:39]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.rpc::CallResponder/result()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\CallResponder.as:122]
at mx.rpc::AsyncToken/http://www.adobe.com/2006/flex/mx/internal::applyResult()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\AsyncToken.as:239]
at mx.rpc.events::ResultEvent/http://www.adobe.com/2006/flex/mx/internal::callTokenResponders()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\events\ResultEvent.as:207]
at mx.rpc::AbstractOperation/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\AbstractOperation.as:244]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:318]
at mx.rpc::Responder/result()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\Responder.as:56]
at mx.rpc::AsyncRequest/acknowledge()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:84]
at NetConnectionMessageResponder/resultHandler()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\messaging\channels\NetConnectionChannel.as:552]
at mx.messaging::MessageResponder/result()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\messaging\MessageResponder.as:235]
Thanks in advance to anyone that get so far in this help cry :D i'd apreciate any sugestions that you can make.
ok so the reason it doesn't work with data is that event though you said
data = new Character();
data is still actually an object (that now looks like a character). to make it work
var myChar:Character = Character(data); // cast it to a Character and it now knows the method
myChar.modStats()
the reason the other call didn't work is the way you called it:
Character::modStats(...)
This say look for a method called modStats in the namespace Character. Instead call this
character.modStats()
and it will work.
You Sir are my personal Hero :D, i've just tried it and it shows the data.
I changed the constructor for the character in Character.AS like this:
public function Character(obj:Object)
{
this._stats = new FinalStats();
this._gear = new GearList();
}
I'm not entirely sure if this is correct, but as you mentioned in your answer:
var myChar:Character = Character(data);
I supose i'll have to use that data object to initialice myChar...am i right? Well, later when i have the time i'll try to add new views and buttons to go through views and see if the data is there :D

Button and String incompatibility from an Array in AS3

So I have an inventory with items and the array has the instance name of the items, which are movieclips. I want to make it so that all the items will have their button mode become true.
Everything works up to i.buttonMode = true. I get this:1119: Access of possibly undefined property buttonMode through a reference with static type String. But if I use the instance name, something like Inv_1.buttonMode = true works.
So the main question is I guess, how can you iterate through an array and make each of the instance names into buttons?
(I also tried getChildByName.(i).buttonMode = true;) and that didn't work. :S
package {
import flash.display.*;
import flash.events.*;
public dynamic class Drag extends MovieClip {
var Inventory:Array = ["Inv_1", "Inv_2", "Inv_3", "Inv_4t", "Inv_5"];
public function Drag():void {
for (var i:String in Inventory){
i.buttonMode = true;
}
}
}
}
Your Inventory array is a collection of strings, not MovieClips.
If those are instance names of child display objects, implement getChildByName as a function, not dot notation.
Also note getChildByName returns DisplayObject, which does not define buttonMode. Cast the object as MovieClip or appropriate type.
package {
import flash.display.*;
import flash.events.*;
public dynamic class Drag extends MovieClip {
var Inventory:Array = ["Inv_1", "Inv_2", "Inv_3", "Inv_4t", "Inv_5"];
public function Drag():void {
for (var i:String in Inventory) {
MovieClip(getChildByName(i)).buttonMode = true;
}
}
}
}
you have created an array of strings, not movie clip instances.
declare your instance names and add them to a vector:
package
{
import flash.display.*;
import flash.events.*;
public dynamic class Drag extends MovieClip
{
private var Inv_1:MovieClip;
private var Inv_2:MovieClip;
private var Inv_3:MovieClip;
private var Inv_4:MovieClip;
private var Inv_5:MovieClip;
public function Drag():void
{
var Inventory:Vector.<MovieClip> = new <MovieClip>[Inv_1, Inv_2, Inv_3, Inv_4t, Inv_5];
for (var i:MovieClip in Inventory)
{
i.buttonMode = true;
}
}
}
}

Resources