2011-02-06 4 views
0

解決済みの質問がいくつか見られましたが、誰かが助けることができるかどうか疑問に思っていた。AS3外部プレローダーはFlash CS5で動作しますが、ブラウザでは動作しません(Chrome、Ff、IE) - 100%でスティックする

私は映画(ayproj.swf)を読み込むために外部プリローダー(loader.swf)を使用しています。プリローダーは、Flash Playerで.swfファイルを実行していて、Flash cs5でダウンロードをシミュレートするときにうまく動作しますが、インターネットにアップロードして、flashが100%フレームにあるindex.htmlを開くと、100 %(FfとIE)、または単に "pl"(chrome) - ダイナミックパーセンテージテキストボックスの最初のテキストです。

プリローダーのコードは次のとおりです。

stop(); 

import flash.net.URLRequest; 
import flash.events.Event; 
import flash.events.ProgressEvent; 
import flash.display.Loader; 
import com.greensock.TweenNano; 

stage.scaleMode = StageScaleMode.NO_SCALE; 
stage.align = StageAlign.TOP_LEFT; 

stage.addEventListener(Event.RESIZE, onStageResize); 
addEventListener(Event.ENTER_FRAME, onFrame); 

var barcomp:Number = stage.stageWidth; 
percentContainer.x = stage.stageWidth/2 - percentContainer.width/2; 
percentContainer.y = stage.stageHeight/2 - percentContainer.height/2; 

function onStageResize(evt:Event):void { 

    bar_mc.x = 0; 
    bar_mc.y = (stage.stageHeight) - 3; 
    bar_mc.height = 20; 
    barcomp = stage.stageWidth; 

    percentContainer.x = stage.stageWidth/2 - percentContainer.width/2; 
    percentContainer.y = stage.stageHeight/2 - percentContainer.height/2; 

} 



function onFrame(evt:Event):void { 

    bar_mc.x = 0; 
    bar_mc.y = (stage.stageHeight) - 3; 
    bar_mc.height = 20; 
    barcomp = stage.stageWidth; 

    percentContainer.x = stage.stageWidth/2 - percentContainer.width/2; 
    percentContainer.y = stage.stageHeight/2 - percentContainer.height/2; 
} 

var loader:Loader = new Loader(); 

loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop); 
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, done); 
loader.load(new URLRequest("ayproj.swf")); 
loader.visible = false; 

function loop(e:ProgressEvent):void { 

    var perc:Number = e.bytesLoaded/e.bytesTotal; 
    var s:String = Math.ceil(perc*100).toString()+"%"; 
    percentContainer.percent.text = s 
    bar_mc.width = perc * barcomp; 
} 

function done(e:Event):void { 

    removeChildAt(getChildIndex(percentContainer)); 
    removeChildAt(getChildIndex(bar_mc)); 

    percentContainer.percent = null; 

    stage.addChild(loader); 

    TweenNano.delayedCall(0.5, fadeInAyproj); 
} 

function fadeInAyproj():void { 

    loader.visible = true; 
    TweenNano.to(loader, 0.8, {alpha:0}); 
    TweenNano.from(loader, 0.8, {alpha:0}); 
} 

誰が助けることができれば、私は非常に感謝されます。

+0

あなたのFlashコードではないかもしれませんが、埋め込みです。ここにあなたのHTMLコードを入れてもらえますか? – robertp

答えて

0

ProgressEventハンドラにも100%がロードされていることを確認する必要があります。 completeイベントが発生しないことがあります。

function loop(e:ProgressEvent):void { 

    var perc:Number = e.bytesLoaded/e.bytesTotal; 
    if (perc >= 100) done (e); 

//...more code 
} 

また、必ずayproj.swfはindex.htmlを同じフォルダにある、またはindex.htmlをのパスへの要求URLが相対作るされていることを確認。

+0

はい、プリローダーswfファイルの "ayproj.swf"がウェブサイト上の "flash/ayproj.swf"と言っているはずです。上記のコードなしでも動作します。あなたの助けをありがとう:D –

関連する問題