| 1 |
/* |
|---|
| 2 |
* Copyright(c) 2007 Mk-10 cellfusion.jp |
|---|
| 3 |
* |
|---|
| 4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
|---|
| 5 |
* you may not use this file except in compliance with the License. |
|---|
| 6 |
* You may obtain a copy of the License at |
|---|
| 7 |
* |
|---|
| 8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|---|
| 9 |
* |
|---|
| 10 |
* Unless required by applicable law or agreed to in writing, software |
|---|
| 11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|---|
| 12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, |
|---|
| 13 |
* either express or implied. See the License for the specific language |
|---|
| 14 |
* governing permissions and limitations under the License. |
|---|
| 15 |
*/ |
|---|
| 16 |
|
|---|
| 17 |
import jp.cellfusion.commands.CommandBase; |
|---|
| 18 |
|
|---|
| 19 |
/** |
|---|
| 20 |
* @author Makoto Matsutake |
|---|
| 21 |
*/ |
|---|
| 22 |
class jp.cellfusion.commands.LoaderCommand extends CommandBase { |
|---|
| 23 |
private var mcl:MovieClipLoader, url:String, path:Object; |
|---|
| 24 |
|
|---|
| 25 |
/** |
|---|
| 26 |
* @param url 読み込むURL |
|---|
| 27 |
* @param path 読み込み先 |
|---|
| 28 |
*/ |
|---|
| 29 |
public function LoaderCommand(url:String, path:Object) { |
|---|
| 30 |
super(); |
|---|
| 31 |
|
|---|
| 32 |
if (url == "" || url == null) throw new Error("urlが空です。"); |
|---|
| 33 |
else this.url = url; |
|---|
| 34 |
|
|---|
| 35 |
if (path == "" || path == null) throw new Error("pathが空です。"); |
|---|
| 36 |
else this.path = path; |
|---|
| 37 |
|
|---|
| 38 |
mcl = new MovieClipLoader(); |
|---|
| 39 |
mcl.addListener(this); |
|---|
| 40 |
} |
|---|
| 41 |
|
|---|
| 42 |
/** |
|---|
| 43 |
* 実行 |
|---|
| 44 |
*/ |
|---|
| 45 |
public function execute():Boolean { |
|---|
| 46 |
mcl.loadClip(url, path); |
|---|
| 47 |
|
|---|
| 48 |
return true; |
|---|
| 49 |
} |
|---|
| 50 |
|
|---|
| 51 |
/** |
|---|
| 52 |
* クローン |
|---|
| 53 |
*/ |
|---|
| 54 |
public function clone():LoaderCommand { |
|---|
| 55 |
return new LoaderCommand(url, path); |
|---|
| 56 |
} |
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 |
private function onLoadStart(target:MovieClip):Void { |
|---|
| 60 |
dispatchEvent({type:COMMAND_START, target:target, url:url}); |
|---|
| 61 |
} |
|---|
| 62 |
|
|---|
| 63 |
private function onLoadProgress(target:MovieClip, loaded:Number, total:Number):Void { |
|---|
| 64 |
dispatchEvent({type:COMMAND_PROGRESS, target:target, loaded:loaded, total:total, url:url}); |
|---|
| 65 |
} |
|---|
| 66 |
|
|---|
| 67 |
private function onLoadComplete(target:MovieClip):Void { |
|---|
| 68 |
} |
|---|
| 69 |
|
|---|
| 70 |
private function onLoadInit(target:MovieClip):Void { |
|---|
| 71 |
dispatchEvent({type:COMMAND_COMPLETE, target:target, url:url}); |
|---|
| 72 |
} |
|---|
| 73 |
|
|---|
| 74 |
private function onLoadError():Void { |
|---|
| 75 |
trace("error"); |
|---|
| 76 |
} |
|---|
| 77 |
} |
|---|