Skip to content
This repository has been archived by the owner on May 15, 2022. It is now read-only.

abortAsyncProcess() #11

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target
82 changes: 82 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<repositories>
<repository>
<id>sonatype</id>
<url>http://repository.sonatype.org/content/groups/flexgroup/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>sonatype</id>
<url>http://repository.sonatype.org/content/groups/flexgroup/</url>
</pluginRepository>
</pluginRepositories>

<groupId>com.codeazur</groupId>
<artifactId>as3swf</artifactId>
<version>1.3-yelbota</version>
<packaging>swc</packaging>

<properties>
<flex.sdk.version>4.5.1.21328</flex.sdk.version>
<flexmojos.version>4.0-beta-7</flexmojos.version>
<flashplayer.version>10.2</flashplayer.version>
</properties>

<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>org.sonatype.flexmojos</groupId>
<artifactId>flexmojos-maven-plugin</artifactId>
<version>${flexmojos.version}</version>
<extensions>true</extensions>
<configuration>
<storepass/>
<filesToTrust>
<file>${build.outputDirectory}/${build.finalName}</file>
</filesToTrust>
<sourceFile>Main.as</sourceFile>
<targetPlayer>${flashplayer.version}</targetPlayer>
</configuration>
<dependencies>
<dependency>
<groupId>com.adobe.flex</groupId>
<artifactId>compiler</artifactId>
<version>${flex.sdk.version}</version>
<type>pom</type>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>com.adobe.flex.framework</groupId>
<artifactId>playerglobal</artifactId>
<version>${flex.sdk.version}</version>
<classifier>${flashplayer.version}</classifier>
<scope>provided</scope>
<type>swc</type>
</dependency>
</dependencies>

<distributionManagement>
<repository>
<id>Flexis maven repository-releases</id>
<name>Flexis maven repository-releases</name>
<url>http://artifactory.flexis.ru:8030/artifactory/flexis-local</url>
</repository>
<snapshotRepository>
<id>Flexis maven repository-snapshots</id>
<name>Flexis maven repository-snapshots</name>
<url>http://artifactory.flexis.ru:8030/artifactory/flexis-local</url>
</snapshotRepository>
</distributionManagement>
</project>
53 changes: 41 additions & 12 deletions src/com/codeazur/as3swf/SWFTimelineContainer.as
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ package com.codeazur.as3swf
public static var TIMEOUT:int = 50;
public static var AUTOBUILD_LAYERS:Boolean = false;
public static var EXTRACT_SOUND_STREAM:Boolean = true;


public static const ASYNC_PROCESS_PARSING:int = 0;
public static const ASYNC_PROCESS_PUBLISHING:int = 1;

protected var _tags:Vector.<ITag>;
protected var _tagsRaw:Vector.<SWFRawTag>;
protected var _dictionary:Dictionary;
Expand All @@ -71,25 +74,31 @@ package com.codeazur.as3swf

protected var _tagFactory:ISWFTagFactory;

protected var _currentAsyncProcess:int;
protected var abortAsyncProcessFlag:Boolean;

internal var rootTimelineContainer:SWFTimelineContainer;

public var backgroundColor:uint = 0xffffff;
public var jpegTablesTag:TagJPEGTables;

public function SWFTimelineContainer()
{
initializeCollections();
_tagFactory = new SWFTagFactory();

rootTimelineContainer = this;

enterFrameProvider = new Sprite();
}

private function initializeCollections():void {
_tags = new Vector.<ITag>();
_tagsRaw = new Vector.<SWFRawTag>();
_dictionary = new Dictionary();
_scenes = new Vector.<Scene>();
_frames = new Vector.<Frame>();
_layers = new Vector.<Layer>();

_tagFactory = new SWFTagFactory();

rootTimelineContainer = this;

enterFrameProvider = new Sprite();
}

public function get tags():Vector.<ITag> { return _tags; }
Expand Down Expand Up @@ -118,8 +127,17 @@ package com.codeazur.as3swf
while ((tag = parseTag(data)) && tag.type != TagEnd.TYPE) {};
parseTagsFinalize();
}


public function abortAsyncProcess():void {
if (_currentAsyncProcess == ASYNC_PROCESS_PARSING)
initializeCollections();

abortAsyncProcessFlag = true;
}

public function parseTagsAsync(data:SWFData, version:uint):void {
abortAsyncProcessFlag = false;
_currentAsyncProcess = ASYNC_PROCESS_PARSING;
parseTagsInit(data, version);
enterFrameProvider.addEventListener(Event.ENTER_FRAME, parseTagsAsyncHandler);
}
Expand All @@ -134,12 +152,14 @@ package com.codeazur.as3swf
protected function parseTagsAsyncInternal():void {
var tag:ITag;
var time:int = getTimer();
while ((tag = parseTag(_tmpData, true)) && tag.type != TagEnd.TYPE) {
while ((tag = parseTag(_tmpData, true)) && tag.type != TagEnd.TYPE && !abortAsyncProcessFlag) {
if((getTimer() - time) > TIMEOUT) {
enterFrameProvider.addEventListener(Event.ENTER_FRAME, parseTagsAsyncHandler);
return;
}
}
if (abortAsyncProcessFlag)
return;
parseTagsFinalize();
if(eof) {
dispatchEvent(new SWFErrorEvent(SWFErrorEvent.ERROR, SWFErrorEvent.REASON_EOF));
Expand Down Expand Up @@ -224,6 +244,8 @@ package com.codeazur.as3swf
}

public function publishTagsAsync(data:SWFData, version:uint):void {
abortAsyncProcessFlag = false;
_currentAsyncProcess = ASYNC_PROCESS_PUBLISHING;
_tmpData = data;
_tmpVersion = version;
_tmpTagIterator = 0;
Expand All @@ -249,9 +271,12 @@ package com.codeazur.as3swf
return;
}
}
while (tag.type != TagEnd.TYPE);
dispatchEvent(new SWFProgressEvent(SWFProgressEvent.PROGRESS, _tmpTagIterator, tags.length));
dispatchEvent(new SWFProgressEvent(SWFProgressEvent.COMPLETE, _tmpTagIterator, tags.length));
while (tag.type != TagEnd.TYPE && !abortAsyncProcessFlag);

if (!abortAsyncProcessFlag) {
dispatchEvent(new SWFProgressEvent(SWFProgressEvent.PROGRESS, _tmpTagIterator, tags.length));
dispatchEvent(new SWFProgressEvent(SWFProgressEvent.COMPLETE, _tmpTagIterator, tags.length));
}
}

public function publishTag(data:SWFData, tag:ITag, rawTag:SWFRawTag, version:uint):void {
Expand Down Expand Up @@ -495,5 +520,9 @@ package com.codeazur.as3swf
}
return str;
}

public function get currentAsyncProcess():int {
return _currentAsyncProcess;
}
}
}