开发者

how to embed swf file in ahref tag?

开发者 https://www.devze.com 2022-12-09 07:03 出处:网络
i have an a href tag. i want that embed swf (object) tag to a开发者_如何学编程 href. i dont want add event in swf, beacuse a href link is different and create dynamic.

i have an a href tag. i want that embed swf (object) tag to a开发者_如何学编程 href. i dont want add event in swf, beacuse a href link is different and create dynamic. underestand it? what can i do?


Ok. Answer:

1.Process the html used in htmlText property of textField: - find and put <a>...</a> strings to Array

  • check if Arrays strings have <img ...> strings inside them and put {url:hrefFromString, img:idFromString, object:null} to new Array

2.Create mouseDownHandler:

function mouseDownHandler(e:MouseEvent):void{ 
   for(var i:uint = 0; i<array.length; i++){
      if(e.target == array[i].object){
         navigateToURL(new URLRequest(array[i].url));
   }
}

3.Add addEventListener Event.ADDED to textField with handler:

for(var i:int=0; i<array.length; i++){
   var dsp:Loader =  textField.getImageReference(array[i].img) as Loader;
   if(dsp!=null and array[i].object!=null){
      array[i].object = dsp;
      dps.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
      dsp.mousChildren = false;
   }
}

Finito! You don't only have mouseButton cursor. Remember to add in html id for images! Sample:

<a href='http://...'><img id='img1' src='...'></a>
0

精彩评论

暂无评论...
验证码 换一张
取 消