• ベストアンサー
※ ChatGPTを利用し、要約された質問です(原文:startDrag()について)

startDrag()について

このQ&Aのポイント
  • startDrag()を使用して、400px×300pxの範囲内で1600px×1400pxのMCをドラッグする方法について教えてください。
  • startDrag(false, left, top, right, bottom)のパラメータ設定だけでは、うまく制限できない場合もあります。他の方法での制限方法についても教えてください。
  • SEOを意識したハッシュタグを5つ作成しました。

質問者が選んだベストアンサー

  • ベストアンサー
  • BlurFiltan
  • ベストアンサー率91% (1611/1754)
回答No.2

#1です。 ステージの基準は左上のコーナーが(0 , 0)です。 その(0 , 0)から考えて,ムービークリップの基準点の座標を範囲指定してやればいいのですから, 次のような感じでできると思います↓。 on (press) { // 左限界はステージの幅から自分自身の幅の半分 hidari = Stage.width-this._width/2; // 上限界はステージ高さから自分自身の高さの半分 ue = Stage.height-this._height/2; // 右限界は自分自身の幅の半分 migi = this._width/2; // 下限界は自分自身の高さの半分 sita = this._height/2; this.startDrag(false, hidari, ue, migi, sita); } on (release, releaseOutside) { this.stopDrag(); }

danmarino
質問者

お礼

ありがとうございました。 バッチリできました。

全文を見る
すると、全ての回答が全文表示されます。

その他の回答 (1)

  • BlurFiltan
  • ベストアンサー率91% (1611/1754)
回答No.1

> おそらく「何に対するleft,top,right,bottom」という理解が > できていないと思うのですが、 なんとなく,それは違う気がします。 基準点を理解していないのではないかと思います。 1600px×1400px の MC の基準点はどこにあるでしょうか。 それがわからないと,誰もが left,top,right,bottom の指定の仕方がわかりません。 インスタンスの基準点 http://homepage3.nifty.com/ginga-b/MX/inst_refpoint.html また,その基準点もデフォルトでは親階層内の座標になりますから,1600px×1400px の MC の階層によっても回答は変わる場合があります。 ターゲットパス http://homepage3.nifty.com/ginga-b/MX/targetpath.html

danmarino
質問者

お礼

早速のご回答ありがとうございます。 MCの基準点は1600px×1400pxのちょうど中央に設定してあります。 MCをおいてある階層は、シーン1の最初のフレームにおいてあるので、(おそらく)root直下ということになります。 このような状況でどうでしょうか?

全文を見る
すると、全ての回答が全文表示されます。

関連するQ&A

  • 縮小させる時の基点について

    ActionScriptを勉強中です。分からないことがあるので質問させていただきます。 ステージ上にマスクをかけたムービークリップ(インスタンス名:mc)があり、 そのmcを拡大ボタンと縮小ボタンを使い拡大/縮小できるようにしています。 mcが拡大されている時には、mc自体をドラッグして動かせるようにしています。 レイヤー構造は ーーーーーーーーーーーーーーーーーーーーーーーーーーーー 1、ボタン:拡大ボタンと縮小ボタンを配置 2、マスク ---マスクの対象:mcを配置 3、背景:背景というか枠を書いています ーーーーーーーーーーーーーーーーーーーーーーーーーーーー となっております。 mcにには ーーーーーーーーーーーーーーーーーーーーーーーーーーーー on (press) { left = Stage.width-this._width/2-2; top = Stage.height-this._height/2-98; right = this._width/2+2; bottom = this._height/2+2; this.startDrag(false, left, top, right, bottom); } on (release, releaseOutside) { this.stopDrag(); } ーーーーーーーーーーーーーーーーーーーーーーーーーーーー 拡大ボタンには ーーーーーーーーーーーーーーーーーーーーーーーーーーーー on (release) { if (mc._yscale < 300) { mc._xscale = mc._yscale += 100; } else { mc._xscale = mc._yscale = 300; } }ーーーーーーーーーーーーーーーーーーーーーーーーーーーー 縮小ボタンには ーーーーーーーーーーーーーーーーーーーーーーーーーーーー on (release) { if (mc._yscale > 100) { mc._xscale = mc._yscale -= 100; } else { mc._xscale = mc._yscale = 100; } } ーーーーーーーーーーーーーーーーーーーーーーーーーーーー と書いています。 拡大した時の挙動は問題ないのですが、縮小する時の挙動に問題があります。 mcの中心を基点にしているため、端の方でで縮小すると余白が見えてしまいます。 この余白を見せないためにはどうしたら良いのでしょうか? 素人考えでhitTest()を使えば良いのかと思っているのですが、なかなかうまくいきません。 どうしたらよいのかご教示いただけると助かります。よろしくお願いいたします。 制作環境はCS4でAS2.0です。

  • CSSのposition値の上書き(打消)について

    現在、スタイルシートにてサイトを制作中です。 トップページとその他のページでposition: absolute; で配置を変えたいDIV要素があり、 以下のようなCSSを記述してテスト中です。 (※トップページにはbodyに#topというIDを割り振ったとします。) <style>  div#test {position: absolute; left: 10px; top: -20px; width: 980px; height:160px;}  body#top div#test {bottom: 80px; right: 15px;} </style> <div id="test"></div> 上記のように、トップページのみに body#top div#test として上の要素のサイズなどを 継承していますが、 position の値のみを top → bottom に、left → right に変更して設定にしようとしております。 通常ページでは position を left と top からの位置で適用しておりますが、 トップのみ bottom と right から適用する必要がある場所に配置したいと考えています。 しかし上記のように継承して記述しても、 トップページではどうしても left と top からの指定となってしまい、 bottom: 80px; right: 15px; という新たなposition値は無視されてしまうようなのです。 横幅などは通常下にあるものが上書きされるのですが、この場合には駄目な様です・・・。 ここで難しいのは、top → bottom に、left → right に変更したいという点にあると思います。 つまり上書きは出来ないため、上の要素のtop 、 left はそのまま継承されてしまうようです。 top 、 left 、bottom 、 right のすべてを body#top div#test に記述しても駄目なので、 どうにかして継承元の top と left の設定を下位で継承させない (無効にする?)ような方法はありませんか? 参考本やネット上の情報でも、このあたりの記述は無く、 今まであまりこのように position をページごとに別の方向から指定するように スタイルシートを書いたことが無いため、完全にわからない状態です。 お分かりになられる方がいらっしゃいましたら、アドバイスいただければ幸いです。

    • ベストアンサー
    • CSS
  • IE6でfloatされない。

    IE6でfloatされない。 横幅950pxのコンテンツの中に divで3つのboxを作って横一列に並べているのですが ie7,8, firefoxでは意図した通りに表示されますがie6ではdiv id="c"(下記ソース)がfloatされません、どなたか解決策をご指導お願いします。 <div id="a"><img src="img/left.png" width="403" height="240" alt="スペース左" title="" /></div> <div id="b"><iframe name="iframe3" id="iframe3" frameborder="0" scrolling="no" src="home.html" title="******">*******</iframe></div> <div id="c"><img src="img/right.png" width="403" height="240" alt="スペース右" title="" /></div> css記述は下記の通りです #a{ padding-top : 0px; padding-left : 0px; padding-right : 0px; padding-bottom : 0px; margin-top : 0px; margin-left : 0px; margin-right : 0px; margin-bottom : 0px; width : 403px; height : 240px; float : left; display : inline; } #b{ padding-top : 0px; padding-left : 0px; padding-right : 0px; padding-bottom : 0px; margin-top : 0px; margin-left : 0px; margin-right : 0px; margin-bottom : 0px; width : 144px; height : 240px; float : left; display : inline; } #c{ padding-top : 0px; padding-left : 0px; padding-right : 0px; padding-bottom : 0px; margin-top : 0px; margin-left : 0px; margin-right : 0px; margin-bottom : 0px; width : 403px; height : 240px; float : left; display : inline; } #iframe3{ border-width : 0px 0px 0px 0px; margin-left : 0px; width : 144px; height : 240px; padding-top : 0px; overflow : hidden; margin-top : 0px; margin-right : 0px; margin-bottom : 0px; padding-bottom : 0px; padding-left : 0px; padding-right : 0px; } 宜しくお願いします。

  • div入れ子、親でmarginを設定すると子のmarginは反映されない?

    段組みレイアウトでdivが 入れ子になってています。 外側が <div id=wrap> <div id=main> <div id=form> </div> </div> </div> #wrap{ width: 840px; margin-top: 0px; margin-right: auto; margin-bottom: 15px; margin-left: auto; } #main { width: 582px; float: right; padding: 0; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 10; } #form { width: 562px; padding: 0; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 20; } としてあります。 id=formのmargin-left :20; だけがブラウザで反映されず、 flort:right;で右に寄せて左に20pxあけました。 id=mainもflort:right;で右に寄っているだけだったようです。 divを入れ子に使う場合、 親でmarginを設定したら、子のmarginは反映されないのでしょうか?

    • ベストアンサー
    • HTML
  • 横線の書き方

    CSSを使って横線を記述しようとしています。 こんな感じで書きました。 css------------------- .udl5 { margin-right: 5px; margin-left: 5px; margin-top: 3px; margin-bottom: 1px; border-left-style: none; border-left-width: 0px; border-right-style: none; border-right-width: 0px; border-top-width: 1px; border-top-style: solid; border-top-color: #666666; border-bottom-style: none; border-bottom-width: 0px; width: 600px; height: 1px; } ----------------------------------------------- html------------------------------------------- <div class="udl5"></div> ----------------------------------------------- こんな感じで記述したのですがIE7ではちゃんと 表示されるのですが、IE6だと線の下に10pxぐらいの 空欄ができてしまいます。 なぜでしょうか? もし知っている方がいれば教えていただければと思います。 よろしくお願いします。

  • この度HPを作成していて疑問に思ったのですが、imgを回り込ませたとき

    この度HPを作成していて疑問に思ったのですが、imgを回り込ませたときなどに、添付画像の様にならなくする方法はありますか? なるべくCSSでそれを行いたいのですが、高さを指定してなどは、やりたくありません よろしくお願いします。 HTML <h2>キングギドラ公開開始 </h2> <p class="up"> <img src="file:///C:/Users/chako/Desktop/G-Works/img/lrg53616_0_357935.png" width="150" height="112" border="0"> キンブギドラ公開しました詳細はギャラリーより </p> CSS .up{ bottom : auto; line-height : 15px; border-bottom-width : 2px; border-bottom-style : dotted; border-bottom-color : #990000; } h2{ margin-top : 0px; margin-left : 0px; margin-right : 0px; margin-bottom : 0px; height : 20px; border-bottom-width : 2px; border-bottom-style : dotted; border-bottom-color : #990000; bottom : auto; padding-top : 5px; font-size : 20px; } #right img{ float : left; margin-top : 0px; margin-left : 5px; margin-right : 10px; margin-bottom : 10px; }

  • CSSで枠線の太さを変えるとき

    CSSでlistタグを使ってナビゲーションを作る練習をしています。 CSSで以下のように書いた場合、a:hover時の動作として、上の枠線のみが1pxから5pxに変わります。しかし、この方法だと、【上の枠線の下】が5pxとなり、その分、入力してある文字が下にずれます。 そこで、ずれないように、【上の枠線の上】に5px増やすにはどうすればいいでしょうか。 あるいは、そのように見せるための方法がありますか。画像は使用しないで作りたいです。 よろしくお願いします(CSSは初心者程度のレベルです)。 ================================================== ul{ list-style-type:none; } a{ text-decoration:none; } li a{ border-top-style:solid; border-right-style:solid; border-bottom-style:solid; border-left-style:solid; border-top-width:1px; border-right-width:1px; border-bottom-width:1px; border-left-width:1px; border-top-color:red; border-right-color:green; border-bottom-color:green; border-left-color:green; width:8em; } li a:hover{ border-top-style:solid; border-right-style:solid; border-bottom-style:solid; border-left-style:solid; border-top-width:5px; border-right-width:1px; border-bottom-width:1px; border-left-width:1px; border-top-color:red; border-right-color:green; border-bottom-color:green; border-left-color:green; width:8em; } ==================================================

    • ベストアンサー
    • CSS
  • floatとclearを使ったレイアウト作成について

    http://www.ario-nishiarai.jp/ 上記のサイトのようなページ中央より下のレイアウトを作りたいと思い、下記のようにコーディングしました。 <html> <head> <title>Web</title> <style type="text/css"> .container {text-align:left;width:760px;margin:0px auto;background-color:#FFFFFF;} .content1 {width:760px; height:200; padding:0px; border:1px solid #999999;} .content2 {width:760px;padding:0px;border-right:1px solid #999999; border-bottom:1px solid #999999; border-left:1px solid #999999; margin:0;} .box1 {width:180px; float:left; border-top:1px solid #CCCCCC; border-left:1px solid #CCCCCC; border-right:1px solid #CCCCCC; border-bottom:1px solid #CCCCCC; margin-top:5px; margin-left:5px;} .box2 {width:180px; float:left; border-top:1px solid #CCCCCC; border-left:1px solid #CCCCCC; border-right:1px solid #CCCCCC; border-bottom:1px solid #CCCCCC; margin-top:5px; margin-left:5px;} .box3 {width:180px; float:left; border-top:1px solid #CCCCCC; border-left:1px solid #CCCCCC; border-right:1px solid #CCCCCC; border-bottom:1px solid #CCCCCC; margin-top:5px; margin-left:5px;} .box4 {width:180px; float:left; border-top:1px solid #CCCCCC; border-left:1px solid #CCCCCC; border-right:1px solid #CCCCCC; border-bottom:1px solid #CCCCCC; margin-top:5px; margin-left:5px; margin-bottom:10px;} .box5 {width:220px; float:right; border-top:1px solid #CCCCCC; border-left:1px solid #CCCCCC; border-right:1px solid #CCCCCC; border-bottom:1px solid #CCCCCC; margin-top:5px; margin-left:5px;} .box6 {width:220px; float:right; border-top:1px solid #CCCCCC; border-left:1px solid #CCCCCC; border-right:1px solid #CCCCCC; border-bottom:1px solid #CCCCCC; margin-top:5px; margin-left:5px;} .news {width:350px; height:200; overflow:auto; border-top:1px solid #CCCCCC; border-left:1px solid #CCCCCC; border-right:1px solid #CCCCCC; border-bottom:1px solid #CCCCCC; margin-top:5px; margin-left:5px;} .topics {width:350px; height:200; overflow:auto; border-top:1px solid #CCCCCC; border-left:1px solid #CCCCCC; border-right:1px solid #CCCCCC; border-bottom:1px solid #CCCCCC; margin-top:5px; margin-left:5px;}solid #CCCCCC; margin-top:5px; margin-left:5px;} </style> </head> <body> <div class="container"> <div class="content1"> 画像 </div> <div class="content2"> <!--左側--> <div class="box1"> タイトル<br /> メニュー </div> <div class="box2"> タイトル<br /> メニュー </div> <div class="box3"> タイトル<br /> メニュー </div> <div class="box4"> タイトル<br /> メニュー </div> <!--中央--> <div class="news"> あ </div> <div class="topics"> い </div> <!--右側--> <div class="box5"> う </div> <div class="box6"> え </div> </div> </div> </body> </html> box1、box2、box3、box4のボックスは左側に、news、topicsのボックスは中央に、box5、box6のボックスは右側にレイアウトしたいと思っています。 floatとclearを使って作成するのだと思うのですが、どうコーディングしたら良いのかわかりません。 どこをどう直したら良いかアドバイスいただけますようお願いします。

    • ベストアンサー
    • HTML
  • CSSのcaption-side:・・・

    続けて質問すみません。 CSSのcaption-side:なのですが、 right / left / bottom はテーブルのどこに配置されるのが正しい配置ですか?        TOP   ┏━━━━━━━━━━━┓   ┃              ┃   ┃              ┃ left┃              ┃right   ┃              ┃   ┃              ┃   ┗━━━━━━━━━━━┛        bottom ですか?  left   TOP  right ┏━━━━━━━━━━━┓ ┃              ┃ ┃              ┃ ┃              ┃ ┃              ┃ ┃              ┃ ┗━━━━━━━━━━━┛      bottom ですか?

  • cssハックについて

    googleとfirefoxでcssが聞かない箇所があります。 css--------- #operation { width: 420px; background-image: url(../picture/top/left_middle.jpg); background-repeat: repeat-y; background-position: center top; margin-top: 10px; } #operation img { border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; } #operation #ope_top { background-image: url(../picture/top/left_top.jpg); background-repeat: no-repeat; background-position: left top; height: 30px; padding-bottom: 0px; margin-bottom: 0px; } #operation #ope_top #ope_tit { font-size: 14px; line-height: 2; font-weight: bold; color: #FFFFFF; text-indent: 10px; float: left; width: 200px; margin-top: 0px; padding-top: 0px; height: 20px; } #operation #ope_top .ope_img { padding-top: 5px; float: right; margin-right: 10px; } #operation #ope_middle { margin-top: 0px; padding-top: 0px; width: 420px; margin-left: -200px;←ここがおかしいです!! } #operation #ope_middle .content ul { margin-top: 5px; padding-left: 30px; list-style-image: url(../picture/list.jpg); } #operation #ope_middle .content li { margin-bottom: 5px; margin-top: 1px; } #operation #ope_middle .content .line01 { border: 1px dotted #CCCCCC; margin-top: 2px; margin-bottom: 2px; } というかんじなのですが、左右へとぶれてしまいます。 どのように修正したいいのか困っております。 参考になるようなことありましたらお願いします。