Note that there are some explanatory texts on larger screens.

plurals
  1. POAS3 (Adobe AIR / Flash) gotoAndPlay causing immense lag, even though it's only being called once?
    primarykey
    data
    text
    <p>I am creating a game, in AS3, in Flash CS4, with Adobe AIR. The game has gotten too large and complex for me to share the full thing on here, but I will try to explain my problem.</p> <p>The background of my game is animated water, and it is a symbol separate of the game character and the other entities in the game. When the character performs certain tasks, the water animation needs to jump to a certain frame. This should be really easy:</p> <pre><code>water_background.gotoAndPlay(the_frame); </code></pre> <p>However, this for some reason is causing a lot of lag, regardless of the machine I use it on. Right when the gotoAndPlay fires off, there is about a 700 millisecond delay where everything freezes up, and then when it comes out of it, all the animations already have completed and the water is playing from the appropriate frame, however the user misses all the pretty animation because the game freezes during it. </p> <p>I've been trying to figure this out for hours. I've googled everything I could think of and have yet to find an answer. </p> <p>I am a little concerned it might be because my symbol has a large number of frames... it is 850 frames. </p> <p>Can anyone shed some light on this for me?</p> <p>Here is the relevant code. This is run in response to a keyboard action by the user:</p> <pre><code>//the nearest frame to jump to in FRONT of the current frame, when something is succesfully eaten. var nearest_clear_frame:int = 1; var curr_frame = water_background.currentFrame; var i; var skipped_frames:int = 0; for(i = 0; i &lt; clear_frames.length -1; i++) { var new_delta = (clear_frames[i]-curr_frame); var old_delta = (nearest_clear_frame-curr_frame); if((new_delta&lt;old_delta || old_delta&lt;0)&amp;&amp; new_delta &gt;= 1){ nearest_clear_frame = clear_frames[i]; skipped_frames = nearest_clear_frame -curr_frame; } } water_background.gotoAndPlay(nearest_clear_frame); </code></pre> <p><code>water_background</code> is the movieClip of the water background t hat is about a 30 second looping video.</p> <p><code>clear_frames</code> is defined like so:</p> <pre><code>public var clear_frames:Array = [1, 109, 272, 413, 529, 690, 830]; </code></pre> <p><code>clear_frames</code> is defined in a separate class, but the class that the main code is in is an extension of that separate class, so I believe I should have full access to it</p> <p>Any help is greatly appreciated, thank you.</p> <p><strong>EDIT</strong></p> <hr> <p><code>gotoAndPlay(1)</code> functions perfectly smooth, but some of the other frames don't, even if I type them in manually instead of using the array.</p> <p>Here is the size report for the thing:</p> <pre><code>turtle_game.swf Movie Report ----------------------------- Metadata -------- Bytes Value ----- ----- 1290 &lt;rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"&gt; &lt;rdf:Description rdf:about="" xmlns:xmp="http://ns.adobe.com/xap/1.0/"&gt; &lt;xmp:CreatorTool&gt;Adobe Flash CS4 Professional&lt;/xmp:CreatorTool&gt; &lt;xmp:CreateDate&gt;2011-11-14T14:28:55-08:00&lt;/xmp:CreateDate&gt; &lt;xmp:MetadataDate&gt;2011-12-31T12:34:19-08:00&lt;/xmp:MetadataDate&gt; &lt;xmp:ModifyDate&gt;2011-12-31T12:34:19-08:00&lt;/xmp:ModifyDate&gt; &lt;/rdf:Description&gt; &lt;rdf:Description rdf:about="" xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/" xmlns:stRef="http://ns.adobe.com/xap/1.0/sType/ResourceRef#"&gt; &lt;xmpMM:InstanceID&gt;xmp.iid:DCA89ABBEE33E1119D5DF3032563A207&lt;/xmpMM:InstanceID&gt; &lt;xmpMM:DocumentID&gt;xmp.did:DCA89ABBEE33E1119D5DF3032563A207&lt;/xmpMM:DocumentID&gt; &lt;xmpMM:OriginalDocumentID&gt;xmp.did:2F1CC129100FE111B280DE374C2F22D4&lt;/xmpMM:OriginalDocumentID&gt; &lt;xmpMM:DerivedFrom rdf:parseType="Resource"&gt; &lt;stRef:instanceID&gt;xmp.iid:B51A6ED0190FE111B280DE374C2F22D4&lt;/stRef:instanceID&gt; &lt;stRef:documentID&gt;xmp.did:B51A6ED0190FE111B280DE374C2F22D4&lt;/stRef:documentID&gt; &lt;stRef:originalDocumentID&gt;xmp.did:2F1CC129100FE111B280DE374C2F22D4&lt;/stRef:originalDocumentID&gt; &lt;/xmpMM:DerivedFrom&gt; &lt;/rdf:Description&gt; &lt;rdf:Description rdf:about="" xmlns:dc="http://purl.org/dc/elements/1.1/"&gt; &lt;dc:format&gt;application/x-shockwave-flash&lt;/dc:format&gt; &lt;/rdf:Description&gt; &lt;/rdf:RDF&gt; Frame # Frame Bytes Total Bytes Scene ------- ----------- ----------- ---------------- 1 7792727 7792727 Scene 1 (AS 3.0 Classes Export Frame) 2 2 7792729 3 2 7792731 4 2 7792733 5 2 7792735 6 2 7792737 ... i checked all of these and they are roughly identical ... 837 2 7794399 838 2 7794401 839 2 7794403 840 2 7794405 Scene Shape Bytes Text Bytes ActionScript Bytes ------------------------- ----------- ---------- ------------------ Scene 1 0 0 49218 Symbol Shape Bytes Text Bytes ActionScript Bytes ------------------------- ----------- ---------- ------------------ water_background2 0 0 0 water_background 0 0 0 background 0 0 0 gauge 0 0 0 stage_mask 0 0 0 lose_screen 0 68 0 win_screen 0 66 0 gauge_mask 38 0 0 gauge 0 0 0 gauge_shell 0 0 0 main_turtle2 0 0 0 Floating Turtle Frames 2 0 0 0 Floating Turtle Frames 0 0 0 Floating Turtle Tweens 0 0 0 Floating Turtle Frames3 0 0 0 item 0 0 0 blf 0 0 0 brf 0 0 0 tlf 0 0 0 trf 0 0 0 body 0 0 0 Tween 1 0 0 0 Tween 2 0 0 0 main_turtle 0 0 0 Font Name Bytes Characters ---------------------- --------- -------------- TimesNewRomanPSMT 1633 !LWYnostu ActionScript Bytes Location ------------------ -------- 49218 Scene 1:Frame 1 Bitmap Compressed Compression ----------------------- ---------- -------- ----------- jelly.png 4546 133056 JPEG Quality=80 bag.png 6289 176148 JPEG Quality=80 6pack.png 4730 57936 JPEG Quality=80 turtle.png 40215 2743296 JPEG Quality=80 back left flipper 3524 56144 JPEG Quality=80 back right flipper 4664 63448 JPEG Quality=80 top left flipper 6228 123300 JPEG Quality=80 top right flipper 4407 69552 JPEG Quality=80 body 18132 242740 JPEG Quality=80 Gauge-shell.png 10399 236160 JPEG Quality=80 portal.png 215640 8294400 JPEG Quality=80 Outside Template 140809 7542720 JPEG Quality=80 Finish 3510 39432 JPEG Quality=80 Start 3303 39008 JPEG Quality=80 Shark A 6454 115320 JPEG Quality=80 Shark B 6360 96672 JPEG Quality=80 Shark C 6275 96672 JPEG Quality=80 Red Boat 10781 226872 JPEG Quality=80 Green Boat 11601 241664 JPEG Quality=80 Yellow Boat 12305 245504 JPEG Quality=80 Green Leatherback 3755 38352 JPEG Quality=80 Globe 248169 5607360 JPEG Quality=80 Shadow 507039 8294400 JPEG Quality=80 Dimpled Aluminum 489466 8294400 JPEG Quality=80 progress_meter.jpg 17398 558112 Imported JPEG=102 Video Compressed ------------------------ ---------- background.flv 5933617 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload