Note that there are some explanatory texts on larger screens.

plurals
  1. POActionScript 3.0 Slider doesn't continue when sliding to start
    primarykey
    data
    text
    <p>I made a slider to search trough my actionscript video. Maybe you'll understand better if you can see what i'm working on: <a href="http://www.stevevo.sin.khk.be/Website%202SDesign/" rel="nofollow">http://www.stevevo.sin.khk.be/Website%202SDesign/</a> -> this is the link of the testserver where the website i'm building is running on. You'll see the huge banner in the center, rollover it an you'll see a slider and a pause/start button. The slider works great exept for 1 little thing. When you drag the slider to the utter left actionScript 3.0 will start the movie again (i asume), now drag to the right without interuptions and the slider won't move to the right as he should (all in one drag).</p> <p>Why ain't it possible to first slide to the start and then continue sliding?</p> <p>MY CODE:</p> <p>very simple. You start dragging, the rectangle is the dragRestriction. The Movie stops. isDragging = true.</p> <pre><code>SearchBarSlider.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag); function fl_ClickToDrag(event:MouseEvent):void { var rect:Rectangle = new Rectangle(SearchBar.x + 3, SearchBar.y, SearchBar.width - 10, 0); SearchBarSlider.startDrag(false, rect); stop(); isDraging = true; } </code></pre> <p>Again easy peasy. Drag stops. Movie starts to play again. isdragging = false;</p> <pre><code>stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop); function fl_ReleaseToDrop(event:MouseEvent):void { SearchBarSlider.stopDrag(); play(); isDraging = false; } </code></pre> <p>When the mouse moves when dragging the x-position of the slider will be converted to the right amount of frames. In between the 3 parts other lengths aply.</p> <pre><code>stage.addEventListener(MouseEvent.MOUSE_MOVE, fl_Drag); function fl_Drag(event:MouseEvent):void { if(isDraging == true) { if(SearchBarSlider.x - (SearchBar.x + 3) &lt; 20){ gotoAndStop(Math.round(((SearchBarSlider.x - (SearchBar.x + 3)) / 20) * 320)); } else if(SearchBarSlider.x - SearchBar.x + 3 &gt;= 20 &amp;&amp; SearchBarSlider.x - SearchBar.x + 3 &lt; 40){ gotoAndStop(Math.round(((SearchBarSlider.x - (SearchBar.x + 3) - 20) / 20) * 365) + 365); } else { gotoAndStop(Math.round(((SearchBarSlider.x - (SearchBar.x + 3) - 40) / 20) * 465) + 685); } } } </code></pre> <p>This event accurs at every frame when not dragging. But instead of converting the x-position of the slider to frames this will convert frames to x-positon of the slider.</p> <pre><code>stage.addEventListener(Event.ENTER_FRAME, fl_frameEvent); function fl_frameEvent(e:Event):void { if(isDraging == false) { if(currentFrame &lt; 365){ SearchBarSlider.x = SearchBar.x + 3 + Math.round((currentFrame / 365) * 20); } else if(currentFrame &gt;= 365 &amp;&amp; currentFrame &lt; 685){ SearchBarSlider.x = SearchBar.x + 23 + Math.round(((currentFrame - 365) / 320) * 20); } else { SearchBarSlider.x = SearchBar.x + 43 + Math.round(((currentFrame - 685) / 465) * 20); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    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